@mailwoman/react 8.0.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.
- package/common/ClientOnly.tsx +6 -2
- package/common/CopyButton.tsx +9 -3
- package/common/KindBadge.tsx +1 -1
- package/common/LoadingIndicator.tsx +22 -7
- package/common/PresetChips.tsx +6 -2
- package/common/cx.ts +3 -1
- package/common/useClipboard.ts +7 -2
- package/index.ts +5 -0
- package/map/BackendControl.tsx +12 -4
- package/map/CompareToggle.tsx +27 -9
- package/map/DemoControls.tsx +31 -11
- package/map/DemoMap.tsx +33 -11
- package/map/GeocoderDemo.tsx +25 -8
- package/map/OverlayLayers.tsx +7 -3
- package/map/PlaceAutocomplete.tsx +25 -9
- package/map/PlaceMarker.tsx +18 -6
- package/map/ResolvedPlaceLayers.tsx +15 -5
- package/map/ResultCamera.tsx +6 -2
- package/map/ResultOverlay.tsx +18 -6
- package/map/ResultPanel.tsx +21 -7
- package/map/VersionPicker.tsx +18 -6
- package/map/geometry.ts +28 -8
- package/map/index.ts +3 -0
- package/map/place-render.ts +36 -12
- package/map/types.ts +132 -44
- package/map/useCompareState.ts +15 -5
- package/map/useDemoGeocode.ts +12 -4
- package/map/useMapPlaceRender.ts +3 -1
- package/map/usePlaceAutocomplete.ts +52 -18
- package/out/common/ClientOnly.d.ts +6 -2
- package/out/common/ClientOnly.d.ts.map +1 -1
- package/out/common/ClientOnly.js.map +1 -1
- package/out/common/CopyButton.d.ts +9 -3
- package/out/common/CopyButton.d.ts.map +1 -1
- package/out/common/CopyButton.js.map +1 -1
- package/out/common/KindBadge.js +1 -1
- package/out/common/KindBadge.js.map +1 -1
- package/out/common/LoadingIndicator.d.ts +21 -6
- package/out/common/LoadingIndicator.d.ts.map +1 -1
- package/out/common/LoadingIndicator.js +4 -1
- package/out/common/LoadingIndicator.js.map +1 -1
- package/out/common/PresetChips.d.ts +6 -2
- package/out/common/PresetChips.d.ts.map +1 -1
- package/out/common/PresetChips.js.map +1 -1
- package/out/common/cx.d.ts +3 -1
- package/out/common/cx.d.ts.map +1 -1
- package/out/common/cx.js +3 -1
- package/out/common/cx.js.map +1 -1
- package/out/common/useClipboard.d.ts +3 -1
- package/out/common/useClipboard.d.ts.map +1 -1
- package/out/common/useClipboard.js +6 -2
- package/out/common/useClipboard.js.map +1 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js.map +1 -1
- package/out/map/BackendControl.d.ts +12 -4
- package/out/map/BackendControl.d.ts.map +1 -1
- package/out/map/BackendControl.js +3 -1
- package/out/map/BackendControl.js.map +1 -1
- package/out/map/CompareToggle.d.ts +27 -9
- package/out/map/CompareToggle.d.ts.map +1 -1
- package/out/map/CompareToggle.js +3 -1
- package/out/map/CompareToggle.js.map +1 -1
- package/out/map/DemoControls.d.ts +30 -10
- package/out/map/DemoControls.d.ts.map +1 -1
- package/out/map/DemoControls.js +4 -2
- package/out/map/DemoControls.js.map +1 -1
- package/out/map/DemoMap.d.ts +33 -11
- package/out/map/DemoMap.d.ts.map +1 -1
- package/out/map/DemoMap.js.map +1 -1
- package/out/map/GeocoderDemo.d.ts +16 -6
- package/out/map/GeocoderDemo.d.ts.map +1 -1
- package/out/map/GeocoderDemo.js +9 -3
- package/out/map/GeocoderDemo.js.map +1 -1
- package/out/map/OverlayLayers.d.ts +6 -2
- package/out/map/OverlayLayers.d.ts.map +1 -1
- package/out/map/OverlayLayers.js +4 -2
- package/out/map/OverlayLayers.js.map +1 -1
- package/out/map/PlaceAutocomplete.d.ts +24 -8
- package/out/map/PlaceAutocomplete.d.ts.map +1 -1
- package/out/map/PlaceAutocomplete.js +4 -2
- package/out/map/PlaceAutocomplete.js.map +1 -1
- package/out/map/PlaceMarker.d.ts +15 -5
- package/out/map/PlaceMarker.d.ts.map +1 -1
- package/out/map/PlaceMarker.js +6 -2
- package/out/map/PlaceMarker.js.map +1 -1
- package/out/map/ResolvedPlaceLayers.d.ts +15 -5
- package/out/map/ResolvedPlaceLayers.d.ts.map +1 -1
- package/out/map/ResolvedPlaceLayers.js +3 -1
- package/out/map/ResolvedPlaceLayers.js.map +1 -1
- package/out/map/ResultCamera.d.ts +6 -2
- package/out/map/ResultCamera.d.ts.map +1 -1
- package/out/map/ResultCamera.js +3 -1
- package/out/map/ResultCamera.js.map +1 -1
- package/out/map/ResultOverlay.d.ts +15 -5
- package/out/map/ResultOverlay.d.ts.map +1 -1
- package/out/map/ResultOverlay.js +3 -1
- package/out/map/ResultOverlay.js.map +1 -1
- package/out/map/ResultPanel.d.ts +21 -7
- package/out/map/ResultPanel.d.ts.map +1 -1
- package/out/map/ResultPanel.js +3 -1
- package/out/map/ResultPanel.js.map +1 -1
- package/out/map/VersionPicker.d.ts +18 -6
- package/out/map/VersionPicker.d.ts.map +1 -1
- package/out/map/VersionPicker.js +3 -1
- package/out/map/VersionPicker.js.map +1 -1
- package/out/map/geometry.d.ts +12 -4
- package/out/map/geometry.d.ts.map +1 -1
- package/out/map/geometry.js +17 -5
- package/out/map/geometry.js.map +1 -1
- package/out/map/index.d.ts.map +1 -1
- package/out/map/index.js.map +1 -1
- package/out/map/place-render.d.ts +27 -9
- package/out/map/place-render.d.ts.map +1 -1
- package/out/map/place-render.js +9 -3
- package/out/map/place-render.js.map +1 -1
- package/out/map/types.d.ts +132 -44
- package/out/map/types.d.ts.map +1 -1
- package/out/map/useCompareState.d.ts +15 -5
- package/out/map/useCompareState.d.ts.map +1 -1
- package/out/map/useCompareState.js.map +1 -1
- package/out/map/useDemoGeocode.d.ts +12 -4
- package/out/map/useDemoGeocode.d.ts.map +1 -1
- package/out/map/useDemoGeocode.js.map +1 -1
- package/out/map/useMapPlaceRender.d.ts +3 -1
- package/out/map/useMapPlaceRender.d.ts.map +1 -1
- package/out/map/useMapPlaceRender.js +3 -1
- package/out/map/useMapPlaceRender.js.map +1 -1
- package/out/map/usePlaceAutocomplete.d.ts +45 -15
- package/out/map/usePlaceAutocomplete.d.ts.map +1 -1
- package/out/map/usePlaceAutocomplete.js +7 -3
- package/out/map/usePlaceAutocomplete.js.map +1 -1
- package/out/pipeline/ConfidenceCell.d.ts.map +1 -1
- package/out/pipeline/ConfidenceCell.js +9 -1
- package/out/pipeline/ConfidenceCell.js.map +1 -1
- package/out/pipeline/PipelineExplorer.d.ts +12 -4
- package/out/pipeline/PipelineExplorer.d.ts.map +1 -1
- package/out/pipeline/PipelineExplorer.js +6 -2
- package/out/pipeline/PipelineExplorer.js.map +1 -1
- package/out/pipeline/QueryForm.d.ts +6 -2
- package/out/pipeline/QueryForm.d.ts.map +1 -1
- package/out/pipeline/QueryForm.js +1 -1
- package/out/pipeline/QueryForm.js.map +1 -1
- package/out/pipeline/ResolvedPlace.js +1 -1
- package/out/pipeline/ResolvedPlace.js.map +1 -1
- package/out/pipeline/presets.d.ts +7 -0
- package/out/pipeline/presets.d.ts.map +1 -1
- package/out/pipeline/presets.js +7 -0
- package/out/pipeline/presets.js.map +1 -1
- package/out/pipeline/types.d.ts +60 -20
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/pipeline/useParsePipeline.d.ts +12 -4
- package/out/pipeline/useParsePipeline.d.ts.map +1 -1
- package/out/pipeline/useParsePipeline.js +2 -2
- package/out/pipeline/useParsePipeline.js.map +1 -1
- package/out/poi/LiveResultsBlock.d.ts +6 -2
- package/out/poi/LiveResultsBlock.d.ts.map +1 -1
- package/out/poi/LiveResultsBlock.js +1 -1
- package/out/poi/LiveResultsBlock.js.map +1 -1
- package/out/poi/POIExplorer.d.ts +12 -4
- package/out/poi/POIExplorer.d.ts.map +1 -1
- package/out/poi/POIExplorer.js.map +1 -1
- package/out/poi/SubjectPanel.d.ts.map +1 -1
- package/out/poi/SubjectPanel.js +4 -2
- package/out/poi/SubjectPanel.js.map +1 -1
- package/out/poi/runtime.d.ts +9 -2
- package/out/poi/runtime.d.ts.map +1 -1
- package/out/poi/runtime.js +10 -3
- package/out/poi/runtime.js.map +1 -1
- package/out/poi/types.d.ts +40 -15
- package/out/poi/types.d.ts.map +1 -1
- package/out/poi/usePOISearch.d.ts +27 -9
- package/out/poi/usePOISearch.d.ts.map +1 -1
- package/out/poi/usePOISearch.js +5 -3
- package/out/poi/usePOISearch.js.map +1 -1
- package/out/runtime/useDemoRuntime.d.ts +81 -27
- package/out/runtime/useDemoRuntime.d.ts.map +1 -1
- package/out/runtime/useDemoRuntime.js.map +1 -1
- package/package.json +4 -4
- package/pipeline/ConfidenceCell.tsx +11 -1
- package/pipeline/PipelineExplorer.tsx +19 -6
- package/pipeline/QueryForm.tsx +7 -3
- package/pipeline/ResolvedPlace.tsx +2 -2
- package/pipeline/presets.ts +7 -0
- package/pipeline/types.ts +60 -20
- package/pipeline/useParsePipeline.ts +14 -6
- package/poi/LiveResultsBlock.tsx +7 -3
- package/poi/POIExplorer.tsx +14 -4
- package/poi/SubjectPanel.tsx +4 -2
- package/poi/runtime.ts +11 -3
- package/poi/types.ts +41 -15
- package/poi/usePOISearch.ts +34 -12
- package/runtime/useDemoRuntime.ts +82 -27
package/map/ResultOverlay.tsx
CHANGED
|
@@ -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
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* The house pink, matched to {@link PlaceMarker}.
|
|
23
|
+
*/
|
|
22
24
|
const OUTLINE_COLOR = "#e0367c"
|
|
23
25
|
|
|
24
26
|
export interface ResultOverlayProps {
|
|
25
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* The outline geometry to draw, or `null` to draw nothing (the bare-point result).
|
|
29
|
+
*/
|
|
26
30
|
outline: PlaceGeometry | null
|
|
27
|
-
/**
|
|
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
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Fill color. @default the house pink.
|
|
37
|
+
*/
|
|
30
38
|
color?: string
|
|
31
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Fill opacity. @default 0.12
|
|
41
|
+
*/
|
|
32
42
|
fillOpacity?: number
|
|
33
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Outline stroke width (px). @default 2
|
|
45
|
+
*/
|
|
34
46
|
lineWidth?: number
|
|
35
47
|
}
|
|
36
48
|
|
package/map/ResultPanel.tsx
CHANGED
|
@@ -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
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* The parse+resolve result to render.
|
|
30
|
+
*/
|
|
29
31
|
result: ParseResult
|
|
30
|
-
/**
|
|
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
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* The selected candidate index, for the picker's active state.
|
|
38
|
+
*/
|
|
33
39
|
selectedCandidateIndex: number
|
|
34
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Fired when a candidate in the picker is chosen.
|
|
42
|
+
*/
|
|
35
43
|
onSelectCandidate: (index: number) => void
|
|
36
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Host-injected heavy visualizers (span highlight, tree, timing, …), rendered from the result.
|
|
46
|
+
*/
|
|
37
47
|
extras?: (result: ParseResult) => ReactNode
|
|
38
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Host-injected no-resolve diagnostic, rendered when nothing resolved.
|
|
50
|
+
*/
|
|
39
51
|
failure?: (result: ParseResult) => ReactNode
|
|
40
52
|
}
|
|
41
53
|
|
|
42
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* The composed result block for the geocoder demo.
|
|
56
|
+
*/
|
|
43
57
|
export function ResultPanel({
|
|
44
58
|
result,
|
|
45
59
|
selectedCandidate,
|
package/map/VersionPicker.tsx
CHANGED
|
@@ -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
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* The selectable model bundles.
|
|
22
|
+
*/
|
|
21
23
|
versions: ReadonlyArray<DemoVersionOption>
|
|
22
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* The currently-selected version tag.
|
|
26
|
+
*/
|
|
23
27
|
selected: string | null
|
|
24
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Fired with the chosen version tag.
|
|
30
|
+
*/
|
|
25
31
|
onSelect: (version: string) => void
|
|
26
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Disable the control (e.g. while a parse is running).
|
|
34
|
+
*/
|
|
27
35
|
disabled?: boolean
|
|
28
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Field label. @default "Model version"
|
|
38
|
+
*/
|
|
29
39
|
label?: string
|
|
30
40
|
}
|
|
31
41
|
|
|
32
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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 <=
|
|
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
|
-
/**
|
|
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"
|
package/map/place-render.ts
CHANGED
|
@@ -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
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* `[longitude, latitude]`.
|
|
28
|
+
*/
|
|
27
29
|
export type LngLat = [number, number]
|
|
28
30
|
|
|
29
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* The declarative render spec for one resolved place — the pure output of {@link computeMapPlaceRenderSpec}.
|
|
72
|
+
*/
|
|
61
73
|
export interface MapPlaceRenderSpec {
|
|
62
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* The camera target — animate or fit to this.
|
|
84
|
+
*/
|
|
67
85
|
camera: MapCameraTarget
|
|
68
86
|
}
|
|
69
87
|
|
|
70
|
-
/**
|
|
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
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Padding (px) `fitBounds` insets a fitted box by, matching the ported effect.
|
|
100
|
+
*/
|
|
79
101
|
const FIT_PADDING = 40
|
|
80
102
|
|
|
81
|
-
/**
|
|
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
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* `[longitude, latitude]`.
|
|
27
|
+
*/
|
|
26
28
|
export type LngLatTuple = [number, number]
|
|
27
29
|
|
|
28
|
-
/**
|
|
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
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Map center as `[lon, lat]`, typically read from `map.getCenter()`.
|
|
36
|
+
*/
|
|
31
37
|
center: LngLatTuple
|
|
32
|
-
/**
|
|
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
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Stable id — used as the `<Source>` id and the layer-id prefix.
|
|
51
|
+
*/
|
|
42
52
|
id: string
|
|
43
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* The map source spec (vector/geojson/raster).
|
|
55
|
+
*/
|
|
44
56
|
source: SourceSpecification
|
|
45
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* The layers drawn from that source.
|
|
59
|
+
*/
|
|
46
60
|
layers: LayerSpecification[]
|
|
47
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Whether the overlay is visible initially. @default true
|
|
63
|
+
*/
|
|
48
64
|
visible?: boolean
|
|
49
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Human label for a layer-toggle control.
|
|
67
|
+
*/
|
|
50
68
|
label?: string
|
|
51
69
|
}
|
|
52
70
|
|
|
53
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* One autocomplete suggestion produced by the host's FST prefix-walk.
|
|
73
|
+
*/
|
|
54
74
|
export interface Suggestion {
|
|
55
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* The text inserted when the suggestion is picked.
|
|
77
|
+
*/
|
|
56
78
|
value: string
|
|
57
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Optional display label if it differs from `value`.
|
|
81
|
+
*/
|
|
58
82
|
label?: string
|
|
59
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Optional place kind for badge/icon rendering.
|
|
85
|
+
*/
|
|
60
86
|
placetype?: string
|
|
61
87
|
}
|
|
62
88
|
|
|
63
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* A selectable model bundle (version tag + a display label the picker shows).
|
|
91
|
+
*/
|
|
64
92
|
export interface DemoVersionOption {
|
|
65
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* The version tag (e.g. a git tag or model-card version).
|
|
95
|
+
*/
|
|
66
96
|
version: string
|
|
67
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Display label; falls back to `version`.
|
|
99
|
+
*/
|
|
68
100
|
label?: string
|
|
69
101
|
}
|
|
70
102
|
|
|
71
|
-
/**
|
|
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
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* The composed basemap style (URL or `StyleSpecification`).
|
|
119
|
+
*/
|
|
84
120
|
mapStyle: DemoMapStyle
|
|
85
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Host-supplied overlays (coverage, race-dots, …).
|
|
123
|
+
*/
|
|
86
124
|
overlays?: OverlaySpec[]
|
|
87
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* Initial map center as `[lon, lat]` (the host's browser-geolocation result).
|
|
127
|
+
*/
|
|
88
128
|
initialCenter: LngLatTuple
|
|
89
|
-
/**
|
|
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
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* FST prefix-walk autocomplete, wrapped by the host.
|
|
146
|
+
*/
|
|
103
147
|
autocomplete?: (query: string) => Promise<Suggestion[]>
|
|
104
|
-
/**
|
|
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
|
-
/**
|
|
162
|
+
/**
|
|
163
|
+
* The selectable model bundles the version picker offers.
|
|
164
|
+
*/
|
|
117
165
|
availableVersions?: DemoVersionOption[]
|
|
118
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* The currently-selected model version.
|
|
168
|
+
*/
|
|
119
169
|
selectedVersion?: string
|
|
120
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Switch the active model bundle (re-loads weights/tokenizer/gazetteer).
|
|
172
|
+
*/
|
|
121
173
|
selectVersion?: (version: string) => void
|
|
122
|
-
/**
|
|
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
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* Whether the CPU/WASM backend is currently forced (the controlled value for the backend toggle).
|
|
180
|
+
*/
|
|
125
181
|
forceWASM?: boolean
|
|
126
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* The current primary parse result, or `null` before the first submit.
|
|
194
|
+
*/
|
|
133
195
|
result: ParseResult | null
|
|
134
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* Whether the compare toggle is on.
|
|
198
|
+
*/
|
|
135
199
|
compareMode: boolean
|
|
136
|
-
/**
|
|
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
|
-
/**
|
|
213
|
+
/**
|
|
214
|
+
* The current parse+resolve result.
|
|
215
|
+
*/
|
|
148
216
|
result: ParseResult
|
|
149
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* The selected candidate (falls back to the first), enriched for the resolved-place detail.
|
|
219
|
+
*/
|
|
150
220
|
selectedCandidate: ResolvedPlaceView | null
|
|
151
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* The selected candidate index, for the picker's active state.
|
|
223
|
+
*/
|
|
152
224
|
selectedCandidateIndex: number
|
|
153
|
-
/**
|
|
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
|
-
/**
|
|
238
|
+
/**
|
|
239
|
+
* Rendered at the top of the control panel (e.g. the docs "About this demo").
|
|
240
|
+
*/
|
|
165
241
|
header?: ReactNode
|
|
166
|
-
/**
|
|
242
|
+
/**
|
|
243
|
+
* One-line release blurb for the selected version.
|
|
244
|
+
*/
|
|
167
245
|
releaseInfo?: ReactNode
|
|
168
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
287
|
+
/**
|
|
288
|
+
* Extra map controls mounted as `<DemoMap>` children (host's DebugControl / LayerToggle via `useControl`).
|
|
289
|
+
*/
|
|
204
290
|
mapControls?: ReactNode
|
|
205
|
-
/**
|
|
291
|
+
/**
|
|
292
|
+
* A permalink control for the current address (host's PermalinkButton).
|
|
293
|
+
*/
|
|
206
294
|
permalink?: (text: string) => ReactNode
|
|
207
295
|
}
|
package/map/useCompareState.ts
CHANGED
|
@@ -13,15 +13,25 @@
|
|
|
13
13
|
import { useCallback, useState } from "react"
|
|
14
14
|
|
|
15
15
|
export interface UseCompareState {
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Whether compare mode is on.
|
|
18
|
+
*/
|
|
17
19
|
compareMode: boolean
|
|
18
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* The version chosen to compare against, or `null`.
|
|
22
|
+
*/
|
|
19
23
|
compareVersion: string | null
|
|
20
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Flip compare mode; turning it off clears the chosen version.
|
|
26
|
+
*/
|
|
21
27
|
setCompareMode: (compareMode: boolean) => void
|
|
22
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Choose a compare version (`null` clears it).
|
|
30
|
+
*/
|
|
23
31
|
setCompareVersion: (version: string | null) => void
|
|
24
|
-
/**
|
|
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
|
|
package/map/useDemoGeocode.ts
CHANGED
|
@@ -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
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* The injected demo runtime (extends `PipelineRuntime` with the map + bias surface).
|
|
31
|
+
*/
|
|
30
32
|
runtime: DemoRuntime
|
|
31
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Address to pre-fill.
|
|
35
|
+
*/
|
|
32
36
|
defaultText: string
|
|
33
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
package/map/useMapPlaceRender.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
}
|