@mailwoman/react 8.1.0 → 8.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/common/ClientOnly.tsx +6 -2
  2. package/common/CopyButton.tsx +9 -3
  3. package/common/KindBadge.tsx +1 -1
  4. package/common/LoadingIndicator.tsx +22 -7
  5. package/common/PresetChips.tsx +6 -2
  6. package/common/cx.ts +3 -1
  7. package/common/useClipboard.ts +7 -2
  8. package/index.ts +5 -0
  9. package/map/BackendControl.tsx +12 -4
  10. package/map/CompareToggle.tsx +27 -9
  11. package/map/DemoControls.tsx +31 -11
  12. package/map/DemoMap.tsx +33 -11
  13. package/map/GeocoderDemo.tsx +25 -8
  14. package/map/OverlayLayers.tsx +7 -3
  15. package/map/PlaceAutocomplete.tsx +25 -9
  16. package/map/PlaceMarker.tsx +18 -6
  17. package/map/ResolvedPlaceLayers.tsx +15 -5
  18. package/map/ResultCamera.tsx +6 -2
  19. package/map/ResultOverlay.tsx +18 -6
  20. package/map/ResultPanel.tsx +21 -7
  21. package/map/VersionPicker.tsx +18 -6
  22. package/map/geometry.ts +28 -8
  23. package/map/index.ts +3 -0
  24. package/map/place-render.ts +36 -12
  25. package/map/types.ts +132 -44
  26. package/map/useCompareState.ts +15 -5
  27. package/map/useDemoGeocode.ts +12 -4
  28. package/map/useMapPlaceRender.ts +3 -1
  29. package/map/usePlaceAutocomplete.ts +52 -18
  30. package/out/common/ClientOnly.d.ts +6 -2
  31. package/out/common/ClientOnly.d.ts.map +1 -1
  32. package/out/common/ClientOnly.js.map +1 -1
  33. package/out/common/CopyButton.d.ts +9 -3
  34. package/out/common/CopyButton.d.ts.map +1 -1
  35. package/out/common/CopyButton.js.map +1 -1
  36. package/out/common/KindBadge.js +1 -1
  37. package/out/common/KindBadge.js.map +1 -1
  38. package/out/common/LoadingIndicator.d.ts +21 -6
  39. package/out/common/LoadingIndicator.d.ts.map +1 -1
  40. package/out/common/LoadingIndicator.js +4 -1
  41. package/out/common/LoadingIndicator.js.map +1 -1
  42. package/out/common/PresetChips.d.ts +6 -2
  43. package/out/common/PresetChips.d.ts.map +1 -1
  44. package/out/common/PresetChips.js.map +1 -1
  45. package/out/common/cx.d.ts +3 -1
  46. package/out/common/cx.d.ts.map +1 -1
  47. package/out/common/cx.js +3 -1
  48. package/out/common/cx.js.map +1 -1
  49. package/out/common/useClipboard.d.ts +3 -1
  50. package/out/common/useClipboard.d.ts.map +1 -1
  51. package/out/common/useClipboard.js +6 -2
  52. package/out/common/useClipboard.js.map +1 -1
  53. package/out/index.d.ts.map +1 -1
  54. package/out/index.js.map +1 -1
  55. package/out/map/BackendControl.d.ts +12 -4
  56. package/out/map/BackendControl.d.ts.map +1 -1
  57. package/out/map/BackendControl.js +3 -1
  58. package/out/map/BackendControl.js.map +1 -1
  59. package/out/map/CompareToggle.d.ts +27 -9
  60. package/out/map/CompareToggle.d.ts.map +1 -1
  61. package/out/map/CompareToggle.js +3 -1
  62. package/out/map/CompareToggle.js.map +1 -1
  63. package/out/map/DemoControls.d.ts +30 -10
  64. package/out/map/DemoControls.d.ts.map +1 -1
  65. package/out/map/DemoControls.js +4 -2
  66. package/out/map/DemoControls.js.map +1 -1
  67. package/out/map/DemoMap.d.ts +33 -11
  68. package/out/map/DemoMap.d.ts.map +1 -1
  69. package/out/map/DemoMap.js.map +1 -1
  70. package/out/map/GeocoderDemo.d.ts +16 -6
  71. package/out/map/GeocoderDemo.d.ts.map +1 -1
  72. package/out/map/GeocoderDemo.js +9 -3
  73. package/out/map/GeocoderDemo.js.map +1 -1
  74. package/out/map/OverlayLayers.d.ts +6 -2
  75. package/out/map/OverlayLayers.d.ts.map +1 -1
  76. package/out/map/OverlayLayers.js +4 -2
  77. package/out/map/OverlayLayers.js.map +1 -1
  78. package/out/map/PlaceAutocomplete.d.ts +24 -8
  79. package/out/map/PlaceAutocomplete.d.ts.map +1 -1
  80. package/out/map/PlaceAutocomplete.js +4 -2
  81. package/out/map/PlaceAutocomplete.js.map +1 -1
  82. package/out/map/PlaceMarker.d.ts +15 -5
  83. package/out/map/PlaceMarker.d.ts.map +1 -1
  84. package/out/map/PlaceMarker.js +6 -2
  85. package/out/map/PlaceMarker.js.map +1 -1
  86. package/out/map/ResolvedPlaceLayers.d.ts +15 -5
  87. package/out/map/ResolvedPlaceLayers.d.ts.map +1 -1
  88. package/out/map/ResolvedPlaceLayers.js +3 -1
  89. package/out/map/ResolvedPlaceLayers.js.map +1 -1
  90. package/out/map/ResultCamera.d.ts +6 -2
  91. package/out/map/ResultCamera.d.ts.map +1 -1
  92. package/out/map/ResultCamera.js +3 -1
  93. package/out/map/ResultCamera.js.map +1 -1
  94. package/out/map/ResultOverlay.d.ts +15 -5
  95. package/out/map/ResultOverlay.d.ts.map +1 -1
  96. package/out/map/ResultOverlay.js +3 -1
  97. package/out/map/ResultOverlay.js.map +1 -1
  98. package/out/map/ResultPanel.d.ts +21 -7
  99. package/out/map/ResultPanel.d.ts.map +1 -1
  100. package/out/map/ResultPanel.js +3 -1
  101. package/out/map/ResultPanel.js.map +1 -1
  102. package/out/map/VersionPicker.d.ts +18 -6
  103. package/out/map/VersionPicker.d.ts.map +1 -1
  104. package/out/map/VersionPicker.js +3 -1
  105. package/out/map/VersionPicker.js.map +1 -1
  106. package/out/map/geometry.d.ts +12 -4
  107. package/out/map/geometry.d.ts.map +1 -1
  108. package/out/map/geometry.js +17 -5
  109. package/out/map/geometry.js.map +1 -1
  110. package/out/map/index.d.ts.map +1 -1
  111. package/out/map/index.js.map +1 -1
  112. package/out/map/place-render.d.ts +27 -9
  113. package/out/map/place-render.d.ts.map +1 -1
  114. package/out/map/place-render.js +9 -3
  115. package/out/map/place-render.js.map +1 -1
  116. package/out/map/types.d.ts +132 -44
  117. package/out/map/types.d.ts.map +1 -1
  118. package/out/map/useCompareState.d.ts +15 -5
  119. package/out/map/useCompareState.d.ts.map +1 -1
  120. package/out/map/useCompareState.js.map +1 -1
  121. package/out/map/useDemoGeocode.d.ts +12 -4
  122. package/out/map/useDemoGeocode.d.ts.map +1 -1
  123. package/out/map/useDemoGeocode.js.map +1 -1
  124. package/out/map/useMapPlaceRender.d.ts +3 -1
  125. package/out/map/useMapPlaceRender.d.ts.map +1 -1
  126. package/out/map/useMapPlaceRender.js +3 -1
  127. package/out/map/useMapPlaceRender.js.map +1 -1
  128. package/out/map/usePlaceAutocomplete.d.ts +45 -15
  129. package/out/map/usePlaceAutocomplete.d.ts.map +1 -1
  130. package/out/map/usePlaceAutocomplete.js +7 -3
  131. package/out/map/usePlaceAutocomplete.js.map +1 -1
  132. package/out/pipeline/ConfidenceCell.d.ts.map +1 -1
  133. package/out/pipeline/ConfidenceCell.js +9 -1
  134. package/out/pipeline/ConfidenceCell.js.map +1 -1
  135. package/out/pipeline/PipelineExplorer.d.ts +12 -4
  136. package/out/pipeline/PipelineExplorer.d.ts.map +1 -1
  137. package/out/pipeline/PipelineExplorer.js +6 -2
  138. package/out/pipeline/PipelineExplorer.js.map +1 -1
  139. package/out/pipeline/QueryForm.d.ts +6 -2
  140. package/out/pipeline/QueryForm.d.ts.map +1 -1
  141. package/out/pipeline/QueryForm.js +1 -1
  142. package/out/pipeline/QueryForm.js.map +1 -1
  143. package/out/pipeline/ResolvedPlace.js +1 -1
  144. package/out/pipeline/ResolvedPlace.js.map +1 -1
  145. package/out/pipeline/presets.d.ts +7 -0
  146. package/out/pipeline/presets.d.ts.map +1 -1
  147. package/out/pipeline/presets.js +7 -0
  148. package/out/pipeline/presets.js.map +1 -1
  149. package/out/pipeline/types.d.ts +60 -20
  150. package/out/pipeline/types.d.ts.map +1 -1
  151. package/out/pipeline/useParsePipeline.d.ts +12 -4
  152. package/out/pipeline/useParsePipeline.d.ts.map +1 -1
  153. package/out/pipeline/useParsePipeline.js +2 -2
  154. package/out/pipeline/useParsePipeline.js.map +1 -1
  155. package/out/poi/LiveResultsBlock.d.ts +6 -2
  156. package/out/poi/LiveResultsBlock.d.ts.map +1 -1
  157. package/out/poi/LiveResultsBlock.js +1 -1
  158. package/out/poi/LiveResultsBlock.js.map +1 -1
  159. package/out/poi/POIExplorer.d.ts +12 -4
  160. package/out/poi/POIExplorer.d.ts.map +1 -1
  161. package/out/poi/POIExplorer.js.map +1 -1
  162. package/out/poi/SubjectPanel.d.ts.map +1 -1
  163. package/out/poi/SubjectPanel.js +4 -2
  164. package/out/poi/SubjectPanel.js.map +1 -1
  165. package/out/poi/runtime.d.ts +9 -2
  166. package/out/poi/runtime.d.ts.map +1 -1
  167. package/out/poi/runtime.js +10 -3
  168. package/out/poi/runtime.js.map +1 -1
  169. package/out/poi/types.d.ts +40 -15
  170. package/out/poi/types.d.ts.map +1 -1
  171. package/out/poi/usePOISearch.d.ts +27 -9
  172. package/out/poi/usePOISearch.d.ts.map +1 -1
  173. package/out/poi/usePOISearch.js +5 -3
  174. package/out/poi/usePOISearch.js.map +1 -1
  175. package/out/runtime/useDemoRuntime.d.ts +81 -27
  176. package/out/runtime/useDemoRuntime.d.ts.map +1 -1
  177. package/out/runtime/useDemoRuntime.js.map +1 -1
  178. package/package.json +4 -4
  179. package/pipeline/ConfidenceCell.tsx +11 -1
  180. package/pipeline/PipelineExplorer.tsx +19 -6
  181. package/pipeline/QueryForm.tsx +7 -3
  182. package/pipeline/ResolvedPlace.tsx +2 -2
  183. package/pipeline/presets.ts +7 -0
  184. package/pipeline/types.ts +60 -20
  185. package/pipeline/useParsePipeline.ts +14 -6
  186. package/poi/LiveResultsBlock.tsx +7 -3
  187. package/poi/POIExplorer.tsx +14 -4
  188. package/poi/SubjectPanel.tsx +4 -2
  189. package/poi/runtime.ts +11 -3
  190. package/poi/types.ts +41 -15
  191. package/poi/usePOISearch.ts +34 -12
  192. package/runtime/useDemoRuntime.ts +82 -27
@@ -18,19 +18,31 @@ import { Layer, Source } from "react-map-gl/maplibre"
18
18
 
19
19
  import type { PlaceGeometry } from "./geometry.ts"
20
20
 
21
- /** The house pink, matched to {@link PlaceMarker}. */
21
+ /**
22
+ * The house pink, matched to {@link PlaceMarker}.
23
+ */
22
24
  const OUTLINE_COLOR = "#e0367c"
23
25
 
24
26
  export interface ResultOverlayProps {
25
- /** The outline geometry to draw, or `null` to draw nothing (the bare-point result). */
27
+ /**
28
+ * The outline geometry to draw, or `null` to draw nothing (the bare-point result).
29
+ */
26
30
  outline: PlaceGeometry | null
27
- /** Source/layer id prefix — override to render more than one outline on a map. @default "mw-result" */
31
+ /**
32
+ * Source/layer id prefix — override to render more than one outline on a map. @default "mw-result"
33
+ */
28
34
  id?: string
29
- /** Fill color. @default the house pink. */
35
+ /**
36
+ * Fill color. @default the house pink.
37
+ */
30
38
  color?: string
31
- /** Fill opacity. @default 0.12 */
39
+ /**
40
+ * Fill opacity. @default 0.12
41
+ */
32
42
  fillOpacity?: number
33
- /** Outline stroke width (px). @default 2 */
43
+ /**
44
+ * Outline stroke width (px). @default 2
45
+ */
34
46
  lineWidth?: number
35
47
  }
36
48
 
@@ -25,21 +25,35 @@ import { ResolvedPlace } from "../pipeline/ResolvedPlace.tsx"
25
25
  import type { ParseResult, ResolvedPlaceView } from "../pipeline/types.ts"
26
26
 
27
27
  export interface ResultPanelProps {
28
- /** The parse+resolve result to render. */
28
+ /**
29
+ * The parse+resolve result to render.
30
+ */
29
31
  result: ParseResult
30
- /** The selected candidate (falls back to the first), used for the resolved-place detail + copy payload. */
32
+ /**
33
+ * The selected candidate (falls back to the first), used for the resolved-place detail + copy payload.
34
+ */
31
35
  selectedCandidate: ResolvedPlaceView | null
32
- /** The selected candidate index, for the picker's active state. */
36
+ /**
37
+ * The selected candidate index, for the picker's active state.
38
+ */
33
39
  selectedCandidateIndex: number
34
- /** Fired when a candidate in the picker is chosen. */
40
+ /**
41
+ * Fired when a candidate in the picker is chosen.
42
+ */
35
43
  onSelectCandidate: (index: number) => void
36
- /** Host-injected heavy visualizers (span highlight, tree, timing, …), rendered from the result. */
44
+ /**
45
+ * Host-injected heavy visualizers (span highlight, tree, timing, …), rendered from the result.
46
+ */
37
47
  extras?: (result: ParseResult) => ReactNode
38
- /** Host-injected no-resolve diagnostic, rendered when nothing resolved. */
48
+ /**
49
+ * Host-injected no-resolve diagnostic, rendered when nothing resolved.
50
+ */
39
51
  failure?: (result: ParseResult) => ReactNode
40
52
  }
41
53
 
42
- /** The composed result block for the geocoder demo. */
54
+ /**
55
+ * The composed result block for the geocoder demo.
56
+ */
43
57
  export function ResultPanel({
44
58
  result,
45
59
  selectedCandidate,
@@ -17,19 +17,31 @@ import type { ReactNode } from "react"
17
17
  import type { DemoVersionOption } from "./types.ts"
18
18
 
19
19
  export interface VersionPickerProps {
20
- /** The selectable model bundles. */
20
+ /**
21
+ * The selectable model bundles.
22
+ */
21
23
  versions: ReadonlyArray<DemoVersionOption>
22
- /** The currently-selected version tag. */
24
+ /**
25
+ * The currently-selected version tag.
26
+ */
23
27
  selected: string | null
24
- /** Fired with the chosen version tag. */
28
+ /**
29
+ * Fired with the chosen version tag.
30
+ */
25
31
  onSelect: (version: string) => void
26
- /** Disable the control (e.g. while a parse is running). */
32
+ /**
33
+ * Disable the control (e.g. while a parse is running).
34
+ */
27
35
  disabled?: boolean
28
- /** Field label. @default "Model version" */
36
+ /**
37
+ * Field label. @default "Model version"
38
+ */
29
39
  label?: string
30
40
  }
31
41
 
32
- /** The model-version selector. Renders `null` when there is nothing meaningful to pick. */
42
+ /**
43
+ * The model-version selector. Renders `null` when there is nothing meaningful to pick.
44
+ */
33
45
  export function VersionPicker({
34
46
  versions,
35
47
  selected,
package/map/geometry.ts CHANGED
@@ -16,15 +16,26 @@
16
16
  * preserve it so the ported behavior is byte-identical and the browser graph stays clean.
17
17
  */
18
18
 
19
- /** Mean km per degree of latitude (WGS84 average). */
19
+ /**
20
+ * Segments used to approximate a circle as a polygon ring.
21
+ */
22
+ const CIRCLE_SEGMENTS = 64
23
+
24
+ /**
25
+ * Mean km per degree of latitude (WGS84 average).
26
+ */
20
27
  const KM_PER_DEG_LAT = 111.32
21
28
 
22
- /** A GeoJSON Polygon / MultiPolygon — what the polygon DB stores and the map draws as the place outline. */
29
+ /**
30
+ * A GeoJSON Polygon / MultiPolygon — what the polygon DB stores and the map draws as the place outline.
31
+ */
23
32
  export type PlaceGeometry =
24
33
  | { type: "Polygon"; coordinates: number[][][] }
25
34
  | { type: "MultiPolygon"; coordinates: number[][][][] }
26
35
 
27
- /** A place bounding box in the demo's object form (the WOF points DB carries only these four numbers). */
36
+ /**
37
+ * A place bounding box in the demo's object form (the WOF points DB carries only these four numbers).
38
+ */
28
39
  export interface PlaceBBox {
29
40
  minLat: number
30
41
  maxLat: number
@@ -32,20 +43,26 @@ export interface PlaceBBox {
32
43
  maxLon: number
33
44
  }
34
45
 
35
- /** A `[west, south, east, north]` → `[[minLon, minLat], [maxLon, maxLat]]` pair, the shape `fitBounds` wants. */
46
+ /**
47
+ * A `[west, south, east, north]` → `[[minLon, minLat], [maxLon, maxLat]]` pair, the shape `fitBounds` wants.
48
+ */
36
49
  export type BoundsTuple = [[number, number], [number, number]]
37
50
 
38
- /** Km per degree of longitude at a given latitude — the meridians converge toward the poles. */
51
+ /**
52
+ * Km per degree of longitude at a given latitude — the meridians converge toward the poles.
53
+ */
39
54
  function kmPerDegLon(lat: number): number {
40
55
  return KM_PER_DEG_LAT * Math.cos((lat * Math.PI) / 180)
41
56
  }
42
57
 
43
- /** A closed 64-segment (65-point) GeoJSON ring of `radiusKm` around `[lon, lat]`, with latitude correction. */
58
+ /**
59
+ * A closed 64-segment (65-point) GeoJSON ring of `radiusKm` around `[lon, lat]`, with latitude correction.
60
+ */
44
61
  function circleRing(lat: number, lon: number, radiusKm: number): number[][] {
45
62
  const perLon = kmPerDegLon(lat)
46
63
  const ring: number[][] = []
47
64
 
48
- for (let i = 0; i <= 64; i++) {
65
+ for (let i = 0; i <= CIRCLE_SEGMENTS; i++) {
49
66
  const theta = (2 * Math.PI * i) / 64
50
67
 
51
68
  ring.push([lon + (radiusKm * Math.cos(theta)) / perLon, lat + (radiusKm * Math.sin(theta)) / KM_PER_DEG_LAT])
@@ -63,6 +80,7 @@ export function approxCircleGeometry(lat: number, lon: number, bbox?: PlaceBBox)
63
80
  const halfDiagKm = bbox
64
81
  ? Math.hypot((bbox.maxLat - bbox.minLat) * KM_PER_DEG_LAT, (bbox.maxLon - bbox.minLon) * kmPerDegLon(lat)) / 2
65
82
  : 3
83
+
66
84
  const radiusKm = Math.min(50, Math.max(0.5, halfDiagKm))
67
85
 
68
86
  return { type: "Polygon", coordinates: [circleRing(lat, lon, radiusKm)] }
@@ -126,7 +144,9 @@ export function geomBounds(geometry: PlaceGeometry): PlaceBBox {
126
144
  return { minLon, minLat, maxLon, maxLat }
127
145
  }
128
146
 
129
- /** Reshape a {@link PlaceBBox} into the `[[minLon, minLat], [maxLon, maxLat]]` pair `fitBounds` expects. */
147
+ /**
148
+ * Reshape a {@link PlaceBBox} into the `[[minLon, minLat], [maxLon, maxLat]]` pair `fitBounds` expects.
149
+ */
130
150
  export function bboxToBounds(bbox: PlaceBBox): BoundsTuple {
131
151
  return [
132
152
  [bbox.minLon, bbox.minLat],
package/map/index.ts CHANGED
@@ -14,6 +14,7 @@
14
14
 
15
15
  export { DemoMap } from "./DemoMap.tsx"
16
16
  export type { DemoMapExtraProps, DemoMapProps, DemoMapStyle } from "./DemoMap.tsx"
17
+
17
18
  export type {
18
19
  DemoBackend,
19
20
  DemoCompareContext,
@@ -64,10 +65,12 @@ export type { UseCompareState } from "./useCompareState.ts"
64
65
  export { useDemoGeocode } from "./useDemoGeocode.ts"
65
66
  export type { UseDemoGeocode, UseDemoGeocodeOptions } from "./useDemoGeocode.ts"
66
67
  export { usePlaceAutocomplete } from "./usePlaceAutocomplete.ts"
68
+
67
69
  export type {
68
70
  AutocompleteInputProps,
69
71
  UsePlaceAutocomplete,
70
72
  UsePlaceAutocompleteOptions,
71
73
  } from "./usePlaceAutocomplete.ts"
74
+
72
75
  export { VersionPicker } from "./VersionPicker.tsx"
73
76
  export type { VersionPickerProps } from "./VersionPicker.tsx"
@@ -23,10 +23,14 @@ import type { ResolvedPlaceView } from "../pipeline/types.ts"
23
23
  import { approxCircleGeometry, bboxToBounds, geomBounds, radiusCircleGeometry } from "./geometry.ts"
24
24
  import type { BoundsTuple, PlaceBBox, PlaceGeometry } from "./geometry.ts"
25
25
 
26
- /** `[longitude, latitude]`. */
26
+ /**
27
+ * `[longitude, latitude]`.
28
+ */
27
29
  export type LngLat = [number, number]
28
30
 
29
- /** The street-level resolution tier (#377): `address_point` = exact building; `interpolated` = TIGER estimate. */
31
+ /**
32
+ * The street-level resolution tier (#377): `address_point` = exact building; `interpolated` = TIGER estimate.
33
+ */
30
34
  export type PlaceTier = "address_point" | "interpolated"
31
35
 
32
36
  /**
@@ -35,11 +39,17 @@ export type PlaceTier = "address_point" | "interpolated"
35
39
  * `ResolvedPlaceView` keeps the map render aligned with the shared parse result; the extras are additive.
36
40
  */
37
41
  export interface ResolvedMapPlace extends ResolvedPlaceView {
38
- /** The place's bounding box, when the gazetteer carries one (admin places). Absent for anchor-centroid postcodes. */
42
+ /**
43
+ * The place's bounding box, when the gazetteer carries one (admin places). Absent for anchor-centroid postcodes.
44
+ */
39
45
  bbox?: PlaceBBox
40
- /** Street-level tier, when this hit came from the situs/interp tier rather than the WOF admin cascade. */
46
+ /**
47
+ * Street-level tier, when this hit came from the situs/interp tier rather than the WOF admin cascade.
48
+ */
41
49
  tier?: PlaceTier
42
- /** Honest uncertainty radius in meters for a street-level tier (10 m situs floor; calibrated interp). */
50
+ /**
51
+ * Honest uncertainty radius in meters for a street-level tier (10 m situs floor; calibrated interp).
52
+ */
43
53
  uncertaintyM?: number
44
54
  /**
45
55
  * The crisp admin polygon, when the host has ALREADY fetched it from the sibling polygon DB. Its presence drives the
@@ -57,17 +67,27 @@ export type MapCameraTarget =
57
67
  | { kind: "center"; center: LngLat; zoom: number }
58
68
  | { kind: "bounds"; bounds: BoundsTuple; padding: number }
59
69
 
60
- /** The declarative render spec for one resolved place — the pure output of {@link computeMapPlaceRenderSpec}. */
70
+ /**
71
+ * The declarative render spec for one resolved place — the pure output of {@link computeMapPlaceRenderSpec}.
72
+ */
61
73
  export interface MapPlaceRenderSpec {
62
- /** Marker position(s) as `[lon, lat]`. Single-element today; an array leaves room for multi-marker later. */
74
+ /**
75
+ * Marker position(s) as `[lon, lat]`. Single-element today; an array leaves room for multi-marker later.
76
+ */
63
77
  markers: LngLat[]
64
- /** The outline geometry (polygon / circle) to draw, or `null` when the place renders as a bare point. */
78
+ /**
79
+ * The outline geometry (polygon / circle) to draw, or `null` when the place renders as a bare point.
80
+ */
65
81
  outline: PlaceGeometry | null
66
- /** The camera target — animate or fit to this. */
82
+ /**
83
+ * The camera target — animate or fit to this.
84
+ */
67
85
  camera: MapCameraTarget
68
86
  }
69
87
 
70
- /** Zoom levels the imperative effect flew to, kept named so the cascade reads as intent, not magic numbers. */
88
+ /**
89
+ * Zoom levels the imperative effect flew to, kept named so the cascade reads as intent, not magic numbers.
90
+ */
71
91
  const ZOOM = {
72
92
  addressPoint: 17,
73
93
  interpolated: 15,
@@ -75,10 +95,14 @@ const ZOOM = {
75
95
  point: 12,
76
96
  } as const
77
97
 
78
- /** Padding (px) `fitBounds` insets a fitted box by, matching the ported effect. */
98
+ /**
99
+ * Padding (px) `fitBounds` insets a fitted box by, matching the ported effect.
100
+ */
79
101
  const FIT_PADDING = 40
80
102
 
81
- /** The minimum lat/lon span (degrees) a bbox must exceed to be treated as a real extent rather than a point. */
103
+ /**
104
+ * The minimum lat/lon span (degrees) a bbox must exceed to be treated as a real extent rather than a point.
105
+ */
82
106
  const MIN_EXTENT_DEG = 0.001
83
107
 
84
108
  /**
package/map/types.ts CHANGED
@@ -22,14 +22,22 @@ import type { ParseResult, PipelineRuntime, ResolvedPlaceView } from "../pipelin
22
22
  import type { DemoMapStyle } from "./DemoMap.tsx"
23
23
  import type { ResolvedMapPlace } from "./place-render.ts"
24
24
 
25
- /** `[longitude, latitude]`. */
25
+ /**
26
+ * `[longitude, latitude]`.
27
+ */
26
28
  export type LngLatTuple = [number, number]
27
29
 
28
- /** A viewport bias handed to `runParse` — the map's current center (and optionally zoom) as a soft prior. */
30
+ /**
31
+ * A viewport bias handed to `runParse` — the map's current center (and optionally zoom) as a soft prior.
32
+ */
29
33
  export interface MapBias {
30
- /** Map center as `[lon, lat]`, typically read from `map.getCenter()`. */
34
+ /**
35
+ * Map center as `[lon, lat]`, typically read from `map.getCenter()`.
36
+ */
31
37
  center: LngLatTuple
32
- /** Current zoom, if the host wants distance-aware biasing. */
38
+ /**
39
+ * Current zoom, if the host wants distance-aware biasing.
40
+ */
33
41
  zoom?: number
34
42
  }
35
43
 
@@ -38,37 +46,63 @@ export interface MapBias {
38
46
  * race-dots, …). The host composes the specs; the package renders them declaratively in a later phase.
39
47
  */
40
48
  export interface OverlaySpec {
41
- /** Stable id — used as the `<Source>` id and the layer-id prefix. */
49
+ /**
50
+ * Stable id — used as the `<Source>` id and the layer-id prefix.
51
+ */
42
52
  id: string
43
- /** The map source spec (vector/geojson/raster). */
53
+ /**
54
+ * The map source spec (vector/geojson/raster).
55
+ */
44
56
  source: SourceSpecification
45
- /** The layers drawn from that source. */
57
+ /**
58
+ * The layers drawn from that source.
59
+ */
46
60
  layers: LayerSpecification[]
47
- /** Whether the overlay is visible initially. @default true */
61
+ /**
62
+ * Whether the overlay is visible initially. @default true
63
+ */
48
64
  visible?: boolean
49
- /** Human label for a layer-toggle control. */
65
+ /**
66
+ * Human label for a layer-toggle control.
67
+ */
50
68
  label?: string
51
69
  }
52
70
 
53
- /** One autocomplete suggestion produced by the host's FST prefix-walk. */
71
+ /**
72
+ * One autocomplete suggestion produced by the host's FST prefix-walk.
73
+ */
54
74
  export interface Suggestion {
55
- /** The text inserted when the suggestion is picked. */
75
+ /**
76
+ * The text inserted when the suggestion is picked.
77
+ */
56
78
  value: string
57
- /** Optional display label if it differs from `value`. */
79
+ /**
80
+ * Optional display label if it differs from `value`.
81
+ */
58
82
  label?: string
59
- /** Optional place kind for badge/icon rendering. */
83
+ /**
84
+ * Optional place kind for badge/icon rendering.
85
+ */
60
86
  placetype?: string
61
87
  }
62
88
 
63
- /** A selectable model bundle (version tag + a display label the picker shows). */
89
+ /**
90
+ * A selectable model bundle (version tag + a display label the picker shows).
91
+ */
64
92
  export interface DemoVersionOption {
65
- /** The version tag (e.g. a git tag or model-card version). */
93
+ /**
94
+ * The version tag (e.g. a git tag or model-card version).
95
+ */
66
96
  version: string
67
- /** Display label; falls back to `version`. */
97
+ /**
98
+ * Display label; falls back to `version`.
99
+ */
68
100
  label?: string
69
101
  }
70
102
 
71
- /** Which neural backend the demo is currently running on. */
103
+ /**
104
+ * Which neural backend the demo is currently running on.
105
+ */
72
106
  export type DemoBackend = "webgpu" | "wasm"
73
107
 
74
108
  /**
@@ -80,13 +114,21 @@ export type DemoBackend = "webgpu" | "wasm"
80
114
  */
81
115
  export interface DemoRuntime extends PipelineRuntime {
82
116
  // ── Map ────────────────────────────────────────────────────────────────
83
- /** The composed basemap style (URL or `StyleSpecification`). */
117
+ /**
118
+ * The composed basemap style (URL or `StyleSpecification`).
119
+ */
84
120
  mapStyle: DemoMapStyle
85
- /** Host-supplied overlays (coverage, race-dots, …). */
121
+ /**
122
+ * Host-supplied overlays (coverage, race-dots, …).
123
+ */
86
124
  overlays?: OverlaySpec[]
87
- /** Initial map center as `[lon, lat]` (the host's browser-geolocation result). */
125
+ /**
126
+ * Initial map center as `[lon, lat]` (the host's browser-geolocation result).
127
+ */
88
128
  initialCenter: LngLatTuple
89
- /** Initial zoom for the first camera. */
129
+ /**
130
+ * Initial zoom for the first camera.
131
+ */
90
132
  initialZoom?: number
91
133
 
92
134
  // ── Parse extras layered over PipelineRuntime.runParse ──────────────────
@@ -99,9 +141,13 @@ export interface DemoRuntime extends PipelineRuntime {
99
141
  bias: MapBias | null,
100
142
  hooks: { onStage: (stage: number) => void }
101
143
  ) => ReturnType<PipelineRuntime["runParse"]>
102
- /** FST prefix-walk autocomplete, wrapped by the host. */
144
+ /**
145
+ * FST prefix-walk autocomplete, wrapped by the host.
146
+ */
103
147
  autocomplete?: (query: string) => Promise<Suggestion[]>
104
- /** Maps a raw model score to a calibrated one; `null` when no calibration table is loaded. */
148
+ /**
149
+ * Maps a raw model score to a calibrated one; `null` when no calibration table is loaded.
150
+ */
105
151
  calibrator?: (raw: number) => number | null
106
152
  /**
107
153
  * Enrich the selected candidate into the richer {@link ResolvedMapPlace} the declarative map render consumes (bbox,
@@ -113,27 +159,47 @@ export interface DemoRuntime extends PipelineRuntime {
113
159
  resolveMapPlace?: (candidate: ResolvedPlaceView, result: ParseResult) => ResolvedMapPlace | null
114
160
 
115
161
  // ── Version + backend selection ─────────────────────────────────────────
116
- /** The selectable model bundles the version picker offers. */
162
+ /**
163
+ * The selectable model bundles the version picker offers.
164
+ */
117
165
  availableVersions?: DemoVersionOption[]
118
- /** The currently-selected model version. */
166
+ /**
167
+ * The currently-selected model version.
168
+ */
119
169
  selectedVersion?: string
120
- /** Switch the active model bundle (re-loads weights/tokenizer/gazetteer). */
170
+ /**
171
+ * Switch the active model bundle (re-loads weights/tokenizer/gazetteer).
172
+ */
121
173
  selectVersion?: (version: string) => void
122
- /** The backend the neural runtime resolved to (e.g. `webgpu (28 MB int8)`); free-form for the label. */
174
+ /**
175
+ * The backend the neural runtime resolved to (e.g. `webgpu (28 MB int8)`); free-form for the label.
176
+ */
123
177
  activeBackend?: string
124
- /** Whether the CPU/WASM backend is currently forced (the controlled value for the backend toggle). */
178
+ /**
179
+ * Whether the CPU/WASM backend is currently forced (the controlled value for the backend toggle).
180
+ */
125
181
  forceWASM?: boolean
126
- /** Force the WASM backend (opt out of WebGPU), for the backend toggle. */
182
+ /**
183
+ * Force the WASM backend (opt out of WebGPU), for the backend toggle.
184
+ */
127
185
  setForceWASM?: (forceWASM: boolean) => void
128
186
  }
129
187
 
130
- /** The compare-mode state a {@link DemoPanels.compare} render-prop receives (the second parse itself stays host-side). */
188
+ /**
189
+ * The compare-mode state a {@link DemoPanels.compare} render-prop receives (the second parse itself stays host-side).
190
+ */
131
191
  export interface DemoCompareContext {
132
- /** The current primary parse result, or `null` before the first submit. */
192
+ /**
193
+ * The current primary parse result, or `null` before the first submit.
194
+ */
133
195
  result: ParseResult | null
134
- /** Whether the compare toggle is on. */
196
+ /**
197
+ * Whether the compare toggle is on.
198
+ */
135
199
  compareMode: boolean
136
- /** The version selected to compare against, or `null` when none is chosen. */
200
+ /**
201
+ * The version selected to compare against, or `null` when none is chosen.
202
+ */
137
203
  compareVersion: string | null
138
204
  }
139
205
 
@@ -144,13 +210,21 @@ export interface DemoCompareContext {
144
210
  * by the package (`useDemoGeocode`).
145
211
  */
146
212
  export interface DemoResultContext {
147
- /** The current parse+resolve result. */
213
+ /**
214
+ * The current parse+resolve result.
215
+ */
148
216
  result: ParseResult
149
- /** The selected candidate (falls back to the first), enriched for the resolved-place detail. */
217
+ /**
218
+ * The selected candidate (falls back to the first), enriched for the resolved-place detail.
219
+ */
150
220
  selectedCandidate: ResolvedPlaceView | null
151
- /** The selected candidate index, for the picker's active state. */
221
+ /**
222
+ * The selected candidate index, for the picker's active state.
223
+ */
152
224
  selectedCandidateIndex: number
153
- /** Fired when a candidate in the picker is chosen. */
225
+ /**
226
+ * Fired when a candidate in the picker is chosen.
227
+ */
154
228
  onSelectCandidate: (index: number) => void
155
229
  }
156
230
 
@@ -161,11 +235,17 @@ export interface DemoResultContext {
161
235
  * fake-runtime Storybook stories pass none and still render the whole demo.
162
236
  */
163
237
  export interface DemoPanels {
164
- /** Rendered at the top of the control panel (e.g. the docs "About this demo"). */
238
+ /**
239
+ * Rendered at the top of the control panel (e.g. the docs "About this demo").
240
+ */
165
241
  header?: ReactNode
166
- /** One-line release blurb for the selected version. */
242
+ /**
243
+ * One-line release blurb for the selected version.
244
+ */
167
245
  releaseInfo?: ReactNode
168
- /** Rendered at the bottom of the control panel (e.g. a guided tour). */
246
+ /**
247
+ * Rendered at the bottom of the control panel (e.g. a guided tour).
248
+ */
169
249
  footer?: ReactNode
170
250
  /**
171
251
  * A device-location / proximity-bias control, rendered between the query form and the autocomplete list (the demo's
@@ -173,7 +253,9 @@ export interface DemoPanels {
173
253
  * {@link DemoRuntime.runParseWithBias} stay a host concern.
174
254
  */
175
255
  bias?: ReactNode
176
- /** Heavy visualizers (span highlight, tree, timing, BIO, …), rendered from the result. */
256
+ /**
257
+ * Heavy visualizers (span highlight, tree, timing, BIO, …), rendered from the result.
258
+ */
177
259
  extras?: (result: ParseResult) => ReactNode
178
260
  /**
179
261
  * Rendered just above the result block (present or empty). The demo's opt-in display toggles live here — calibrated
@@ -192,7 +274,9 @@ export interface DemoPanels {
192
274
  * {@link result} is set.
193
275
  */
194
276
  failure?: (result: ParseResult) => ReactNode
195
- /** The version-compare view — the host renders its own diff from the compare state it owns. */
277
+ /**
278
+ * The version-compare view — the host renders its own diff from the compare state it owns.
279
+ */
196
280
  compare?: (context: DemoCompareContext) => ReactNode
197
281
  /**
198
282
  * The model-visualizer / debug drawer, mounted beside the map (host's ModelVisualizer). A render-prop so the host can
@@ -200,8 +284,12 @@ export interface DemoPanels {
200
284
  * state and returns `null` when the drawer is closed.
201
285
  */
202
286
  debugDrawer?: (context: { result: ParseResult | null }) => ReactNode
203
- /** Extra map controls mounted as `<DemoMap>` children (host's DebugControl / LayerToggle via `useControl`). */
287
+ /**
288
+ * Extra map controls mounted as `<DemoMap>` children (host's DebugControl / LayerToggle via `useControl`).
289
+ */
204
290
  mapControls?: ReactNode
205
- /** A permalink control for the current address (host's PermalinkButton). */
291
+ /**
292
+ * A permalink control for the current address (host's PermalinkButton).
293
+ */
206
294
  permalink?: (text: string) => ReactNode
207
295
  }
@@ -13,15 +13,25 @@
13
13
  import { useCallback, useState } from "react"
14
14
 
15
15
  export interface UseCompareState {
16
- /** Whether compare mode is on. */
16
+ /**
17
+ * Whether compare mode is on.
18
+ */
17
19
  compareMode: boolean
18
- /** The version chosen to compare against, or `null`. */
20
+ /**
21
+ * The version chosen to compare against, or `null`.
22
+ */
19
23
  compareVersion: string | null
20
- /** Flip compare mode; turning it off clears the chosen version. */
24
+ /**
25
+ * Flip compare mode; turning it off clears the chosen version.
26
+ */
21
27
  setCompareMode: (compareMode: boolean) => void
22
- /** Choose a compare version (`null` clears it). */
28
+ /**
29
+ * Choose a compare version (`null` clears it).
30
+ */
23
31
  setCompareVersion: (version: string | null) => void
24
- /** Keep the compare selection distinct from the primary — call when the primary version changes. */
32
+ /**
33
+ * Keep the compare selection distinct from the primary — call when the primary version changes.
34
+ */
25
35
  clearIfPrimary: (primaryVersion: string) => void
26
36
  }
27
37
 
@@ -26,16 +26,24 @@ import type { ResolvedMapPlace } from "./place-render.ts"
26
26
  import type { DemoRuntime, MapBias } from "./types.ts"
27
27
 
28
28
  export interface UseDemoGeocodeOptions {
29
- /** The injected demo runtime (extends `PipelineRuntime` with the map + bias surface). */
29
+ /**
30
+ * The injected demo runtime (extends `PipelineRuntime` with the map + bias surface).
31
+ */
30
32
  runtime: DemoRuntime
31
- /** Address to pre-fill. */
33
+ /**
34
+ * Address to pre-fill.
35
+ */
32
36
  defaultText: string
33
- /** Read the current viewport bias (the map center) at submit time. Absent → no bias. */
37
+ /**
38
+ * Read the current viewport bias (the map center) at submit time. Absent → no bias.
39
+ */
34
40
  getBias?: () => MapBias | null
35
41
  }
36
42
 
37
43
  export interface UseDemoGeocode extends UseParsePipeline {
38
- /** The selected candidate enriched into the map-render shape (bbox / tier / polygon), or `null`. */
44
+ /**
45
+ * The selected candidate enriched into the map-render shape (bbox / tier / polygon), or `null`.
46
+ */
39
47
  mapPlace: ResolvedMapPlace | null
40
48
  }
41
49
 
@@ -15,7 +15,9 @@ import { useMemo } from "react"
15
15
  import { computeMapPlaceRenderSpec } from "./place-render.ts"
16
16
  import type { MapPlaceRenderSpec, ResolvedMapPlace } from "./place-render.ts"
17
17
 
18
- /** Memoize the render spec for a resolved place; `null` in → `null` out (nothing to draw). */
18
+ /**
19
+ * Memoize the render spec for a resolved place; `null` in → `null` out (nothing to draw).
20
+ */
19
21
  export function useMapPlaceRender(place: ResolvedMapPlace | null | undefined): MapPlaceRenderSpec | null {
20
22
  return useMemo(() => (place ? computeMapPlaceRenderSpec(place) : null), [place])
21
23
  }