@mailwoman/react 10.1.0 → 10.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/README.md +1 -0
- package/lib/common/About.tsx +3 -3
- package/lib/common/CopyButton.tsx +6 -2
- package/lib/common/LoadingIndicator.tsx +10 -4
- package/lib/common/PresetChips.tsx +3 -1
- package/lib/common/confidence-tiers.ts +1 -1
- package/lib/common/text-tokens.ts +3 -9
- package/lib/index.ts +0 -1
- package/lib/map/AppIdentity.tsx +6 -2
- package/lib/map/DebugInfo.tsx +3 -16
- package/lib/map/Geocoder.tsx +9 -8
- package/lib/map/GeocoderControls.tsx +1 -13
- package/lib/map/GraticuleLayer.tsx +3 -1
- package/lib/map/MapCanvas.tsx +3 -1
- package/lib/map/MapChipRow.tsx +1 -1
- package/lib/map/MapCompass.tsx +3 -1
- package/lib/map/MapControlStack.tsx +3 -1
- package/lib/map/MapFooter.tsx +3 -1
- package/lib/map/OverlayLayers.tsx +13 -2
- package/lib/map/PlaceAutocomplete.tsx +3 -1
- package/lib/map/PlaceMarker.tsx +6 -2
- package/lib/map/ResolvedPlaceLayers.tsx +13 -5
- package/lib/map/ResultCamera.tsx +3 -1
- package/lib/map/ResultOverlay.tsx +12 -4
- package/lib/map/VersionPicker.tsx +1 -1
- package/lib/map/fake-runtime.ts +36 -7
- package/lib/map/map-debug.ts +3 -1
- package/lib/map/place-render.ts +3 -3
- package/lib/map/types.ts +2 -15
- package/lib/map/useMapPlaceRender.ts +1 -1
- package/lib/map/usePlaceAutocomplete.ts +2 -2
- package/lib/map.ts +0 -3
- package/lib/pipeline/ConfidenceCell.tsx +1 -1
- package/lib/pipeline/PipelineExplorer.tsx +6 -3
- package/lib/pipeline/ResolvedPlace.tsx +1 -1
- package/lib/pipeline/TreeView.tsx +1 -1
- package/lib/pipeline/types.ts +0 -4
- package/lib/poi/POIExplorer.tsx +6 -3
- package/lib/poi/runtime.ts +9 -0
- package/lib/poi/types.ts +27 -28
- package/lib/poi/usePOISearch.ts +55 -41
- package/lib/poi.ts +1 -0
- package/lib/runtime/useReleaseRuntime.ts +14 -33
- package/lib/search/SearchModal.tsx +227 -66
- package/lib/search/search.css +160 -22
- package/lib/search/types.ts +2 -1
- package/out/common/About.d.ts +1 -1
- package/out/common/About.js +1 -1
- package/out/common/About.js.map +1 -1
- package/out/common/CopyButton.d.ts +6 -2
- package/out/common/CopyButton.d.ts.map +1 -1
- package/out/common/CopyButton.js.map +1 -1
- package/out/common/LoadingIndicator.d.ts +10 -4
- package/out/common/LoadingIndicator.d.ts.map +1 -1
- package/out/common/LoadingIndicator.js.map +1 -1
- package/out/common/PresetChips.d.ts +3 -1
- package/out/common/PresetChips.d.ts.map +1 -1
- package/out/common/PresetChips.js.map +1 -1
- package/out/common/confidence-tiers.d.ts +1 -1
- package/out/common/confidence-tiers.d.ts.map +1 -1
- package/out/common/confidence-tiers.js.map +1 -1
- package/out/common/text-tokens.d.ts +2 -8
- package/out/common/text-tokens.d.ts.map +1 -1
- package/out/common/text-tokens.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.d.ts.map +1 -1
- package/out/map/AppIdentity.d.ts +6 -2
- package/out/map/AppIdentity.d.ts.map +1 -1
- package/out/map/AppIdentity.js.map +1 -1
- package/out/map/DebugInfo.d.ts +2 -9
- package/out/map/DebugInfo.d.ts.map +1 -1
- package/out/map/DebugInfo.js +3 -6
- package/out/map/DebugInfo.js.map +1 -1
- package/out/map/Geocoder.d.ts +4 -4
- package/out/map/Geocoder.d.ts.map +1 -1
- package/out/map/Geocoder.js +4 -2
- package/out/map/Geocoder.js.map +1 -1
- package/out/map/GeocoderControls.d.ts +2 -3
- package/out/map/GeocoderControls.d.ts.map +1 -1
- package/out/map/GeocoderControls.js +2 -3
- package/out/map/GeocoderControls.js.map +1 -1
- package/out/map/GraticuleLayer.d.ts +3 -1
- package/out/map/GraticuleLayer.d.ts.map +1 -1
- package/out/map/GraticuleLayer.js.map +1 -1
- package/out/map/MapCanvas.d.ts +3 -1
- package/out/map/MapCanvas.d.ts.map +1 -1
- package/out/map/MapCanvas.js.map +1 -1
- package/out/map/MapChipRow.d.ts +1 -1
- package/out/map/MapCompass.d.ts +3 -1
- package/out/map/MapCompass.d.ts.map +1 -1
- package/out/map/MapCompass.js.map +1 -1
- package/out/map/MapControlStack.d.ts +3 -1
- package/out/map/MapControlStack.d.ts.map +1 -1
- package/out/map/MapControlStack.js.map +1 -1
- package/out/map/MapFooter.d.ts +3 -1
- package/out/map/MapFooter.d.ts.map +1 -1
- package/out/map/MapFooter.js.map +1 -1
- package/out/map/OverlayLayers.d.ts +7 -1
- package/out/map/OverlayLayers.d.ts.map +1 -1
- package/out/map/OverlayLayers.js +2 -2
- package/out/map/OverlayLayers.js.map +1 -1
- package/out/map/PlaceAutocomplete.d.ts +3 -1
- package/out/map/PlaceAutocomplete.d.ts.map +1 -1
- package/out/map/PlaceAutocomplete.js.map +1 -1
- package/out/map/PlaceMarker.d.ts +6 -2
- package/out/map/PlaceMarker.d.ts.map +1 -1
- package/out/map/PlaceMarker.js.map +1 -1
- package/out/map/ResolvedPlaceLayers.d.ts +13 -5
- package/out/map/ResolvedPlaceLayers.d.ts.map +1 -1
- package/out/map/ResolvedPlaceLayers.js.map +1 -1
- package/out/map/ResultCamera.d.ts +3 -1
- package/out/map/ResultCamera.d.ts.map +1 -1
- package/out/map/ResultCamera.js.map +1 -1
- package/out/map/ResultOverlay.d.ts +12 -4
- package/out/map/ResultOverlay.d.ts.map +1 -1
- package/out/map/ResultOverlay.js.map +1 -1
- package/out/map/VersionPicker.d.ts +1 -1
- package/out/map/fake-runtime.d.ts.map +1 -1
- package/out/map/fake-runtime.js +36 -7
- package/out/map/fake-runtime.js.map +1 -1
- package/out/map/map-debug.d.ts +3 -1
- package/out/map/map-debug.d.ts.map +1 -1
- package/out/map/map-debug.js.map +1 -1
- package/out/map/place-render.d.ts +3 -3
- package/out/map/place-render.d.ts.map +1 -1
- package/out/map/types.d.ts +2 -14
- package/out/map/types.d.ts.map +1 -1
- package/out/map/useMapPlaceRender.d.ts +1 -1
- package/out/map/useMapPlaceRender.d.ts.map +1 -1
- package/out/map/useMapPlaceRender.js.map +1 -1
- package/out/map/usePlaceAutocomplete.d.ts +2 -2
- package/out/map.d.ts +1 -3
- package/out/map.d.ts.map +1 -1
- package/out/map.js +0 -1
- package/out/map.js.map +1 -1
- package/out/pipeline/ConfidenceCell.d.ts +1 -1
- package/out/pipeline/ConfidenceCell.d.ts.map +1 -1
- package/out/pipeline/PipelineExplorer.d.ts +6 -2
- package/out/pipeline/PipelineExplorer.d.ts.map +1 -1
- package/out/pipeline/PipelineExplorer.js +1 -1
- package/out/pipeline/PipelineExplorer.js.map +1 -1
- package/out/pipeline/ResolvedPlace.d.ts +1 -1
- package/out/pipeline/ResolvedPlace.d.ts.map +1 -1
- package/out/pipeline/TreeView.js.map +1 -1
- package/out/pipeline/types.d.ts +0 -4
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/poi/POIExplorer.d.ts +1 -1
- package/out/poi/POIExplorer.d.ts.map +1 -1
- package/out/poi/POIExplorer.js +2 -2
- package/out/poi/POIExplorer.js.map +1 -1
- package/out/poi/runtime.d.ts.map +1 -1
- package/out/poi/runtime.js +9 -0
- package/out/poi/runtime.js.map +1 -1
- package/out/poi/types.d.ts +24 -28
- package/out/poi/types.d.ts.map +1 -1
- package/out/poi/usePOISearch.d.ts +4 -2
- package/out/poi/usePOISearch.d.ts.map +1 -1
- package/out/poi/usePOISearch.js +42 -32
- package/out/poi/usePOISearch.js.map +1 -1
- package/out/poi.d.ts +1 -1
- package/out/poi.d.ts.map +1 -1
- package/out/poi.js.map +1 -1
- package/out/runtime/useReleaseRuntime.d.ts +13 -23
- package/out/runtime/useReleaseRuntime.d.ts.map +1 -1
- package/out/runtime/useReleaseRuntime.js +2 -8
- package/out/runtime/useReleaseRuntime.js.map +1 -1
- package/out/search/SearchModal.d.ts +10 -3
- package/out/search/SearchModal.d.ts.map +1 -1
- package/out/search/SearchModal.js +83 -15
- package/out/search/SearchModal.js.map +1 -1
- package/out/search/types.d.ts +2 -1
- package/out/search/types.d.ts.map +1 -1
- package/package.json +19 -29
- package/lib/map/BackendControl.tsx +0 -50
- package/out/map/BackendControl.d.ts +0 -31
- package/out/map/BackendControl.d.ts.map +0 -1
- package/out/map/BackendControl.js +0 -8
- package/out/map/BackendControl.js.map +0 -1
package/README.md
CHANGED
package/lib/common/About.tsx
CHANGED
|
@@ -15,7 +15,7 @@ export interface AboutProps {
|
|
|
15
15
|
* Set false where the host is already the disclosure, because a summary repeating
|
|
16
16
|
* an About button's words is one control too many.
|
|
17
17
|
*
|
|
18
|
-
* @
|
|
18
|
+
* @defaultValue `true`
|
|
19
19
|
*/
|
|
20
20
|
collapsible?: boolean
|
|
21
21
|
}
|
|
@@ -28,8 +28,8 @@ export function About({ collapsible = true }: AboutProps = {}): ReactNode {
|
|
|
28
28
|
<p>
|
|
29
29
|
A ~29M-parameter BERT-style encoder classifies each token into one of 33 BIO labels covering 16 address
|
|
30
30
|
components (street, house number, unit, locality, region, postcode, venue, country, intersection, etc.). It
|
|
31
|
-
runs entirely in your browser via <strong>onnxruntime-web</strong>
|
|
32
|
-
|
|
31
|
+
runs entirely in your browser via <strong>onnxruntime-web</strong> on its WASM SIMD backend. The model ships
|
|
32
|
+
as a 37.6 MB int8-quantized ONNX bundle; fp32 weights are also available for higher accuracy.
|
|
33
33
|
</p>
|
|
34
34
|
</section>
|
|
35
35
|
|
|
@@ -19,11 +19,15 @@ export interface CopyButtonProps {
|
|
|
19
19
|
*/
|
|
20
20
|
value: string | (() => string)
|
|
21
21
|
/**
|
|
22
|
-
* Label in the idle state.
|
|
22
|
+
* Label in the idle state.
|
|
23
|
+
*
|
|
24
|
+
* @defaultValue `"Copy"`
|
|
23
25
|
*/
|
|
24
26
|
label?: ReactNode
|
|
25
27
|
/**
|
|
26
|
-
* Label shown briefly after a successful copy.
|
|
28
|
+
* Label shown briefly after a successful copy.
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue `"✓ Copied"`
|
|
27
31
|
*/
|
|
28
32
|
copiedLabel?: ReactNode
|
|
29
33
|
className?: string
|
|
@@ -17,7 +17,7 @@ export type LoadingMode = "pulse" | "spinner" | "staged"
|
|
|
17
17
|
|
|
18
18
|
export interface LoadingIndicatorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
19
19
|
/**
|
|
20
|
-
* @
|
|
20
|
+
* @defaultValue `"spinner"`
|
|
21
21
|
*/
|
|
22
22
|
mode?: LoadingMode
|
|
23
23
|
/**
|
|
@@ -26,11 +26,15 @@ export interface LoadingIndicatorProps extends React.HTMLAttributes<HTMLDivEleme
|
|
|
26
26
|
*/
|
|
27
27
|
label?: string
|
|
28
28
|
/**
|
|
29
|
-
* Number of skeleton bars (pulse mode).
|
|
29
|
+
* Number of skeleton bars (pulse mode).
|
|
30
|
+
*
|
|
31
|
+
* @defaultValue `3`
|
|
30
32
|
*/
|
|
31
33
|
barCount?: number
|
|
32
34
|
/**
|
|
33
|
-
* Spinner ring size.
|
|
35
|
+
* Spinner ring size.
|
|
36
|
+
*
|
|
37
|
+
* @defaultValue `"medium"`
|
|
34
38
|
*/
|
|
35
39
|
size?: "small" | "medium" | "large"
|
|
36
40
|
/**
|
|
@@ -39,7 +43,9 @@ export interface LoadingIndicatorProps extends React.HTMLAttributes<HTMLDivEleme
|
|
|
39
43
|
steps?: string[]
|
|
40
44
|
/**
|
|
41
45
|
* 0-based index of the active step.
|
|
42
|
-
* Earlier steps are complete, later ones pending.
|
|
46
|
+
* Earlier steps are complete, later ones pending.
|
|
47
|
+
*
|
|
48
|
+
* @defaultValue `-1`
|
|
43
49
|
*/
|
|
44
50
|
activeStep?: number
|
|
45
51
|
}
|
|
@@ -26,7 +26,9 @@ export interface PresetChipsProps {
|
|
|
26
26
|
onPick: (value: string) => void
|
|
27
27
|
disabled?: boolean
|
|
28
28
|
/**
|
|
29
|
-
* The label shown before the choices.
|
|
29
|
+
* The label shown before the choices.
|
|
30
|
+
*
|
|
31
|
+
* @defaultValue `"Try:"`
|
|
30
32
|
*/
|
|
31
33
|
caption?: string
|
|
32
34
|
/**
|
|
@@ -44,7 +44,7 @@ export function confidenceTier(confidence: number): ConfidenceTier {
|
|
|
44
44
|
* {@link confidenceTier} for a possibly-absent confidence: an unmeasured span is drawn as `mid`
|
|
45
45
|
* rather than `low`, so an older model that emits no confidence never reads as uniformly wrong.
|
|
46
46
|
*/
|
|
47
|
-
export function confidenceTierOrMid(confidence?: number): ConfidenceTier {
|
|
47
|
+
export function confidenceTierOrMid(confidence?: number | null): ConfidenceTier {
|
|
48
48
|
if (confidence == null) return "mid"
|
|
49
49
|
|
|
50
50
|
return confidenceTier(confidence)
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* the owner walk live here.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import type { CharRange } from "@mailwoman/query-shape"
|
|
14
|
+
|
|
13
15
|
export interface WordToken {
|
|
14
16
|
/**
|
|
15
17
|
* The word text as it appears in the input.
|
|
@@ -61,20 +63,12 @@ export function tokenizeWords(input: string): WordToken[] {
|
|
|
61
63
|
return words
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
/**
|
|
65
|
-
* A half-open `[start, end)` character range into the input.
|
|
66
|
-
*/
|
|
67
|
-
export interface CharSpan {
|
|
68
|
-
start: number
|
|
69
|
-
end: number
|
|
70
|
-
}
|
|
71
|
-
|
|
72
66
|
/**
|
|
73
67
|
* Per-word index of the most specific (shortest) span covering it, or `-1` when no span overlaps the word.
|
|
74
68
|
*
|
|
75
69
|
* A word is covered when any part of it falls within the span.
|
|
76
70
|
*/
|
|
77
|
-
export function shortestSpanOwners(words: readonly
|
|
71
|
+
export function shortestSpanOwners(words: readonly CharRange[], spans: readonly CharRange[]): number[] {
|
|
78
72
|
return words.map((word) => {
|
|
79
73
|
let best = -1
|
|
80
74
|
let bestLen = Infinity
|
package/lib/index.ts
CHANGED
package/lib/map/AppIdentity.tsx
CHANGED
|
@@ -30,11 +30,15 @@ export interface AppIdentityProps {
|
|
|
30
30
|
*/
|
|
31
31
|
docsURL?: string
|
|
32
32
|
/**
|
|
33
|
-
* The documentation link's text.
|
|
33
|
+
* The documentation link's text.
|
|
34
|
+
*
|
|
35
|
+
* @defaultValue `"Developer Documentation"`
|
|
34
36
|
*/
|
|
35
37
|
docsLabel?: string
|
|
36
38
|
/**
|
|
37
|
-
* The URL of the build record.
|
|
39
|
+
* The URL of the build record.
|
|
40
|
+
*
|
|
41
|
+
* @defaultValue `"/build.json"`
|
|
38
42
|
*/
|
|
39
43
|
buildInfoURL?: string
|
|
40
44
|
/**
|
package/lib/map/DebugInfo.tsx
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
6
|
* Display and log build, model and runtime details for bug reports.
|
|
7
|
-
* Report the actual execution backend because successful loading does not imply WebGPU ran.
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
9
|
import { type ReactNode, useEffect, useMemo } from "react"
|
|
@@ -13,15 +12,9 @@ import { useBuildInfo } from "#common/useBuildInfo"
|
|
|
13
12
|
|
|
14
13
|
export interface DebugInfoProps {
|
|
15
14
|
/**
|
|
16
|
-
* The backend
|
|
15
|
+
* The runtime's backend and model size (e.g. `wasm (28 MB int8)`); empty before the model loads.
|
|
17
16
|
*/
|
|
18
17
|
activeBackend?: string
|
|
19
|
-
/**
|
|
20
|
-
* Whether the CPU/wasm backend is currently forced.
|
|
21
|
-
*
|
|
22
|
-
* This explains a `wasm` backend that would otherwise indicate a WebGPU failure.
|
|
23
|
-
*/
|
|
24
|
-
forceWASM?: boolean
|
|
25
18
|
/**
|
|
26
19
|
* The model version the runtime loaded.
|
|
27
20
|
*
|
|
@@ -47,7 +40,7 @@ function Row({ label, value }: { label: string; value: string }): ReactNode {
|
|
|
47
40
|
)
|
|
48
41
|
}
|
|
49
42
|
|
|
50
|
-
export function DebugInfo({ activeBackend,
|
|
43
|
+
export function DebugInfo({ activeBackend, selectedVersion, ready }: DebugInfoProps): ReactNode {
|
|
51
44
|
const build = useBuildInfo()
|
|
52
45
|
|
|
53
46
|
// Memoized on the primitives it reads, so the log below fires when a value changes
|
|
@@ -60,11 +53,9 @@ export function DebugInfo({ activeBackend, forceWASM, selectedVersion, ready }:
|
|
|
60
53
|
buildTime: build?.buildTime ?? "—",
|
|
61
54
|
model: selectedVersion ?? "—",
|
|
62
55
|
backend: activeBackend || (ready ? "unknown" : "loading…"),
|
|
63
|
-
forceWASM: Boolean(forceWASM),
|
|
64
|
-
webgpuInBrowser: typeof navigator !== "undefined" && "gpu" in navigator,
|
|
65
56
|
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "—",
|
|
66
57
|
}),
|
|
67
|
-
[build?.app, build?.commit, build?.revision, build?.buildTime, selectedVersion, activeBackend,
|
|
58
|
+
[build?.app, build?.commit, build?.revision, build?.buildTime, selectedVersion, activeBackend, ready]
|
|
68
59
|
)
|
|
69
60
|
|
|
70
61
|
useEffect(() => {
|
|
@@ -79,10 +70,6 @@ export function DebugInfo({ activeBackend, forceWASM, selectedVersion, ready }:
|
|
|
79
70
|
<Row label="Built" value={record.buildTime} />
|
|
80
71
|
<Row label="Model" value={record.model} />
|
|
81
72
|
<Row label="Backend" value={record.backend} />
|
|
82
|
-
{/* A browser with no WebGPU at all explains a `wasm` backend that is otherwise indistinguishable from a
|
|
83
|
-
WebGPU session that threw. */}
|
|
84
|
-
<Row label="WebGPU available" value={record.webgpuInBrowser ? "yes" : "no"} />
|
|
85
|
-
<Row label="Force WASM" value={record.forceWASM ? "on" : "off"} />
|
|
86
73
|
</div>
|
|
87
74
|
)
|
|
88
75
|
}
|
package/lib/map/Geocoder.tsx
CHANGED
|
@@ -50,13 +50,13 @@ export interface GeocoderProps {
|
|
|
50
50
|
/**
|
|
51
51
|
* The example chips.
|
|
52
52
|
*
|
|
53
|
-
* @
|
|
53
|
+
* @defaultValue []
|
|
54
54
|
*/
|
|
55
55
|
presets?: ReadonlyArray<Preset>
|
|
56
56
|
/**
|
|
57
57
|
* Whether the developer panel starts open.
|
|
58
58
|
*
|
|
59
|
-
* @
|
|
59
|
+
* @defaultValue `false`
|
|
60
60
|
*/
|
|
61
61
|
developer?: boolean
|
|
62
62
|
/**
|
|
@@ -69,7 +69,7 @@ export interface GeocoderProps {
|
|
|
69
69
|
/**
|
|
70
70
|
* The minimum map zoom at which the viewport is sent as a location bias.
|
|
71
71
|
*
|
|
72
|
-
* @
|
|
72
|
+
* @defaultValue `4`
|
|
73
73
|
*/
|
|
74
74
|
minBiasZoom?: number
|
|
75
75
|
/**
|
|
@@ -78,7 +78,7 @@ export interface GeocoderProps {
|
|
|
78
78
|
* Set it to false when the host controls the camera or a test needs a fixed view.
|
|
79
79
|
* The marker and outline render either way.
|
|
80
80
|
*
|
|
81
|
-
* @
|
|
81
|
+
* @defaultValue `true`
|
|
82
82
|
*/
|
|
83
83
|
applyResultCamera?: boolean
|
|
84
84
|
}
|
|
@@ -111,6 +111,9 @@ function GeocoderInner({
|
|
|
111
111
|
// The graticule is inserted before the first non-background layer, so it draws under the data layers.
|
|
112
112
|
const [baseLayerID, setBaseLayerID] = useState<string | undefined>(undefined)
|
|
113
113
|
|
|
114
|
+
// Overlays are inserted before the first label layer, so place names stay readable over a fill.
|
|
115
|
+
const [labelLayerID, setLabelLayerID] = useState<string | undefined>(undefined)
|
|
116
|
+
|
|
114
117
|
const onMapLoad = useCallback((event: { target: ReturnType<MapRef["getMap"]> }) => {
|
|
115
118
|
// Browser tests read the map from this global.
|
|
116
119
|
;(globalThis as { __mailwomanMapCanvas?: ReturnType<MapRef["getMap"]> }).__mailwomanMapCanvas = event.target
|
|
@@ -119,6 +122,7 @@ function GeocoderInner({
|
|
|
119
122
|
const layers = event.target.getStyle()?.layers ?? []
|
|
120
123
|
|
|
121
124
|
setBaseLayerID(layers.find((layer) => layer.type !== "background")?.id)
|
|
125
|
+
setLabelLayerID(layers.find((layer) => layer.type === "symbol")?.id)
|
|
122
126
|
}, [])
|
|
123
127
|
|
|
124
128
|
useEffect(
|
|
@@ -160,8 +164,6 @@ function GeocoderInner({
|
|
|
160
164
|
[runtime, compare]
|
|
161
165
|
)
|
|
162
166
|
|
|
163
|
-
const onForceWASMChange = useCallback((forceWASM: boolean) => runtime.setForceWASM?.(forceWASM), [runtime])
|
|
164
|
-
|
|
165
167
|
return (
|
|
166
168
|
<div className="mw-geocoder-demo">
|
|
167
169
|
<div className="mw-geocoder-demo__map">
|
|
@@ -179,7 +181,7 @@ function GeocoderInner({
|
|
|
179
181
|
mapProps={{ attributionControl: { compact: true }, maplibreLogo: false, onLoad: onMapLoad }}
|
|
180
182
|
>
|
|
181
183
|
<GraticuleLayer beforeID={baseLayerID} />
|
|
182
|
-
<OverlayLayers overlays={runtime.overlays} />
|
|
184
|
+
<OverlayLayers overlays={runtime.overlays} beforeID={labelLayerID} />
|
|
183
185
|
<ResolvedPlaceLayers spec={spec} applyCamera={applyResultCamera} />
|
|
184
186
|
{panels.mapControls}
|
|
185
187
|
</MapCanvas>
|
|
@@ -197,7 +199,6 @@ function GeocoderInner({
|
|
|
197
199
|
map={map}
|
|
198
200
|
onSubmitQuery={onSubmitQuery}
|
|
199
201
|
onSelectVersion={onSelectVersion}
|
|
200
|
-
onForceWASMChange={onForceWASMChange}
|
|
201
202
|
developer={developer}
|
|
202
203
|
/>
|
|
203
204
|
{panels.debugDrawer ? panels.debugDrawer({ result: geocode.result }) : null}
|
|
@@ -17,7 +17,6 @@ import type { UsePlaceAutocomplete } from "#map/usePlaceAutocomplete"
|
|
|
17
17
|
|
|
18
18
|
import { LoadingIndicator } from "../common/LoadingIndicator.tsx"
|
|
19
19
|
import type { Preset } from "../common/PresetChips.tsx"
|
|
20
|
-
import { BackendControl } from "./BackendControl.tsx"
|
|
21
20
|
import { CompareToggle } from "./CompareToggle.tsx"
|
|
22
21
|
import { DebugInfo } from "./DebugInfo.tsx"
|
|
23
22
|
import { MapChipRow } from "./MapChipRow.tsx"
|
|
@@ -56,11 +55,10 @@ export interface GeocoderControlsProps {
|
|
|
56
55
|
*/
|
|
57
56
|
onSubmitQuery?: (query: string) => void
|
|
58
57
|
onSelectVersion: (version: string) => void
|
|
59
|
-
onForceWASMChange: (forceWASM: boolean) => void
|
|
60
58
|
/**
|
|
61
59
|
* Whether the developer panel starts open.
|
|
62
60
|
*
|
|
63
|
-
* @
|
|
61
|
+
* @defaultValue `false`
|
|
64
62
|
*/
|
|
65
63
|
developer?: boolean
|
|
66
64
|
}
|
|
@@ -100,7 +98,6 @@ export function GeocoderControls({
|
|
|
100
98
|
initialQuery = null,
|
|
101
99
|
onSubmitQuery,
|
|
102
100
|
onSelectVersion,
|
|
103
|
-
onForceWASMChange,
|
|
104
101
|
developer = false,
|
|
105
102
|
}: GeocoderControlsProps): ReactNode {
|
|
106
103
|
const versions = runtime.availableVersions ?? []
|
|
@@ -608,19 +605,10 @@ export function GeocoderControls({
|
|
|
608
605
|
/>
|
|
609
606
|
</div>
|
|
610
607
|
|
|
611
|
-
<div className="mw-map-sheet__row">
|
|
612
|
-
<BackendControl
|
|
613
|
-
activeBackend={runtime.activeBackend}
|
|
614
|
-
forceWASM={runtime.forceWASM ?? false}
|
|
615
|
-
onForceWASMChange={onForceWASMChange}
|
|
616
|
-
/>
|
|
617
|
-
</div>
|
|
618
|
-
|
|
619
608
|
<div className="mw-map-sheet__row">
|
|
620
609
|
<span className="mw-map-sheet__label">Debug info</span>
|
|
621
610
|
<DebugInfo
|
|
622
611
|
activeBackend={runtime.activeBackend}
|
|
623
|
-
forceWASM={runtime.forceWASM}
|
|
624
612
|
selectedVersion={runtime.selectedVersion}
|
|
625
613
|
ready={runtime.ready}
|
|
626
614
|
/>
|
package/lib/map/MapCanvas.tsx
CHANGED
|
@@ -62,7 +62,9 @@ export interface MapCanvasProps {
|
|
|
62
62
|
*/
|
|
63
63
|
onMove?: (event: ViewStateChangeEvent) => void
|
|
64
64
|
/**
|
|
65
|
-
* Map projection.
|
|
65
|
+
* Map projection.
|
|
66
|
+
*
|
|
67
|
+
* @defaultValue `"globe"` (matches the docs `DashboardMap`).
|
|
66
68
|
*/
|
|
67
69
|
projection?: MapProps["projection"]
|
|
68
70
|
/**
|
package/lib/map/MapChipRow.tsx
CHANGED
package/lib/map/MapCompass.tsx
CHANGED
|
@@ -31,7 +31,9 @@ export interface MapCompassProps {
|
|
|
31
31
|
*/
|
|
32
32
|
onResetNorth: () => void
|
|
33
33
|
/**
|
|
34
|
-
* The control's accessible name.
|
|
34
|
+
* The control's accessible name.
|
|
35
|
+
*
|
|
36
|
+
* @defaultValue `"Reset bearing to north"`
|
|
35
37
|
*/
|
|
36
38
|
label?: string
|
|
37
39
|
className?: string
|
|
@@ -74,7 +74,9 @@ export interface MapControlStackProps {
|
|
|
74
74
|
*/
|
|
75
75
|
children: ReactNode
|
|
76
76
|
/**
|
|
77
|
-
* Which edge the column sits against.
|
|
77
|
+
* Which edge the column sits against.
|
|
78
|
+
*
|
|
79
|
+
* @defaultValue `"right"`
|
|
78
80
|
*/
|
|
79
81
|
side?: "left" | "right"
|
|
80
82
|
className?: string
|
package/lib/map/MapFooter.tsx
CHANGED
|
@@ -22,7 +22,9 @@ export interface MapFooterProps {
|
|
|
22
22
|
*/
|
|
23
23
|
attribution?: ReactNode[]
|
|
24
24
|
/**
|
|
25
|
-
* What the attribution button reads.
|
|
25
|
+
* What the attribution button reads.
|
|
26
|
+
*
|
|
27
|
+
* @defaultValue `"Sources"`
|
|
26
28
|
*/
|
|
27
29
|
attributionLabel?: string
|
|
28
30
|
className?: string
|
|
@@ -23,12 +23,18 @@ export interface OverlayLayersProps {
|
|
|
23
23
|
* The overlays to render, in draw order (first is drawn first / lowest).
|
|
24
24
|
*/
|
|
25
25
|
overlays?: OverlaySpec[]
|
|
26
|
+
/**
|
|
27
|
+
* The basemap layer every overlay layer is inserted beneath, such as the first
|
|
28
|
+
* label layer, so labels stay readable over a fill.
|
|
29
|
+
* Omitted, the layers go on top of the style.
|
|
30
|
+
*/
|
|
31
|
+
beforeID?: string
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
/**
|
|
29
35
|
* Render each overlay as one `<Source>` and its `<Layer>`s, honoring the `visible` flag via `visibility`.
|
|
30
36
|
*/
|
|
31
|
-
export function OverlayLayers({ overlays }: OverlayLayersProps): ReactNode {
|
|
37
|
+
export function OverlayLayers({ overlays, beforeID }: OverlayLayersProps): ReactNode {
|
|
32
38
|
if (!overlays || !overlays.length) return null
|
|
33
39
|
|
|
34
40
|
return (
|
|
@@ -40,7 +46,12 @@ export function OverlayLayers({ overlays }: OverlayLayersProps): ReactNode {
|
|
|
40
46
|
<Fragment key={overlay.id}>
|
|
41
47
|
<Source id={overlay.id} {...overlay.source} />
|
|
42
48
|
{overlay.layers.map((layer) => (
|
|
43
|
-
<Layer
|
|
49
|
+
<Layer
|
|
50
|
+
key={layer.id}
|
|
51
|
+
{...layer}
|
|
52
|
+
{...(beforeID ? { beforeId: beforeID } : {})}
|
|
53
|
+
layout={{ ...layer.layout, visibility }}
|
|
54
|
+
/>
|
|
44
55
|
))}
|
|
45
56
|
</Fragment>
|
|
46
57
|
)
|
|
@@ -31,7 +31,9 @@ export interface PlaceAutocompleteProps {
|
|
|
31
31
|
*/
|
|
32
32
|
optionID: (index: number) => string
|
|
33
33
|
/**
|
|
34
|
-
* The label before the suggestions.
|
|
34
|
+
* The label before the suggestions.
|
|
35
|
+
*
|
|
36
|
+
* @defaultValue `"Did you mean:"`
|
|
35
37
|
*/
|
|
36
38
|
caption?: string
|
|
37
39
|
}
|
package/lib/map/PlaceMarker.tsx
CHANGED
|
@@ -30,11 +30,15 @@ export interface PlaceMarkerProps {
|
|
|
30
30
|
*/
|
|
31
31
|
latitude: number
|
|
32
32
|
/**
|
|
33
|
-
* Pin color.
|
|
33
|
+
* Pin color.
|
|
34
|
+
*
|
|
35
|
+
* @defaultValue the house pink.
|
|
34
36
|
*/
|
|
35
37
|
color?: string
|
|
36
38
|
/**
|
|
37
|
-
* Which part of the marker sits on the coordinate.
|
|
39
|
+
* Which part of the marker sits on the coordinate.
|
|
40
|
+
*
|
|
41
|
+
* @defaultValue `"center"` (a symmetric dot).
|
|
38
42
|
*/
|
|
39
43
|
anchor?: "center" | "top" | "bottom" | "left" | "right"
|
|
40
44
|
}
|
|
@@ -18,20 +18,28 @@ export interface ResolvedPlaceLayersProps {
|
|
|
18
18
|
*/
|
|
19
19
|
spec: MapPlaceRenderSpec | null
|
|
20
20
|
/**
|
|
21
|
-
* Apply the computed camera target via {@link ResultCamera}; set false when the consumer drives the
|
|
22
|
-
* itself (e.g. a controlled `<MapCanvas viewState>` fed by {@link cameraToViewState}).
|
|
21
|
+
* Apply the computed camera target via {@link ResultCamera}; set false when the consumer drives the
|
|
22
|
+
* camera itself (e.g. a controlled `<MapCanvas viewState>` fed by {@link cameraToViewState}).
|
|
23
|
+
*
|
|
24
|
+
* @defaultValue `true`
|
|
23
25
|
*/
|
|
24
26
|
applyCamera?: boolean
|
|
25
27
|
/**
|
|
26
|
-
* Animate the camera move, forwarded to {@link ResultCamera}.
|
|
28
|
+
* Animate the camera move, forwarded to {@link ResultCamera}.
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue `true`
|
|
27
31
|
*/
|
|
28
32
|
animateCamera?: boolean
|
|
29
33
|
/**
|
|
30
|
-
* Source/layer id prefix for the outline.
|
|
34
|
+
* Source/layer id prefix for the outline.
|
|
35
|
+
*
|
|
36
|
+
* @defaultValue `"mw-result"`
|
|
31
37
|
*/
|
|
32
38
|
outlineID?: string
|
|
33
39
|
/**
|
|
34
|
-
* Marker color.
|
|
40
|
+
* Marker color.
|
|
41
|
+
*
|
|
42
|
+
* @defaultValue the house pink.
|
|
35
43
|
*/
|
|
36
44
|
markerColor?: string
|
|
37
45
|
}
|
package/lib/map/ResultCamera.tsx
CHANGED
|
@@ -20,19 +20,27 @@ export interface ResultOverlayProps {
|
|
|
20
20
|
*/
|
|
21
21
|
outline: PlaceGeometry | null
|
|
22
22
|
/**
|
|
23
|
-
* Source/layer id prefix — override to render more than one outline on a map.
|
|
23
|
+
* Source/layer id prefix — override to render more than one outline on a map.
|
|
24
|
+
*
|
|
25
|
+
* @defaultValue `"mw-result"`
|
|
24
26
|
*/
|
|
25
27
|
id?: string
|
|
26
28
|
/**
|
|
27
|
-
* Fill color.
|
|
29
|
+
* Fill color.
|
|
30
|
+
*
|
|
31
|
+
* @defaultValue the house pink.
|
|
28
32
|
*/
|
|
29
33
|
color?: string
|
|
30
34
|
/**
|
|
31
|
-
* Fill opacity.
|
|
35
|
+
* Fill opacity.
|
|
36
|
+
*
|
|
37
|
+
* @defaultValue `0.12`
|
|
32
38
|
*/
|
|
33
39
|
fillOpacity?: number
|
|
34
40
|
/**
|
|
35
|
-
* Outline stroke width (px).
|
|
41
|
+
* Outline stroke width (px).
|
|
42
|
+
*
|
|
43
|
+
* @defaultValue `2`
|
|
36
44
|
*/
|
|
37
45
|
lineWidth?: number
|
|
38
46
|
}
|
package/lib/map/fake-runtime.ts
CHANGED
|
@@ -58,9 +58,7 @@ export function makeFakeGeocoderRuntime(overrides: Partial<GeocoderRuntime> = {}
|
|
|
58
58
|
],
|
|
59
59
|
selectedVersion: "v7.2.0",
|
|
60
60
|
selectVersion: () => {},
|
|
61
|
-
activeBackend: "
|
|
62
|
-
forceWASM: false,
|
|
63
|
-
setForceWASM: () => {},
|
|
61
|
+
activeBackend: "wasm (28 MB int8)",
|
|
64
62
|
|
|
65
63
|
resolveMapPlace: (candidate): ResolvedMapPlace => ({
|
|
66
64
|
...candidate,
|
|
@@ -86,17 +84,48 @@ export function makeFakeParseResult(input = "350 5th Ave, New York, NY 10118"):
|
|
|
86
84
|
nodes: [
|
|
87
85
|
{ tag: "house_number", value: "350", confidence: 0.97, start: 0, end: 3 },
|
|
88
86
|
{ tag: "street", value: "5th Ave", confidence: 0.88, start: 4, end: 11 },
|
|
89
|
-
{ tag: "locality", value: "New York", confidence: 0.71 },
|
|
87
|
+
{ tag: "locality", value: "New York", confidence: 0.71, start: null, end: null },
|
|
90
88
|
],
|
|
91
89
|
kindResult: { kind: "structured_address", confidence: 0.95, alternatives: [] },
|
|
92
90
|
timing: { shape: 0.4, classify: 12.1, resolve: 4.2 },
|
|
93
|
-
resolved: {
|
|
91
|
+
resolved: {
|
|
92
|
+
id: 85_977_539,
|
|
93
|
+
name: "New York",
|
|
94
|
+
placetype: "locality",
|
|
95
|
+
lat: 40.7128,
|
|
96
|
+
lon: -74.006,
|
|
97
|
+
score: 0.82,
|
|
98
|
+
bbox: null,
|
|
99
|
+
tier: null,
|
|
100
|
+
uncertaintyM: null,
|
|
101
|
+
},
|
|
94
102
|
candidates: [
|
|
95
|
-
{
|
|
96
|
-
|
|
103
|
+
{
|
|
104
|
+
id: 85_977_539,
|
|
105
|
+
name: "New York",
|
|
106
|
+
placetype: "locality",
|
|
107
|
+
lat: 40.7128,
|
|
108
|
+
lon: -74.006,
|
|
109
|
+
score: 0.82,
|
|
110
|
+
bbox: null,
|
|
111
|
+
tier: null,
|
|
112
|
+
uncertaintyM: null,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: 101_715_829,
|
|
116
|
+
name: "New York",
|
|
117
|
+
placetype: "region",
|
|
118
|
+
lat: 43,
|
|
119
|
+
lon: -75,
|
|
120
|
+
score: 0.55,
|
|
121
|
+
bbox: null,
|
|
122
|
+
tier: null,
|
|
123
|
+
uncertaintyM: null,
|
|
124
|
+
},
|
|
97
125
|
],
|
|
98
126
|
fstActive: true,
|
|
99
127
|
fstProvenance: { builtAt: "2026-07-01T00:00:00Z", stateCount: 51, placeCount: 94_000, importanceMatches: 12_000 },
|
|
128
|
+
dualRoles: null,
|
|
100
129
|
}
|
|
101
130
|
}
|
|
102
131
|
|
package/lib/map/map-debug.ts
CHANGED
|
@@ -18,7 +18,9 @@ export interface DebugControlBaseOptions {
|
|
|
18
18
|
*/
|
|
19
19
|
className?: string
|
|
20
20
|
/**
|
|
21
|
-
* Where MapLibre docks the control.
|
|
21
|
+
* Where MapLibre docks the control.
|
|
22
|
+
*
|
|
23
|
+
* @defaultValue `"bottom-left"`
|
|
22
24
|
*/
|
|
23
25
|
position?: ControlPosition
|
|
24
26
|
}
|