@mailwoman/react 10.0.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 +18 -16
- package/fonts.css +97 -22
- package/lib/common/About.tsx +10 -10
- package/lib/common/ClientOnly.tsx +2 -14
- package/lib/common/CopyButton.tsx +9 -3
- package/lib/common/LoadingIndicator.tsx +13 -5
- package/lib/common/PresetChips.tsx +11 -8
- package/lib/common/confidence-tiers.ts +8 -7
- package/lib/common/cx.ts +3 -1
- package/lib/common/text-tokens.ts +10 -13
- package/lib/common/useBuildInfo.ts +54 -0
- package/lib/common/useClipboard.ts +2 -11
- package/lib/common.ts +22 -0
- package/lib/index.ts +27 -18
- package/lib/map/AppIdentity.tsx +89 -0
- package/lib/map/CompareToggle.tsx +8 -31
- package/lib/map/DebugInfo.tsx +75 -0
- package/lib/map/Geocoder.tsx +65 -50
- package/lib/map/GeocoderControls.tsx +425 -141
- package/lib/map/GraticuleLayer.tsx +56 -0
- package/lib/map/MapCanvas.tsx +26 -13
- package/lib/map/MapChipRow.tsx +4 -8
- package/lib/map/MapCompass.tsx +18 -25
- package/lib/map/MapControlStack.tsx +11 -10
- package/lib/map/MapFooter.tsx +5 -17
- package/lib/map/MapProgressBar.tsx +10 -13
- package/lib/map/MapSearchBar.tsx +31 -17
- package/lib/map/MapSheet.tsx +24 -15
- package/lib/map/OverlayLayers.tsx +14 -3
- package/lib/map/PlaceAutocomplete.tsx +12 -21
- package/lib/map/PlaceMarker.tsx +10 -4
- package/lib/map/ResolvedPlaceLayers.tsx +14 -15
- package/lib/map/ResultCamera.tsx +10 -31
- package/lib/map/ResultOverlay.tsx +14 -16
- package/lib/map/ResultPanel.tsx +1 -20
- package/lib/map/VersionPicker.tsx +10 -19
- package/lib/map/fake-runtime.ts +46 -19
- package/lib/map/geometry.ts +14 -47
- package/lib/map/graticule.ts +80 -0
- package/lib/map/map-debug.ts +4 -2
- package/lib/map/place-render.ts +30 -62
- package/lib/map/types.ts +57 -116
- package/lib/map/useCompareState.ts +5 -4
- package/lib/map/useGeocode.ts +7 -5
- package/lib/map/useMapBearing.ts +13 -13
- package/lib/map/useMapLabelPick.ts +21 -30
- package/lib/map/useMapPlaceRender.ts +3 -7
- package/lib/map/usePlaceAutocomplete.ts +44 -50
- package/lib/map.ts +92 -0
- package/lib/pipeline/CandidatePicker.tsx +13 -5
- package/lib/pipeline/ConfidenceCell.tsx +2 -2
- package/lib/pipeline/FailureDiagnostic.tsx +8 -2
- package/lib/pipeline/PipelineExplorer.tsx +6 -3
- package/lib/pipeline/QueryForm.tsx +5 -2
- package/lib/pipeline/ResolvedPlace.tsx +2 -2
- package/lib/pipeline/SpanHighlight.tsx +7 -5
- package/lib/pipeline/TimingPanel.tsx +1 -1
- package/lib/pipeline/TreeView.tsx +2 -2
- package/lib/pipeline/copy.ts +22 -25
- package/lib/pipeline/presets.ts +15 -13
- package/lib/pipeline/types.ts +20 -17
- package/lib/pipeline/useParsePipeline.ts +16 -13
- package/lib/pipeline.ts +36 -0
- package/lib/poi/AbstainPanel.tsx +1 -1
- package/lib/poi/LiveResultsBlock.tsx +2 -1
- package/lib/poi/POIExplorer.tsx +29 -17
- package/lib/poi/QueryInput.tsx +1 -1
- package/lib/poi/SubjectPanel.tsx +4 -3
- package/lib/poi/runtime.ts +14 -16
- package/lib/poi/types.ts +58 -47
- package/lib/poi/usePOISearch.ts +91 -82
- package/lib/poi.ts +40 -0
- package/lib/runtime/useReleaseRuntime.ts +122 -90
- package/lib/search/SearchModal.tsx +478 -0
- package/lib/search/search.css +282 -0
- package/lib/search/types.ts +68 -0
- package/lib/search.ts +11 -0
- package/out/common/About.d.ts +6 -6
- package/out/common/About.d.ts.map +1 -1
- package/out/common/About.js +1 -1
- package/out/common/About.js.map +1 -1
- package/out/common/ClientOnly.d.ts +2 -11
- package/out/common/ClientOnly.d.ts.map +1 -1
- package/out/common/ClientOnly.js +1 -13
- 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/LoadingIndicator.d.ts +13 -5
- package/out/common/LoadingIndicator.d.ts.map +1 -1
- package/out/common/LoadingIndicator.js.map +1 -1
- package/out/common/PresetChips.d.ts +11 -8
- package/out/common/PresetChips.d.ts.map +1 -1
- package/out/common/PresetChips.js.map +1 -1
- package/out/common/confidence-tiers.d.ts +8 -7
- package/out/common/confidence-tiers.d.ts.map +1 -1
- package/out/common/confidence-tiers.js +7 -6
- package/out/common/confidence-tiers.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/text-tokens.d.ts +6 -11
- package/out/common/text-tokens.d.ts.map +1 -1
- package/out/common/text-tokens.js +6 -3
- package/out/common/text-tokens.js.map +1 -1
- package/out/common/useBuildInfo.d.ts +27 -0
- package/out/common/useBuildInfo.d.ts.map +1 -0
- package/out/common/useBuildInfo.js +32 -0
- package/out/common/useBuildInfo.js.map +1 -0
- package/out/common/useClipboard.d.ts +1 -3
- package/out/common/useClipboard.d.ts.map +1 -1
- package/out/common/useClipboard.js +2 -11
- package/out/common/useClipboard.js.map +1 -1
- package/out/common.d.ts +22 -0
- package/out/common.d.ts.map +1 -0
- package/out/common.js +15 -0
- package/out/common.js.map +1 -0
- package/out/index.d.ts +26 -16
- package/out/index.d.ts.map +1 -1
- package/out/index.js +21 -15
- package/out/index.js.map +1 -1
- package/out/map/AppIdentity.d.ts +46 -0
- package/out/map/AppIdentity.d.ts.map +1 -0
- package/out/map/AppIdentity.js +16 -0
- package/out/map/AppIdentity.js.map +1 -0
- package/out/map/CompareToggle.d.ts +8 -31
- package/out/map/CompareToggle.d.ts.map +1 -1
- package/out/map/CompareToggle.js +4 -1
- package/out/map/CompareToggle.js.map +1 -1
- package/out/map/DebugInfo.d.ts +27 -0
- package/out/map/DebugInfo.d.ts.map +1 -0
- package/out/map/DebugInfo.js +36 -0
- package/out/map/DebugInfo.js.map +1 -0
- package/out/map/Geocoder.d.ts +41 -30
- package/out/map/Geocoder.d.ts.map +1 -1
- package/out/map/Geocoder.js +23 -37
- package/out/map/Geocoder.js.map +1 -1
- package/out/map/GeocoderControls.d.ts +15 -44
- package/out/map/GeocoderControls.d.ts.map +1 -1
- package/out/map/GeocoderControls.js +250 -39
- package/out/map/GeocoderControls.js.map +1 -1
- package/out/map/GraticuleLayer.d.ts +30 -0
- package/out/map/GraticuleLayer.d.ts.map +1 -0
- package/out/map/GraticuleLayer.js +25 -0
- package/out/map/GraticuleLayer.js.map +1 -0
- package/out/map/MapCanvas.d.ts +26 -13
- package/out/map/MapCanvas.d.ts.map +1 -1
- package/out/map/MapCanvas.js +5 -2
- package/out/map/MapCanvas.js.map +1 -1
- package/out/map/MapChipRow.d.ts +4 -8
- package/out/map/MapChipRow.d.ts.map +1 -1
- package/out/map/MapChipRow.js.map +1 -1
- package/out/map/MapCompass.d.ts +14 -21
- package/out/map/MapCompass.d.ts.map +1 -1
- package/out/map/MapCompass.js +5 -1
- package/out/map/MapCompass.js.map +1 -1
- package/out/map/MapControlStack.d.ts +11 -10
- package/out/map/MapControlStack.d.ts.map +1 -1
- package/out/map/MapControlStack.js +4 -1
- package/out/map/MapControlStack.js.map +1 -1
- package/out/map/MapFooter.d.ts +5 -16
- package/out/map/MapFooter.d.ts.map +1 -1
- package/out/map/MapFooter.js +0 -14
- package/out/map/MapFooter.js.map +1 -1
- package/out/map/MapProgressBar.d.ts +10 -13
- package/out/map/MapProgressBar.d.ts.map +1 -1
- package/out/map/MapProgressBar.js.map +1 -1
- package/out/map/MapSearchBar.d.ts +16 -17
- package/out/map/MapSearchBar.d.ts.map +1 -1
- package/out/map/MapSearchBar.js +6 -0
- package/out/map/MapSearchBar.js.map +1 -1
- package/out/map/MapSheet.d.ts +15 -12
- package/out/map/MapSheet.d.ts.map +1 -1
- package/out/map/MapSheet.js +8 -12
- package/out/map/MapSheet.js.map +1 -1
- package/out/map/OverlayLayers.d.ts +8 -2
- package/out/map/OverlayLayers.d.ts.map +1 -1
- package/out/map/OverlayLayers.js +3 -3
- package/out/map/OverlayLayers.js.map +1 -1
- package/out/map/PlaceAutocomplete.d.ts +12 -21
- package/out/map/PlaceAutocomplete.d.ts.map +1 -1
- package/out/map/PlaceAutocomplete.js +2 -1
- package/out/map/PlaceAutocomplete.js.map +1 -1
- package/out/map/PlaceMarker.d.ts +10 -4
- package/out/map/PlaceMarker.d.ts.map +1 -1
- package/out/map/PlaceMarker.js +3 -1
- package/out/map/PlaceMarker.js.map +1 -1
- package/out/map/ResolvedPlaceLayers.d.ts +14 -15
- package/out/map/ResolvedPlaceLayers.d.ts.map +1 -1
- package/out/map/ResolvedPlaceLayers.js +1 -1
- package/out/map/ResolvedPlaceLayers.js.map +1 -1
- package/out/map/ResultCamera.d.ts +10 -31
- package/out/map/ResultCamera.d.ts.map +1 -1
- package/out/map/ResultCamera.js +3 -28
- package/out/map/ResultCamera.js.map +1 -1
- package/out/map/ResultOverlay.d.ts +14 -16
- package/out/map/ResultOverlay.d.ts.map +1 -1
- package/out/map/ResultOverlay.js +1 -2
- package/out/map/ResultOverlay.js.map +1 -1
- package/out/map/ResultPanel.d.ts +1 -20
- package/out/map/ResultPanel.d.ts.map +1 -1
- package/out/map/ResultPanel.js.map +1 -1
- package/out/map/VersionPicker.d.ts +7 -19
- package/out/map/VersionPicker.d.ts.map +1 -1
- package/out/map/VersionPicker.js +5 -2
- package/out/map/VersionPicker.js.map +1 -1
- package/out/map/fake-runtime.d.ts +9 -11
- package/out/map/fake-runtime.d.ts.map +1 -1
- package/out/map/fake-runtime.js +45 -19
- package/out/map/fake-runtime.js.map +1 -1
- package/out/map/geometry.d.ts +13 -34
- package/out/map/geometry.d.ts.map +1 -1
- package/out/map/geometry.js +9 -34
- package/out/map/geometry.js.map +1 -1
- package/out/map/graticule.d.ts +17 -0
- package/out/map/graticule.d.ts.map +1 -0
- package/out/map/graticule.js +67 -0
- package/out/map/graticule.js.map +1 -0
- package/out/map/map-debug.d.ts +4 -2
- package/out/map/map-debug.d.ts.map +1 -1
- package/out/map/map-debug.js +1 -1
- package/out/map/map-debug.js.map +1 -1
- package/out/map/place-render.d.ts +25 -45
- package/out/map/place-render.d.ts.map +1 -1
- package/out/map/place-render.js +4 -39
- package/out/map/place-render.js.map +1 -1
- package/out/map/types.d.ts +57 -113
- package/out/map/types.d.ts.map +1 -1
- package/out/map/types.js +1 -10
- package/out/map/types.js.map +1 -1
- package/out/map/useCompareState.d.ts +5 -4
- package/out/map/useCompareState.d.ts.map +1 -1
- package/out/map/useCompareState.js +3 -3
- package/out/map/useCompareState.js.map +1 -1
- package/out/map/useGeocode.d.ts +5 -3
- package/out/map/useGeocode.d.ts.map +1 -1
- package/out/map/useGeocode.js +4 -4
- package/out/map/useGeocode.js.map +1 -1
- package/out/map/useMapBearing.d.ts +11 -11
- package/out/map/useMapBearing.d.ts.map +1 -1
- package/out/map/useMapBearing.js +6 -11
- package/out/map/useMapBearing.js.map +1 -1
- package/out/map/useMapLabelPick.d.ts +4 -14
- package/out/map/useMapLabelPick.d.ts.map +1 -1
- package/out/map/useMapLabelPick.js +21 -30
- package/out/map/useMapLabelPick.js.map +1 -1
- package/out/map/useMapPlaceRender.d.ts +3 -7
- package/out/map/useMapPlaceRender.d.ts.map +1 -1
- package/out/map/useMapPlaceRender.js +2 -6
- package/out/map/useMapPlaceRender.js.map +1 -1
- package/out/map/usePlaceAutocomplete.d.ts +30 -28
- package/out/map/usePlaceAutocomplete.d.ts.map +1 -1
- package/out/map/usePlaceAutocomplete.js +6 -33
- package/out/map/usePlaceAutocomplete.js.map +1 -1
- package/out/map.d.ts +67 -0
- package/out/map.d.ts.map +1 -0
- package/out/map.js +45 -0
- package/out/map.js.map +1 -0
- package/out/pipeline/CandidatePicker.d.ts +12 -2
- package/out/pipeline/CandidatePicker.d.ts.map +1 -1
- package/out/pipeline/CandidatePicker.js +1 -1
- package/out/pipeline/CandidatePicker.js.map +1 -1
- package/out/pipeline/ConfidenceCell.d.ts +2 -2
- package/out/pipeline/ConfidenceCell.d.ts.map +1 -1
- package/out/pipeline/ConfidenceCell.js +1 -1
- package/out/pipeline/FailureDiagnostic.d.ts +8 -2
- package/out/pipeline/FailureDiagnostic.d.ts.map +1 -1
- package/out/pipeline/FailureDiagnostic.js +3 -0
- package/out/pipeline/FailureDiagnostic.js.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/QueryForm.d.ts +5 -2
- package/out/pipeline/QueryForm.d.ts.map +1 -1
- package/out/pipeline/QueryForm.js.map +1 -1
- package/out/pipeline/ResolvedPlace.d.ts +1 -1
- package/out/pipeline/ResolvedPlace.d.ts.map +1 -1
- package/out/pipeline/SpanHighlight.d.ts +4 -3
- package/out/pipeline/SpanHighlight.d.ts.map +1 -1
- package/out/pipeline/SpanHighlight.js +3 -2
- package/out/pipeline/SpanHighlight.js.map +1 -1
- package/out/pipeline/TimingPanel.d.ts +1 -1
- package/out/pipeline/TreeView.d.ts +1 -1
- package/out/pipeline/TreeView.js.map +1 -1
- package/out/pipeline/copy.d.ts +1 -1
- package/out/pipeline/copy.d.ts.map +1 -1
- package/out/pipeline/copy.js +4 -3
- package/out/pipeline/copy.js.map +1 -1
- package/out/pipeline/presets.d.ts +5 -4
- package/out/pipeline/presets.d.ts.map +1 -1
- package/out/pipeline/presets.js +15 -13
- package/out/pipeline/presets.js.map +1 -1
- package/out/pipeline/types.d.ts +20 -17
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/pipeline/types.js +2 -4
- package/out/pipeline/types.js.map +1 -1
- package/out/pipeline/useParsePipeline.d.ts +14 -9
- package/out/pipeline/useParsePipeline.d.ts.map +1 -1
- package/out/pipeline/useParsePipeline.js +7 -8
- package/out/pipeline/useParsePipeline.js.map +1 -1
- package/out/pipeline.d.ts +33 -0
- package/out/pipeline.d.ts.map +1 -0
- package/out/pipeline.js +21 -0
- package/out/pipeline.js.map +1 -0
- package/out/poi/AbstainPanel.d.ts +1 -1
- package/out/poi/LiveResultsBlock.d.ts +2 -1
- package/out/poi/LiveResultsBlock.d.ts.map +1 -1
- package/out/poi/LiveResultsBlock.js.map +1 -1
- package/out/poi/POIExplorer.d.ts +22 -12
- package/out/poi/POIExplorer.d.ts.map +1 -1
- package/out/poi/POIExplorer.js +11 -10
- package/out/poi/POIExplorer.js.map +1 -1
- package/out/poi/QueryInput.d.ts +1 -1
- package/out/poi/SubjectPanel.d.ts +2 -2
- package/out/poi/SubjectPanel.d.ts.map +1 -1
- package/out/poi/SubjectPanel.js +2 -1
- package/out/poi/SubjectPanel.js.map +1 -1
- package/out/poi/runtime.d.ts +5 -14
- package/out/poi/runtime.d.ts.map +1 -1
- package/out/poi/runtime.js +14 -16
- package/out/poi/runtime.js.map +1 -1
- package/out/poi/types.d.ts +53 -45
- package/out/poi/types.d.ts.map +1 -1
- package/out/poi/types.js +2 -4
- package/out/poi/types.js.map +1 -1
- package/out/poi/usePOISearch.d.ts +30 -17
- package/out/poi/usePOISearch.d.ts.map +1 -1
- package/out/poi/usePOISearch.js +48 -64
- package/out/poi/usePOISearch.js.map +1 -1
- package/out/poi.d.ts +23 -0
- package/out/poi.d.ts.map +1 -0
- package/out/poi.js +15 -0
- package/out/poi.js.map +1 -0
- package/out/runtime/useReleaseRuntime.d.ts +63 -74
- package/out/runtime/useReleaseRuntime.d.ts.map +1 -1
- package/out/runtime/useReleaseRuntime.js +31 -32
- package/out/runtime/useReleaseRuntime.js.map +1 -1
- package/out/{runtime/index.d.ts → runtime.d.ts} +1 -1
- package/out/runtime.d.ts.map +1 -0
- package/out/{runtime/index.js → runtime.js} +1 -1
- package/out/runtime.js.map +1 -0
- package/out/search/SearchModal.d.ts +40 -0
- package/out/search/SearchModal.d.ts.map +1 -0
- package/out/search/SearchModal.js +255 -0
- package/out/search/SearchModal.js.map +1 -0
- package/out/search/types.d.ts +65 -0
- package/out/search/types.d.ts.map +1 -0
- package/out/search/types.js +13 -0
- package/out/search/types.js.map +1 -0
- package/out/search.d.ts +11 -0
- package/out/search.d.ts.map +1 -0
- package/out/search.js +9 -0
- package/out/search.js.map +1 -0
- package/package.json +73 -165
- package/styles.css +482 -266
- package/tokens/index.css +24 -6
- package/tokens/tokens.json +114 -6
- package/lib/common/index.ts +0 -22
- package/lib/map/BackendControl.tsx +0 -51
- package/lib/map/index.ts +0 -95
- package/lib/pipeline/index.ts +0 -36
- package/lib/poi/index.ts +0 -39
- package/out/common/index.d.ts +0 -22
- package/out/common/index.d.ts.map +0 -1
- package/out/common/index.js +0 -15
- package/out/common/index.js.map +0 -1
- package/out/map/BackendControl.d.ts +0 -32
- 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/out/map/index.d.ts +0 -69
- package/out/map/index.d.ts.map +0 -1
- package/out/map/index.js +0 -46
- package/out/map/index.js.map +0 -1
- package/out/pipeline/index.d.ts +0 -33
- package/out/pipeline/index.d.ts.map +0 -1
- package/out/pipeline/index.js +0 -21
- package/out/pipeline/index.js.map +0 -1
- package/out/poi/index.d.ts +0 -23
- package/out/poi/index.d.ts.map +0 -1
- package/out/poi/index.js +0 -15
- package/out/poi/index.js.map +0 -1
- package/out/runtime/index.d.ts.map +0 -1
- package/out/runtime/index.js.map +0 -1
- package/styleframe.config.ts +0 -329
- package/vitest.node.config.ts +0 -20
- /package/lib/{runtime/index.ts → runtime.ts} +0 -0
package/lib/pipeline/copy.ts
CHANGED
|
@@ -4,34 +4,31 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
6
|
* Builds the "Copy JSON" payload for a parse result — the components + the selected resolved place,
|
|
7
|
-
* pretty-printed. Pure
|
|
7
|
+
* pretty-printed. Pure. shared by the explorer's copy button.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { prettyJSON } from "@mailwoman/core/json"
|
|
10
11
|
import type { ParseResult, ResolvedPlaceView } from "@mailwoman/core/pipeline/client-result"
|
|
11
12
|
|
|
12
13
|
export function buildParsePayload(result: ParseResult, selected: ResolvedPlaceView | null): string {
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
null,
|
|
35
|
-
2
|
|
36
|
-
)
|
|
14
|
+
return prettyJSON({
|
|
15
|
+
input: result.input,
|
|
16
|
+
components: result.nodes.map((node) => ({
|
|
17
|
+
tag: node.tag,
|
|
18
|
+
value: node.value ?? null,
|
|
19
|
+
confidence: node.confidence ?? null,
|
|
20
|
+
start: node.start ?? null,
|
|
21
|
+
end: node.end ?? null,
|
|
22
|
+
})),
|
|
23
|
+
resolved: selected
|
|
24
|
+
? {
|
|
25
|
+
name: selected.name,
|
|
26
|
+
placetype: selected.placetype,
|
|
27
|
+
id: selected.id,
|
|
28
|
+
lat: selected.lat,
|
|
29
|
+
lon: selected.lon,
|
|
30
|
+
score: selected.score,
|
|
31
|
+
}
|
|
32
|
+
: null,
|
|
33
|
+
})
|
|
37
34
|
}
|
package/lib/pipeline/presets.ts
CHANGED
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Default query + example addresses for the pipeline explorer. Hosts can override via props
|
|
6
|
+
* Default query + example addresses for the pipeline explorer. Hosts can override via props. These
|
|
7
7
|
* mirror the docs demo's set so the extracted component looks identical out of the box.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { Preset } from "../common/PresetChips.tsx"
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Address the pipeline explorer opens on.
|
|
14
|
-
*
|
|
13
|
+
* Address the pipeline explorer opens on.
|
|
14
|
+
*
|
|
15
|
+
* It exercises every stage (house number, street, directional, locality and region) in one line.
|
|
15
16
|
*/
|
|
16
17
|
export const PIPELINE_DEFAULT_ADDRESS = "1600 Pennsylvania Ave NW, Washington, DC 20500"
|
|
17
18
|
|
|
18
|
-
// `country` mirrors the docs `EXAMPLE_ADDRESSES` set
|
|
19
|
-
//
|
|
20
|
-
// locale structural routing can't detect (NZ) still fires; free-typed input drops to structural detection.
|
|
19
|
+
// `country` mirrors the docs `EXAMPLE_ADDRESSES` set and is kept in parity.
|
|
20
|
+
// A host that wires the pair prior pins the country while the input equals the preset text.
|
|
21
21
|
/**
|
|
22
|
-
* Preset inputs offered in the explorer, each picked to show a different parse
|
|
22
|
+
* Preset inputs offered in the explorer, each picked to show a different parse behavior.
|
|
23
23
|
*/
|
|
24
24
|
export const PIPELINE_PRESETS: ReadonlyArray<Preset> = [
|
|
25
25
|
{ label: "White House", value: "1600 Pennsylvania Ave NW, Washington, DC 20500", country: "us" },
|
|
@@ -32,16 +32,18 @@ export const PIPELINE_PRESETS: ReadonlyArray<Preset> = [
|
|
|
32
32
|
{ label: "Berlin (native order)", value: "Straußstraße 27, 12623 Berlin", country: "de" },
|
|
33
33
|
{ label: "Berlin city-state (int'l order)", value: "5 Hauptstraße, Berlin, Berlin 10115", country: "de" },
|
|
34
34
|
{ label: "Paris (street fall-through)", value: "181 Rue du Chevaleret, Paris", country: "fr" },
|
|
35
|
-
//
|
|
36
|
-
//
|
|
35
|
+
// "Henbury" flips to dependent_locality via the en-gb pair-index prior.
|
|
36
|
+
// The UK postcode is structurally detectable, in parity with the docs EXAMPLE_ADDRESSES.
|
|
37
37
|
{
|
|
38
38
|
label: "Macclesfield (GB dependent_locality)",
|
|
39
39
|
value: "41 Hightree Drive, Henbury, Macclesfield, SK11 9PD",
|
|
40
40
|
country: "gb",
|
|
41
41
|
},
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
// "
|
|
45
|
-
//
|
|
42
|
+
// Plimmerton is a suburb (dependent_locality) of Porirua.
|
|
43
|
+
// The postcode is deliberately omitted, since a trailing "Porirua 5026" folds "porirua
|
|
44
|
+
// 5026" in segment mode and misses the index's bare "porirua" key.
|
|
45
|
+
// The `country: "nz"` pin is required, since locale-hint cannot structurally
|
|
46
|
+
// detect NZ (a 4-digit postcode is not distinctive).
|
|
47
|
+
// Only the pin selects the nz index.
|
|
46
48
|
{ label: "Plimmerton (NZ dependent_locality)", value: "35 Steyne Avenue, Plimmerton, Porirua", country: "nz" },
|
|
47
49
|
]
|
package/lib/pipeline/types.ts
CHANGED
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* Types for the pipeline (parse + resolve) explorer. The
|
|
7
|
-
*
|
|
8
|
-
* (the docs site's RuntimeEmbed, or any app) owns loading ONNX/WOF and executing a parse. That keeps
|
|
9
|
-
* onnxruntime-web, sql.js-httpvfs, and node builtins entirely out of this package's browser graph.
|
|
6
|
+
* Types for the pipeline (parse + resolve) explorer. The runtime is injected as a {@link PipelineRuntime},
|
|
7
|
+
* keeping onnxruntime-web, sqlite-wasm and node builtins out of this package's browser graph.
|
|
10
8
|
*/
|
|
11
9
|
|
|
12
10
|
import type { ParseResult } from "@mailwoman/core/pipeline/client-result"
|
|
@@ -19,11 +17,20 @@ export interface PipelineLoadingState {
|
|
|
19
17
|
progress?: string
|
|
20
18
|
stepLabels: string[]
|
|
21
19
|
stepIndex: number
|
|
20
|
+
/**
|
|
21
|
+
* Bytes received over bytes expected for the asset being fetched right now, in [0, 1],
|
|
22
|
+
* or `null` when no download is in progress or the response declares no length.
|
|
23
|
+
*
|
|
24
|
+
* The step index cannot report this download because the model is fetched before the first step begins.
|
|
25
|
+
*/
|
|
26
|
+
byteFraction?: number | null
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
/**
|
|
25
|
-
* The injected parse runtime.
|
|
26
|
-
*
|
|
30
|
+
* The injected parse runtime.
|
|
31
|
+
*
|
|
32
|
+
* The host implements this interface and supplies the model and gazetteer,
|
|
33
|
+
* keeping both imports out of this package.
|
|
27
34
|
*/
|
|
28
35
|
export interface PipelineRuntime {
|
|
29
36
|
/**
|
|
@@ -31,7 +38,8 @@ export interface PipelineRuntime {
|
|
|
31
38
|
*/
|
|
32
39
|
ready: boolean
|
|
33
40
|
/**
|
|
34
|
-
* Execute a full parse+resolve, reporting stage progress via `onStage`
|
|
41
|
+
* Execute a full parse+resolve, reporting stage progress via `onStage`
|
|
42
|
+
* (0-based index into `parseStageLabels`).
|
|
35
43
|
*/
|
|
36
44
|
runParse: (input: string, hooks: { onStage: (stage: number) => void }) => Promise<ParseResult>
|
|
37
45
|
/**
|
|
@@ -49,27 +57,22 @@ export interface PipelineRuntime {
|
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
/**
|
|
52
|
-
* Optional host-injected panels
|
|
53
|
-
*
|
|
54
|
-
* components nor their heavy data types.
|
|
60
|
+
* Optional host-injected panels, kept as `ReactNode` thunks so this package needs
|
|
61
|
+
* neither the host's components nor their data types.
|
|
55
62
|
*/
|
|
56
63
|
export interface PipelinePanels {
|
|
57
64
|
/**
|
|
58
|
-
* Rendered above the form
|
|
65
|
+
* Rendered above the form.
|
|
59
66
|
*/
|
|
60
67
|
header?: ReactNode
|
|
61
68
|
/**
|
|
62
|
-
* Rendered below everything
|
|
69
|
+
* Rendered below everything.
|
|
63
70
|
*/
|
|
64
71
|
footer?: ReactNode
|
|
65
72
|
/**
|
|
66
73
|
* Model-version selector, wired to the host's bundle state.
|
|
67
74
|
*/
|
|
68
75
|
versionControl?: ReactNode
|
|
69
|
-
/**
|
|
70
|
-
* Backend indicator + WASM toggle.
|
|
71
|
-
*/
|
|
72
|
-
backendControl?: ReactNode
|
|
73
76
|
/**
|
|
74
77
|
* One-line release blurb.
|
|
75
78
|
*/
|
|
@@ -79,7 +82,7 @@ export interface PipelinePanels {
|
|
|
79
82
|
*/
|
|
80
83
|
extras?: (result: ParseResult) => ReactNode
|
|
81
84
|
/**
|
|
82
|
-
* Rendered in place of the resolved-place panel when
|
|
85
|
+
* Rendered in place of the resolved-place panel when no place resolved (host's FailureDiagnostic).
|
|
83
86
|
*/
|
|
84
87
|
failure?: (result: ParseResult) => ReactNode
|
|
85
88
|
}
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* to the injected {@link PipelineRuntime}. No model or gazetteer code lives here — it just drives the
|
|
9
|
-
* contract and shapes the UI state.
|
|
6
|
+
* The headless core of the pipeline explorer. It owns query text, busy/stage flags, result and candidate selection.
|
|
7
|
+
* It delegates parse and resolve to the injected {@link PipelineRuntime}.
|
|
10
8
|
*/
|
|
11
9
|
|
|
12
10
|
import type { ParseResult, ResolvedPlaceView } from "@mailwoman/core/pipeline/client-result"
|
|
@@ -14,11 +12,17 @@ import { useCallback, useState } from "react"
|
|
|
14
12
|
|
|
15
13
|
import type { PipelineRuntime } from "#pipeline/types"
|
|
16
14
|
|
|
15
|
+
/**
|
|
16
|
+
* The runtime and starting text for {@link useParsePipeline}.
|
|
17
|
+
*/
|
|
17
18
|
export interface UseParsePipelineOptions {
|
|
18
19
|
runtime: PipelineRuntime
|
|
19
20
|
defaultText: string
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
/**
|
|
24
|
+
* The state and handlers that {@link useParsePipeline} returns.
|
|
25
|
+
*/
|
|
22
26
|
export interface UseParsePipeline {
|
|
23
27
|
text: string
|
|
24
28
|
setText: (text: string) => void
|
|
@@ -36,18 +40,19 @@ export interface UseParsePipeline {
|
|
|
36
40
|
*/
|
|
37
41
|
selectedCandidate: ResolvedPlaceView | null
|
|
38
42
|
/**
|
|
39
|
-
* Parse and resolve the current text
|
|
40
|
-
*
|
|
41
|
-
* Pass `query` to submit a value the field has not re-rendered with yet — a preset press sets the text and submits in
|
|
42
|
-
* one handler, and that state update is not visible to this call.
|
|
43
|
+
* Parse and resolve the current text, safe to bind to a form's `onSubmit`;
|
|
44
|
+
* pass `query` to submit a value the field has not re-rendered with yet.
|
|
43
45
|
*/
|
|
44
46
|
submit: (query?: string) => Promise<void>
|
|
45
47
|
/**
|
|
46
|
-
* Clear the result
|
|
48
|
+
* Clear the result, used when a preset replaces the input.
|
|
47
49
|
*/
|
|
48
50
|
reset: () => void
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Drives the injected runtime and exposes the explorer's UI state.
|
|
55
|
+
*/
|
|
51
56
|
export function useParsePipeline({ runtime, defaultText }: UseParsePipelineOptions): UseParsePipeline {
|
|
52
57
|
const [text, setText] = useState(defaultText)
|
|
53
58
|
const [busy, setBusy] = useState(false)
|
|
@@ -56,9 +61,8 @@ export function useParsePipeline({ runtime, defaultText }: UseParsePipelineOptio
|
|
|
56
61
|
const [selectedCandidateIndex, setSelectedCandidateIndex] = useState(0)
|
|
57
62
|
const [parseError, setParseError] = useState<string | null>(null)
|
|
58
63
|
|
|
59
|
-
// `
|
|
60
|
-
//
|
|
61
|
-
// address before it. A caller that already knows the query passes it; the field's own submit passes nothing.
|
|
64
|
+
// `setText` does not reach this closure before the call after it runs,
|
|
65
|
+
// so a caller that already knows the query passes it.
|
|
62
66
|
const submit = useCallback(
|
|
63
67
|
async (query?: string) => {
|
|
64
68
|
if (!runtime.ready || busy) return
|
|
@@ -85,7 +89,6 @@ export function useParsePipeline({ runtime, defaultText }: UseParsePipelineOptio
|
|
|
85
89
|
|
|
86
90
|
const reset = useCallback(() => setResult(null), [])
|
|
87
91
|
|
|
88
|
-
// Derived during render — no effect needed.
|
|
89
92
|
const selectedCandidate = result ? (result.candidates[selectedCandidateIndex] ?? result.candidates[0] ?? null) : null
|
|
90
93
|
|
|
91
94
|
return {
|
package/lib/pipeline.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file Pipeline explorer components, visualizers, hooks and interfaces.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export { About } from "./common/About.tsx"
|
|
9
|
+
export { FailureDiagnostic } from "./pipeline/FailureDiagnostic.tsx"
|
|
10
|
+
export type { FailureDiagnosticProps } from "./pipeline/FailureDiagnostic.tsx"
|
|
11
|
+
export { SpanHighlight } from "./pipeline/SpanHighlight.tsx"
|
|
12
|
+
export type { SpanHighlightProps } from "./pipeline/SpanHighlight.tsx"
|
|
13
|
+
export { TimingPanel } from "./pipeline/TimingPanel.tsx"
|
|
14
|
+
export type { TimingPanelProps } from "./pipeline/TimingPanel.tsx"
|
|
15
|
+
export { TreeView } from "./pipeline/TreeView.tsx"
|
|
16
|
+
export type { TreeViewProps } from "./pipeline/TreeView.tsx"
|
|
17
|
+
|
|
18
|
+
export { CandidatePicker } from "./pipeline/CandidatePicker.tsx"
|
|
19
|
+
export type { CandidatePickerProps } from "./pipeline/CandidatePicker.tsx"
|
|
20
|
+
export { ComponentTable } from "./pipeline/ComponentTable.tsx"
|
|
21
|
+
export type { ComponentTableProps } from "./pipeline/ComponentTable.tsx"
|
|
22
|
+
export { ConfidenceCell } from "./pipeline/ConfidenceCell.tsx"
|
|
23
|
+
export type { ConfidenceCellProps } from "./pipeline/ConfidenceCell.tsx"
|
|
24
|
+
export { buildParsePayload } from "#pipeline/copy"
|
|
25
|
+
export { PIPELINE_DEFAULT_ADDRESS, PIPELINE_PRESETS } from "#pipeline/presets"
|
|
26
|
+
export { PipelineExplorer } from "./pipeline/PipelineExplorer.tsx"
|
|
27
|
+
export type { PipelineExplorerProps } from "./pipeline/PipelineExplorer.tsx"
|
|
28
|
+
export { QueryForm } from "./pipeline/QueryForm.tsx"
|
|
29
|
+
export type { QueryFormProps } from "./pipeline/QueryForm.tsx"
|
|
30
|
+
export { ResolvedPlace } from "./pipeline/ResolvedPlace.tsx"
|
|
31
|
+
export type { ResolvedPlaceProps } from "./pipeline/ResolvedPlace.tsx"
|
|
32
|
+
|
|
33
|
+
export type { PipelineLoadingState, PipelinePanels, PipelineRuntime } from "#pipeline/types"
|
|
34
|
+
|
|
35
|
+
export { useParsePipeline } from "#pipeline/useParsePipeline"
|
|
36
|
+
export type { UseParsePipeline, UseParsePipelineOptions } from "#pipeline/useParsePipeline"
|
package/lib/poi/AbstainPanel.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* `AbstainPanel` — shown when the query
|
|
6
|
+
* `AbstainPanel` — shown when the query has no POI intent (it parses as an address). Names the
|
|
7
7
|
* classifier's kind so the abstention is legible. Presentational.
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -15,7 +15,8 @@ import type { LiveSearchState } from "#poi/types"
|
|
|
15
15
|
|
|
16
16
|
export interface LiveResultsBlockProps {
|
|
17
17
|
/**
|
|
18
|
-
* Subject label for empty-state copy — a category ("No hospital results near …")
|
|
18
|
+
* Subject label for empty-state copy — a category ("No hospital results near …")
|
|
19
|
+
* or a brand ("No chevron results …").
|
|
19
20
|
*/
|
|
20
21
|
subjectLabel: string
|
|
21
22
|
/**
|
package/lib/poi/POIExplorer.tsx
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* `POIExplorer` — the composed POI-intent tester. Detects a POI subject in free text, shows the
|
|
7
|
-
* category + OverpassQL export, and (when a live-search probe is injected) searches the published
|
|
8
|
-
* poi.db layer. The intent path is self-contained — no weights, no network. All runtime concerns are
|
|
9
|
-
* in {@link usePOISearch}; this file is composition + a `ClientOnly` SSR boundary.
|
|
10
5
|
*/
|
|
11
6
|
|
|
12
7
|
import { type ReactNode, useState } from "react"
|
|
@@ -24,27 +19,35 @@ import { OverpassBlock } from "./OverpassBlock.tsx"
|
|
|
24
19
|
import { QueryInput } from "./QueryInput.tsx"
|
|
25
20
|
import { SubjectPanel } from "./SubjectPanel.tsx"
|
|
26
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Props for {@linkcode POIExplorer}.
|
|
24
|
+
*/
|
|
27
25
|
export interface POIExplorerProps {
|
|
28
26
|
/**
|
|
29
|
-
*
|
|
27
|
+
* The query that pre-fills the input.
|
|
30
28
|
*/
|
|
31
29
|
defaultText?: string
|
|
32
30
|
/**
|
|
33
|
-
*
|
|
31
|
+
* The example chips.
|
|
32
|
+
*
|
|
33
|
+
* @defaultValue POI_PRESETS
|
|
34
34
|
*/
|
|
35
35
|
presets?: ReadonlyArray<Preset>
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* A replacement loader for the taxonomy runtime, such as a mock in stories and tests.
|
|
38
38
|
*/
|
|
39
39
|
loadRuntime?: LoadPOIRuntime
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* The live poi.db search.
|
|
42
|
+
* Without it, the explorer shows only the detected intent.
|
|
42
43
|
*/
|
|
43
44
|
runLiveSearch?: POILiveSearch
|
|
44
45
|
/**
|
|
45
|
-
* Whether {@link runLiveSearch} can
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* Whether {@link runLiveSearch} can search brand subjects by Wikidata QID.
|
|
47
|
+
*
|
|
48
|
+
* When it is false, a brand subject shows its intent and QID chip without a live block.
|
|
49
|
+
* A byte-range probe over httpvfs should leave it off because a brand-wide
|
|
50
|
+
* lookup reads too much of the database.
|
|
48
51
|
*/
|
|
49
52
|
brandLiveSearch?: boolean
|
|
50
53
|
}
|
|
@@ -72,13 +75,12 @@ function POIExplorerInner({
|
|
|
72
75
|
|
|
73
76
|
const subject = result?.subject
|
|
74
77
|
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
// hint, so it must show one step earlier). Category: not build-local. Brand: brand-capable probe + a QID.
|
|
78
|
+
// A category is searchable unless it is build-local.
|
|
79
|
+
// A brand needs a QID and a brand-capable probe.
|
|
78
80
|
const showLiveBlock = Boolean(
|
|
79
81
|
runLiveSearch &&
|
|
80
82
|
subject &&
|
|
81
|
-
(subject.kind === "brand" ? brandLiveSearch && subject.wikidata !==
|
|
83
|
+
(subject.kind === "brand" ? brandLiveSearch && subject.wikidata !== null : !subject.buildLocal)
|
|
82
84
|
)
|
|
83
85
|
|
|
84
86
|
return (
|
|
@@ -94,7 +96,10 @@ function POIExplorerInner({
|
|
|
94
96
|
<>
|
|
95
97
|
<SubjectPanel subject={subject} />
|
|
96
98
|
{subject.kind === "category" ? (
|
|
97
|
-
<OverpassBlock
|
|
99
|
+
<OverpassBlock
|
|
100
|
+
overpassQL={result.overpassQL ?? undefined}
|
|
101
|
+
overpassError={result.overpassError ?? undefined}
|
|
102
|
+
/>
|
|
98
103
|
) : null}
|
|
99
104
|
|
|
100
105
|
{showLiveBlock ? (
|
|
@@ -115,6 +120,13 @@ function POIExplorerInner({
|
|
|
115
120
|
)
|
|
116
121
|
}
|
|
117
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Renders a POI-intent tester that detects a POI subject in free text.
|
|
125
|
+
*
|
|
126
|
+
* It shows the matched category or brand and, for categories, an OverpassQL export.
|
|
127
|
+
* When `runLiveSearch` is set, it can also search the published poi.db.
|
|
128
|
+
* It renders only on the client.
|
|
129
|
+
*/
|
|
118
130
|
export function POIExplorer({
|
|
119
131
|
defaultText = POI_DEFAULT_TEXT,
|
|
120
132
|
presets = POI_PRESETS,
|
package/lib/poi/QueryInput.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* `QueryInput` — the
|
|
6
|
+
* `QueryInput` — the labeled text field for the POI explorer. Controlled. presentational only.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { ReactNode } from "react"
|
package/lib/poi/SubjectPanel.tsx
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
* `SubjectPanel` — renders the detected POI subject. For a
|
|
7
|
-
* build-local badge + note. For a
|
|
6
|
+
* `SubjectPanel` — renders the detected POI subject. For a category: the category chip, the optional
|
|
7
|
+
* build-local badge + note. For a brand: the brand-name chip + a Wikidata QID chip (linked). Both
|
|
8
8
|
* share the match-detail list (matched phrase, confidence, anchor). Presentational.
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -17,7 +17,8 @@ export interface SubjectPanelProps {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* The shared match-detail list (matched phrase, confidence, anchor) —
|
|
20
|
+
* The shared match-detail list (matched phrase, confidence, anchor) —
|
|
21
|
+
* identical for category + brand subjects.
|
|
21
22
|
*/
|
|
22
23
|
function MatchDetail({ subject }: SubjectPanelProps): ReactNode {
|
|
23
24
|
return (
|
package/lib/poi/runtime.ts
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The default POI runtime loader + presentation helpers. `loadPOIRuntime` dynamically imports the
|
|
7
|
-
* ~2k-record Overture taxonomy snapshot (so bundlers code-split it into its own chunk, fetched only
|
|
8
|
-
* when the explorer actually mounts) and wires the kind classifier over it. Pure + browser-safe: no
|
|
9
|
-
* network, no DOM — the whole intent path runs offline.
|
|
10
5
|
*/
|
|
11
6
|
|
|
12
7
|
import { createKindClassifier } from "@mailwoman/kind-classifier"
|
|
@@ -16,14 +11,10 @@ import { createPOIBrandLookup, createPOITaxonomyLookup } from "@mailwoman/poi-ta
|
|
|
16
11
|
import type { POIRuntime } from "#poi/types"
|
|
17
12
|
|
|
18
13
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
14
|
+
* Loads the browser POI runtime, importing the taxonomy and brand tables dynamically
|
|
15
|
+
* so they land in their own chunk instead of every consumer's bundle.
|
|
21
16
|
*
|
|
22
|
-
*
|
|
23
|
-
* matches a taxonomy CATEGORY wins (the curated set); only on a category miss does the chain-brand table fire,
|
|
24
|
-
* returning a `kind: "brand"` match carrying the brand's canonical name + Wikidata QID. (The Node path also chains
|
|
25
|
-
* `@mailwoman/variant-aliases` regional slang; the browser tester leaves that out — one fewer package + data table for
|
|
26
|
-
* a demo, and the QID-keyed brand table already covers the headline brands.)
|
|
17
|
+
* Its lexicon tries exact categories and then brands only, a subset of the Node `poiTaxonomyLookup` chain.
|
|
27
18
|
*/
|
|
28
19
|
export async function loadPOIRuntime(): Promise<POIRuntime> {
|
|
29
20
|
const [table, brandTable] = await Promise.all([
|
|
@@ -34,8 +25,6 @@ export async function loadPOIRuntime(): Promise<POIRuntime> {
|
|
|
34
25
|
const lookup = createPOITaxonomyLookup(table as Parameters<typeof createPOITaxonomyLookup>[0])
|
|
35
26
|
const brands = createPOIBrandLookup(brandTable as Parameters<typeof createPOIBrandLookup>[0])
|
|
36
27
|
|
|
37
|
-
// Adapt the taxonomy + brand lookups to the `POIPhraseLookup` shape the classifier expects: categories first, brands
|
|
38
|
-
// on a category miss.
|
|
39
28
|
const lexicon: POIPhraseLookup = (phrase, locale) => {
|
|
40
29
|
const categoryHits = lookup.lookupPOICategory(phrase, locale)
|
|
41
30
|
|
|
@@ -45,6 +34,11 @@ export async function loadPOIRuntime(): Promise<POIRuntime> {
|
|
|
45
34
|
categoryID: match.category.id,
|
|
46
35
|
matchedPhrase: match.matchedPhrase,
|
|
47
36
|
confidence: match.confidence,
|
|
37
|
+
mechanism: "exact",
|
|
38
|
+
inputPhrase: phrase,
|
|
39
|
+
wikidata: null,
|
|
40
|
+
reading: "preference",
|
|
41
|
+
countryScope: null,
|
|
48
42
|
}))
|
|
49
43
|
}
|
|
50
44
|
|
|
@@ -54,6 +48,10 @@ export async function loadPOIRuntime(): Promise<POIRuntime> {
|
|
|
54
48
|
wikidata: match.brand.wikidata,
|
|
55
49
|
matchedPhrase: match.matchedPhrase,
|
|
56
50
|
confidence: match.confidence,
|
|
51
|
+
mechanism: "exact",
|
|
52
|
+
inputPhrase: phrase,
|
|
53
|
+
reading: "preference",
|
|
54
|
+
countryScope: null,
|
|
57
55
|
}))
|
|
58
56
|
}
|
|
59
57
|
|
|
@@ -61,7 +59,7 @@ export async function loadPOIRuntime(): Promise<POIRuntime> {
|
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
/**
|
|
64
|
-
* Default example queries for the POI explorer — a mix of category, build-local
|
|
62
|
+
* Default example queries for the POI explorer — a mix of category, build-local and chain-brand subjects.
|
|
65
63
|
*/
|
|
66
64
|
export const POI_PRESETS = [
|
|
67
65
|
{ label: "Drinking fountain", value: "drinking fountain near Springfield" },
|
|
@@ -72,7 +70,7 @@ export const POI_PRESETS = [
|
|
|
72
70
|
] as const
|
|
73
71
|
|
|
74
72
|
/**
|
|
75
|
-
*
|
|
73
|
+
* Holds the query the POI explorer opens on, taken from the first preset so the two stay in step.
|
|
76
74
|
*/
|
|
77
75
|
export const POI_DEFAULT_TEXT = POI_PRESETS[0].value
|
|
78
76
|
|