@mailwoman/react 10.0.0 → 10.1.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 +17 -16
- package/fonts.css +97 -22
- package/lib/common/About.tsx +7 -7
- package/lib/common/ClientOnly.tsx +2 -14
- package/lib/common/CopyButton.tsx +3 -1
- package/lib/common/LoadingIndicator.tsx +4 -2
- package/lib/common/PresetChips.tsx +9 -8
- package/lib/common/confidence-tiers.ts +7 -6
- package/lib/common/cx.ts +3 -1
- package/lib/common/text-tokens.ts +7 -4
- 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 -17
- package/lib/map/AppIdentity.tsx +85 -0
- package/lib/map/BackendControl.tsx +9 -10
- package/lib/map/CompareToggle.tsx +8 -31
- package/lib/map/DebugInfo.tsx +88 -0
- package/lib/map/Geocoder.tsx +60 -46
- package/lib/map/GeocoderControls.tsx +430 -134
- package/lib/map/GraticuleLayer.tsx +54 -0
- package/lib/map/MapCanvas.tsx +23 -12
- package/lib/map/MapChipRow.tsx +4 -8
- package/lib/map/MapCompass.tsx +15 -24
- package/lib/map/MapControlStack.tsx +8 -9
- package/lib/map/MapFooter.tsx +2 -16
- 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 +1 -1
- package/lib/map/PlaceAutocomplete.tsx +10 -21
- package/lib/map/PlaceMarker.tsx +4 -2
- package/lib/map/ResolvedPlaceLayers.tsx +5 -14
- package/lib/map/ResultCamera.tsx +8 -31
- package/lib/map/ResultOverlay.tsx +2 -12
- package/lib/map/ResultPanel.tsx +1 -20
- package/lib/map/VersionPicker.tsx +10 -19
- package/lib/map/fake-runtime.ts +10 -12
- package/lib/map/geometry.ts +14 -47
- package/lib/map/graticule.ts +80 -0
- package/lib/map/map-debug.ts +1 -1
- package/lib/map/place-render.ts +28 -60
- package/lib/map/types.ts +58 -104
- 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 +2 -6
- package/lib/map/usePlaceAutocomplete.ts +44 -50
- package/lib/map.ts +95 -0
- package/lib/pipeline/CandidatePicker.tsx +13 -5
- package/lib/pipeline/ConfidenceCell.tsx +1 -1
- package/lib/pipeline/FailureDiagnostic.tsx +8 -2
- package/lib/pipeline/QueryForm.tsx +5 -2
- package/lib/pipeline/ResolvedPlace.tsx +1 -1
- package/lib/pipeline/SpanHighlight.tsx +7 -5
- package/lib/pipeline/TimingPanel.tsx +1 -1
- package/lib/pipeline/TreeView.tsx +1 -1
- package/lib/pipeline/copy.ts +22 -25
- package/lib/pipeline/presets.ts +15 -13
- package/lib/pipeline/types.ts +21 -14
- 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 +24 -15
- package/lib/poi/QueryInput.tsx +1 -1
- package/lib/poi/SubjectPanel.tsx +4 -3
- package/lib/poi/runtime.ts +5 -16
- package/lib/poi/types.ts +39 -27
- package/lib/poi/usePOISearch.ts +39 -44
- package/lib/poi.ts +39 -0
- package/lib/runtime/useReleaseRuntime.ts +125 -74
- package/lib/search/SearchModal.tsx +317 -0
- package/lib/search/search.css +144 -0
- package/lib/search/types.ts +67 -0
- package/lib/search.ts +11 -0
- package/out/common/About.d.ts +5 -5
- 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 +3 -1
- package/out/common/CopyButton.d.ts.map +1 -1
- package/out/common/CopyButton.js.map +1 -1
- package/out/common/LoadingIndicator.d.ts +4 -2
- package/out/common/LoadingIndicator.d.ts.map +1 -1
- package/out/common/LoadingIndicator.js.map +1 -1
- package/out/common/PresetChips.d.ts +9 -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 +7 -6
- 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 +4 -3
- 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 +42 -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/BackendControl.d.ts +9 -10
- package/out/map/BackendControl.d.ts.map +1 -1
- package/out/map/BackendControl.js +1 -1
- package/out/map/BackendControl.js.map +1 -1
- 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 +34 -0
- package/out/map/DebugInfo.d.ts.map +1 -0
- package/out/map/DebugInfo.js +39 -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 +20 -36
- package/out/map/Geocoder.js.map +1 -1
- package/out/map/GeocoderControls.d.ts +14 -42
- package/out/map/GeocoderControls.d.ts.map +1 -1
- package/out/map/GeocoderControls.js +250 -38
- package/out/map/GeocoderControls.js.map +1 -1
- package/out/map/GraticuleLayer.d.ts +28 -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 +23 -12
- 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 +11 -20
- 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 +8 -9
- 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 +2 -15
- 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 +1 -1
- package/out/map/OverlayLayers.js +1 -1
- package/out/map/PlaceAutocomplete.d.ts +10 -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 +4 -2
- 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 +5 -14
- 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 +8 -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 +2 -12
- 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 +9 -12
- 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 +1 -1
- package/out/map/map-debug.js +1 -1
- package/out/map/place-render.d.ts +23 -43
- 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 +58 -102
- 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 +2 -6
- 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 +69 -0
- package/out/map.d.ts.map +1 -0
- package/out/map.js +46 -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 +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/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/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/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 +21 -14
- 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 +9 -8
- 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 +5 -16
- package/out/poi/runtime.js.map +1 -1
- package/out/poi/types.d.ts +39 -27
- 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 +28 -17
- package/out/poi/usePOISearch.d.ts.map +1 -1
- package/out/poi/usePOISearch.js +6 -32
- 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 +64 -65
- package/out/runtime/useReleaseRuntime.d.ts.map +1 -1
- package/out/runtime/useReleaseRuntime.js +31 -26
- 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 +33 -0
- package/out/search/SearchModal.d.ts.map +1 -0
- package/out/search/SearchModal.js +187 -0
- package/out/search/SearchModal.js.map +1 -0
- package/out/search/types.d.ts +64 -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 +60 -142
- 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/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/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/out/poi/usePOISearch.js
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
|
-
* `usePOISearch` — the headless core of the POI explorer. Owns the taxonomy-runtime load, the
|
|
7
|
-
* debounced classify → subject → OverpassQL derivation, and the "Search live" state machine. The
|
|
8
|
-
* runtime loader and the live-search probe are both INJECTABLE, so stories/tests drive it with mocks
|
|
9
|
-
* and no network or db. Presentation is entirely the caller's concern.
|
|
10
5
|
*/
|
|
11
6
|
import { matchPOISubject } from "@mailwoman/kind-classifier";
|
|
12
7
|
import { emitOverpassQL } from "@mailwoman/poi-taxonomy/overpass";
|
|
@@ -14,9 +9,6 @@ import { computeQueryShape } from "@mailwoman/query-shape";
|
|
|
14
9
|
import { useCallback, useEffect, useEffectEvent, useState } from "react";
|
|
15
10
|
import { useDebouncedValue } from "#common/useDebouncedValue";
|
|
16
11
|
import { loadPOIRuntime } from "#poi/runtime";
|
|
17
|
-
/**
|
|
18
|
-
* Compute the OverpassQL export for a matched subject, capturing any emitter error rather than throwing.
|
|
19
|
-
*/
|
|
20
12
|
function buildOverpass(runtime, categoryID, matchedPhrase, remainder) {
|
|
21
13
|
const category = runtime.lookup.getPOICategory(categoryID);
|
|
22
14
|
if (!category) {
|
|
@@ -33,25 +25,18 @@ function buildOverpass(runtime, categoryID, matchedPhrase, remainder) {
|
|
|
33
25
|
return { overpassError: error instanceof Error ? error.message : String(error) };
|
|
34
26
|
}
|
|
35
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Classifies debounced query text as a POI category or brand request and runs live searches on demand.
|
|
30
|
+
*
|
|
31
|
+
* Each result is keyed to the query that produced it, live search requires a non-empty anchor.
|
|
32
|
+
* Brands need `brandLiveSearch` plus a Wikidata ID.
|
|
33
|
+
*/
|
|
36
34
|
export function usePOISearch({ text, loadRuntime = loadPOIRuntime, runLiveSearch, brandLiveSearch = false, debounceMs = 250, }) {
|
|
37
35
|
const [runtime, setRuntime] = useState(null);
|
|
38
|
-
/**
|
|
39
|
-
* The classify result KEYED BY the query that produced it. The visible result is derived during render
|
|
40
|
-
* (`storedResult.query === trimmedText ? … : null`), so a new query invalidates the old answer by derivation — the
|
|
41
|
-
* effect never writes state synchronously to "reset", which is the react(set-state-in-effect) shape the lint bump
|
|
42
|
-
* rightly flags.
|
|
43
|
-
*/
|
|
44
36
|
const [storedResult, setStoredResult] = useState(null);
|
|
45
|
-
/**
|
|
46
|
-
* Live-search state, keyed the same way: launched FOR a query, visible only while that query stands.
|
|
47
|
-
*/
|
|
48
37
|
const [storedLive, setStoredLive] = useState(null);
|
|
49
38
|
const debouncedText = useDebouncedValue(text, debounceMs);
|
|
50
39
|
const trimmedText = debouncedText.trim();
|
|
51
|
-
// The load fires exactly ONCE on mount regardless of whether the caller passes a fresh `loadRuntime`
|
|
52
|
-
// closure each render (an inline `async () => …` would otherwise retrigger the effect → reload →
|
|
53
|
-
// re-render loop). `useEffectEvent` reads the LATEST closure without joining the dependency list —
|
|
54
|
-
// the runtime is a load-once resource.
|
|
55
40
|
const loadRuntimeEvent = useEffectEvent(() => loadRuntime());
|
|
56
41
|
useEffect(() => {
|
|
57
42
|
let cancelled = false;
|
|
@@ -64,9 +49,6 @@ export function usePOISearch({ text, loadRuntime = loadPOIRuntime, runLiveSearch
|
|
|
64
49
|
cancelled = true;
|
|
65
50
|
};
|
|
66
51
|
}, []);
|
|
67
|
-
// Classify the debounced query and derive the subject + OverpassQL (async, so it lives in an effect).
|
|
68
|
-
// Every state write below happens after an await — invalidation on query change is handled by the
|
|
69
|
-
// key derivation above, not by a synchronous reset here.
|
|
70
52
|
useEffect(() => {
|
|
71
53
|
if (!runtime)
|
|
72
54
|
return;
|
|
@@ -84,8 +66,6 @@ export function usePOISearch({ text, loadRuntime = loadPOIRuntime, runLiveSearch
|
|
|
84
66
|
setStoredResult({ query: trimmed, value: { kindResult } });
|
|
85
67
|
return;
|
|
86
68
|
}
|
|
87
|
-
// Brand subject: the lexicon carries the brand's canonical name as `categoryID` + its Wikidata QID. No category
|
|
88
|
-
// record, no OverpassQL (brands are searched by QID against the layer's `brand_wikidata` index, not OSM tags).
|
|
89
69
|
if ((matched.match.kind ?? "category") === "brand") {
|
|
90
70
|
setStoredResult({
|
|
91
71
|
query: trimmed,
|
|
@@ -128,14 +108,9 @@ export function usePOISearch({ text, loadRuntime = loadPOIRuntime, runLiveSearch
|
|
|
128
108
|
cancelled = true;
|
|
129
109
|
};
|
|
130
110
|
}, [trimmedText, runtime]);
|
|
131
|
-
// Derived visibility: an answer stands only while its query does. A new query reads as null/idle
|
|
132
|
-
// with no reset write anywhere.
|
|
133
111
|
const result = storedResult?.query === trimmedText ? storedResult.value : null;
|
|
134
112
|
const liveSearch = storedLive?.query === trimmedText ? storedLive.state : { status: "idle" };
|
|
135
113
|
const subject = result?.subject;
|
|
136
|
-
// A subject is live-searchable when a probe is wired, it has an anchor, and: a CATEGORY that isn't build-local, or a
|
|
137
|
-
// BRAND with a QID AND a brand-capable probe (`brandLiveSearch`). Brands without a QID / without a brand probe show
|
|
138
|
-
// the intent + QID chip but no live affordance.
|
|
139
114
|
const subjectLiveCapable = subject !== undefined &&
|
|
140
115
|
(subject.kind === "brand" ? brandLiveSearch && subject.wikidata !== undefined : !subject.buildLocal);
|
|
141
116
|
const canSearchLive = Boolean(runLiveSearch && runtime && subject && subjectLiveCapable && subject.remainder.trim().length > 0);
|
|
@@ -155,7 +130,6 @@ export function usePOISearch({ text, loadRuntime = loadPOIRuntime, runLiveSearch
|
|
|
155
130
|
}
|
|
156
131
|
: {
|
|
157
132
|
categoryID: subject.category.id,
|
|
158
|
-
// Fan the canonical seed id out over its Overture leaves — the same translation the Node reader uses.
|
|
159
133
|
overtureCategoryIDs: runtime.lookup.resolveOvertureCategories(subject.category.id),
|
|
160
134
|
anchor: subject.remainder,
|
|
161
135
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePOISearch.js","sourceRoot":"","sources":["../../lib/poi/usePOISearch.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"usePOISearch.js","sourceRoot":"","sources":["../../lib/poi/usePOISearch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAsE7C,SAAS,aAAa,CACrB,OAAmB,EACnB,UAAkB,EAClB,aAAqB,EACrB,SAAiB;IAEjB,MAAM,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ACb,KAAK,EAAE,WAAW;oBAClB,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,yCAAyC,EAAE;iBAC9E,CAAC,CAAA;YACH,CAAC;QACF,CAAC;QAAC,MAAM,CAAC;YACR,aAAa,CAAC;gBACb,KAAK,EAAE,WAAW;gBAClB,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,yCAAyC,EAAE;aAC9E,CAAC,CAAA;QACH,CAAC;IACF,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC,CAAA;IAEnE,OAAO,EAAE,YAAY,EAAE,OAAO,KAAK,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,CAAA;AACzF,CAAC"}
|
package/out/poi.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file POI explorer components, hooks, runtime and interfaces.
|
|
6
|
+
*/
|
|
7
|
+
export { AbstainPanel } from "./poi/AbstainPanel.tsx";
|
|
8
|
+
export type { AbstainPanelProps } from "./poi/AbstainPanel.tsx";
|
|
9
|
+
export { LiveResultsBlock } from "./poi/LiveResultsBlock.tsx";
|
|
10
|
+
export type { LiveResultsBlockProps } from "./poi/LiveResultsBlock.tsx";
|
|
11
|
+
export { OverpassBlock } from "./poi/OverpassBlock.tsx";
|
|
12
|
+
export type { OverpassBlockProps } from "./poi/OverpassBlock.tsx";
|
|
13
|
+
export { POIExplorer } from "./poi/POIExplorer.tsx";
|
|
14
|
+
export type { POIExplorerProps } from "./poi/POIExplorer.tsx";
|
|
15
|
+
export { QueryInput } from "./poi/QueryInput.tsx";
|
|
16
|
+
export type { QueryInputProps } from "./poi/QueryInput.tsx";
|
|
17
|
+
export { formatDistance, loadPOIRuntime, POI_DEFAULT_TEXT, POI_PRESETS } from "#poi/runtime";
|
|
18
|
+
export { SubjectPanel } from "./poi/SubjectPanel.tsx";
|
|
19
|
+
export type { SubjectPanelProps } from "./poi/SubjectPanel.tsx";
|
|
20
|
+
export type { CategoryRecord, LiveSearchState, LoadPOIRuntime, POIBrandSubject, POICategorySubject, POIExplorerResult, POILiveSearch, POILiveSearchResult, POIRuntime, POISearchHit, POISubject, POISubjectBase, TaxonomyLookup, } from "#poi/types";
|
|
21
|
+
export { usePOISearch } from "#poi/usePOISearch";
|
|
22
|
+
export type { UsePOISearch, UsePOISearchOptions } from "#poi/usePOISearch";
|
|
23
|
+
//# sourceMappingURL=poi.d.ts.map
|
package/out/poi.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poi.d.ts","sourceRoot":"","sources":["../lib/poi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,YAAY,EACX,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,cAAc,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA"}
|
package/out/poi.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file POI explorer components, hooks, runtime and interfaces.
|
|
6
|
+
*/
|
|
7
|
+
export { AbstainPanel } from "./poi/AbstainPanel.js";
|
|
8
|
+
export { LiveResultsBlock } from "./poi/LiveResultsBlock.js";
|
|
9
|
+
export { OverpassBlock } from "./poi/OverpassBlock.js";
|
|
10
|
+
export { POIExplorer } from "./poi/POIExplorer.js";
|
|
11
|
+
export { QueryInput } from "./poi/QueryInput.js";
|
|
12
|
+
export { formatDistance, loadPOIRuntime, POI_DEFAULT_TEXT, POI_PRESETS } from "#poi/runtime";
|
|
13
|
+
export { SubjectPanel } from "./poi/SubjectPanel.js";
|
|
14
|
+
export { usePOISearch } from "#poi/usePOISearch";
|
|
15
|
+
//# sourceMappingURL=poi.js.map
|
package/out/poi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poi.js","sourceRoot":"","sources":["../lib/poi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAwB,CAAA;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA4B,CAAA;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAyB,CAAA;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAuB,CAAA;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAsB,CAAA;AAEjD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAwB,CAAA;AAmBrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -2,164 +2,163 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* `useReleaseRuntime` — the headless load-orchestration hook shared by every mailwoman browser surface (the
|
|
7
|
-
* inline doc-embeds via `RuntimeEmbed`, and the geocoder). It owns the version-selection state
|
|
8
|
-
* machine, the per-version load SEQUENCING, cancellation, and the ready / loading / error state — but
|
|
9
|
-
* NOTHING model- or map-specific. The actual asset fetchers (the ONNX classifier factory, the httpvfs
|
|
10
|
-
* WOF opener, the FST fetch, the releases.json fetch) are INJECTED by the host as async functions, so
|
|
11
|
-
* this module imports only React: no `onnxruntime-web`, no `sql.js-httpvfs`, no `maplibre-gl`, no
|
|
12
|
-
* `fetch`-specific plumbing. That keeps it node-import-safe and root-exportable from
|
|
13
|
-
* `@mailwoman/react` — the exact interface `PipelineRuntime` established, generalized to the loader itself.
|
|
14
|
-
*
|
|
15
|
-
* The hook is generic over `TAssets` (the opaque bundle the host's `loadAssets` returns — classifier,
|
|
16
|
-
* FST, WOF lookup, calibrator, …) and `TRelease` (the host's release-manifest entry). The package
|
|
17
|
-
* never inspects either; it just holds, reveals, and re-loads them across version/backend switches.
|
|
18
5
|
*/
|
|
19
6
|
/**
|
|
20
|
-
* The minimal
|
|
7
|
+
* The minimal fields of a release-manifest entry.
|
|
8
|
+
* Hosts can add their own fields.
|
|
21
9
|
*/
|
|
22
10
|
export interface ReleaseBase {
|
|
23
|
-
/**
|
|
24
|
-
* The version tag this entry describes (matched against `selectedVersion`).
|
|
25
|
-
*/
|
|
26
11
|
version: string;
|
|
27
12
|
/**
|
|
28
|
-
*
|
|
13
|
+
* The version picker's display label, falling back to `version`.
|
|
29
14
|
*/
|
|
30
15
|
label?: string;
|
|
31
16
|
}
|
|
32
17
|
/**
|
|
33
|
-
* The releases manifest the host fetches
|
|
18
|
+
* The releases manifest that the host fetches.
|
|
34
19
|
*/
|
|
35
20
|
export interface ReleaseManifest<TRelease extends ReleaseBase = ReleaseBase> {
|
|
36
21
|
/**
|
|
37
|
-
* The version
|
|
22
|
+
* The version that the hook selects when the manifest first loads.
|
|
38
23
|
*/
|
|
39
24
|
defaultVersion: string;
|
|
40
|
-
/**
|
|
41
|
-
* Every selectable release.
|
|
42
|
-
*/
|
|
43
25
|
releases: TRelease[];
|
|
44
26
|
}
|
|
45
27
|
/**
|
|
46
|
-
* The progress
|
|
47
|
-
*
|
|
48
|
-
*
|
|
28
|
+
* The abort signal and progress setters that the hook passes to a host's `loadAssets`.
|
|
29
|
+
*
|
|
30
|
+
* The setters stop affecting state after abort or supersession.
|
|
31
|
+
* The hook sets the final ready or error state.
|
|
49
32
|
*/
|
|
50
33
|
export interface AssetsLoadContext {
|
|
51
34
|
/**
|
|
52
|
-
*
|
|
35
|
+
* The signal aborts when a version or backend switch supersedes this load or when the component unmounts.
|
|
53
36
|
*/
|
|
54
37
|
signal: AbortSignal;
|
|
55
38
|
/**
|
|
56
|
-
* Whether
|
|
39
|
+
* Whether this load should use the CPU WASM backend instead of WebGPU.
|
|
57
40
|
*/
|
|
58
41
|
forceWASM: boolean;
|
|
59
42
|
/**
|
|
60
|
-
*
|
|
43
|
+
* Sets the progress line, such as `Loading v7 model (~28 MB)…`.
|
|
61
44
|
*/
|
|
62
45
|
setProgress: (progress: string) => void;
|
|
63
|
-
/**
|
|
64
|
-
* Set the staged-loader step labels (e.g. `["Loading classifier", "Loading FST gazetteer"]`).
|
|
65
|
-
*/
|
|
66
46
|
setStepLabels: (labels: string[]) => void;
|
|
67
47
|
/**
|
|
68
|
-
*
|
|
48
|
+
* Sets the zero-based index of the current loader step.
|
|
69
49
|
*/
|
|
70
50
|
setStepIndex: (index: number) => void;
|
|
71
51
|
/**
|
|
72
|
-
*
|
|
52
|
+
* Reports the backend that the neural runtime resolved to, such as `webgpu (27 MB int8)`.
|
|
73
53
|
*/
|
|
74
54
|
setBackend: (backend: string) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Reports the fraction of the current download received so far, in [0, 1], or `null`
|
|
57
|
+
* when no download is in progress or the response declares no length.
|
|
58
|
+
*
|
|
59
|
+
* The step index cannot show it because the model is fetched before the first step begins.
|
|
60
|
+
*/
|
|
61
|
+
setByteFraction: (fraction: number | null) => void;
|
|
75
62
|
}
|
|
76
63
|
/**
|
|
77
|
-
* The
|
|
64
|
+
* The host's manifest loader, asset loader and optional asset disposer for {@link useReleaseRuntime}.
|
|
78
65
|
*/
|
|
79
66
|
export interface ReleaseRuntimeConfig<TAssets, TRelease extends ReleaseBase = ReleaseBase> {
|
|
80
67
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
68
|
+
* Fetches the releases manifest once on mount.
|
|
69
|
+
*
|
|
70
|
+
* It returns `null` when the manifest is unavailable.
|
|
71
|
+
* The hook reports a rejection through `errorMessage`.
|
|
83
72
|
*/
|
|
84
73
|
loadManifest: (signal: AbortSignal) => Promise<ReleaseManifest<TRelease> | null>;
|
|
85
74
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* `errorMessage
|
|
75
|
+
* Loads the asset bundle for one release and reports progress through `ctx`;
|
|
76
|
+
* the hook calls it on every version or `forceWASM` change, reports a rejection through
|
|
77
|
+
* `errorMessage`, and disposes a result that resolves after `ctx.signal` aborts.
|
|
89
78
|
*/
|
|
90
79
|
loadAssets: (release: TRelease, ctx: AssetsLoadContext) => Promise<TAssets>;
|
|
91
80
|
/**
|
|
92
|
-
*
|
|
81
|
+
* Releases resources the garbage collector does not own, such as an ONNX
|
|
82
|
+
* session's WASM heap or a GPU buffer.
|
|
83
|
+
*
|
|
84
|
+
* The hook calls it when replacing a bundle.
|
|
85
|
+
* It also calls it if a bundle resolves after abort or when unmounting.
|
|
86
|
+
*
|
|
87
|
+
* Without this function, each reload leaves the model resident.
|
|
88
|
+
*/
|
|
89
|
+
disposeAssets?: (assets: TAssets) => void | Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* The progress line shown before the manifest arrives.
|
|
92
|
+
* Defaults to `Loading releases…`.
|
|
93
93
|
*/
|
|
94
94
|
initialProgress?: string;
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
|
-
* The
|
|
97
|
+
* The release-loading state that {@link useReleaseRuntime} returns.
|
|
98
98
|
*
|
|
99
|
-
*
|
|
100
|
-
* `<Geocoder>` consumes). A host builds a {@link GeocoderRuntime} by pairing this loader state (assets + backend +
|
|
101
|
-
* version) with the map surface (style, overlays, bias, parse) — see the map subpath's `GeocoderRuntime`.
|
|
99
|
+
* A host pairs it with its map surface to build a `GeocoderRuntime`.
|
|
102
100
|
*/
|
|
103
101
|
export interface ReleaseLoaderState<TAssets, TRelease extends ReleaseBase = ReleaseBase> {
|
|
104
102
|
/**
|
|
105
|
-
* The releases manifest,
|
|
103
|
+
* The releases manifest, `null` until it loads or when none is available.
|
|
106
104
|
*/
|
|
107
105
|
manifest: ReleaseManifest<TRelease> | null;
|
|
108
106
|
/**
|
|
109
|
-
* The
|
|
107
|
+
* The selected version, `null` before the manifest loads.
|
|
110
108
|
*/
|
|
111
109
|
selectedVersion: string | null;
|
|
112
110
|
/**
|
|
113
|
-
* The
|
|
111
|
+
* The manifest entry that matches `selectedVersion`, or `null` when none matches.
|
|
114
112
|
*/
|
|
115
113
|
selectedRelease: TRelease | null;
|
|
116
114
|
/**
|
|
117
|
-
* The
|
|
115
|
+
* The asset bundle for the selected version, `null` while it loads.
|
|
118
116
|
*/
|
|
119
117
|
assets: TAssets | null;
|
|
120
|
-
/**
|
|
121
|
-
* Whether the asset bundle is loaded and ready to use.
|
|
122
|
-
*/
|
|
123
118
|
ready: boolean;
|
|
124
119
|
/**
|
|
125
|
-
*
|
|
120
|
+
* The load progress line, empty once loading finishes or fails.
|
|
126
121
|
*/
|
|
127
122
|
loadingProgress: string;
|
|
128
123
|
/**
|
|
129
|
-
*
|
|
124
|
+
* The zero-based loader step index, `-1` before the first step.
|
|
130
125
|
*/
|
|
131
126
|
loadingStepIndex: number;
|
|
127
|
+
loadingStepLabels: string[];
|
|
132
128
|
/**
|
|
133
|
-
*
|
|
129
|
+
* The fraction of the current download received so far, in [0, 1], or `null`
|
|
130
|
+
* when no download is in progress or the length is unknown.
|
|
134
131
|
*/
|
|
135
|
-
|
|
132
|
+
loadingByteFraction: number | null;
|
|
136
133
|
/**
|
|
137
|
-
* A
|
|
134
|
+
* A manifest or asset load error, separate from any parse error a consumer tracks.
|
|
138
135
|
*/
|
|
139
136
|
errorMessage: string | null;
|
|
140
137
|
/**
|
|
141
|
-
* The backend the neural runtime resolved to
|
|
138
|
+
* The backend the neural runtime resolved to, such as `webgpu (27 MB int8)`;
|
|
139
|
+
* it is `""` before the backend is known.
|
|
142
140
|
*/
|
|
143
141
|
activeBackend: string;
|
|
144
142
|
/**
|
|
145
|
-
* Whether the CPU
|
|
143
|
+
* Whether the CPU WASM backend is forced instead of WebGPU.
|
|
146
144
|
*/
|
|
147
145
|
forceWASM: boolean;
|
|
148
146
|
/**
|
|
149
|
-
*
|
|
147
|
+
* Switches to another version, clearing any error and reloading the asset bundle.
|
|
150
148
|
*/
|
|
151
149
|
selectVersion: (version: string) => void;
|
|
152
150
|
/**
|
|
153
|
-
*
|
|
151
|
+
* Forces or releases the CPU WASM backend.
|
|
152
|
+
* Either change reloads the asset bundle.
|
|
154
153
|
*/
|
|
155
154
|
setForceWASM: (forceWASM: boolean) => void;
|
|
156
155
|
}
|
|
157
156
|
/**
|
|
158
|
-
*
|
|
157
|
+
* Loads the release manifest on mount and the selected release's assets whenever
|
|
158
|
+
* the version or `forceWASM` changes.
|
|
159
159
|
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* `loadAssets` resolves (so `ready` flips exactly once per load), and consumers wait on `ready`.
|
|
160
|
+
* Each reload aborts the previous load and disposes the old assets.
|
|
161
|
+
* `ready` becomes true after the new assets load.
|
|
163
162
|
*/
|
|
164
163
|
export declare function useReleaseRuntime<TAssets, TRelease extends ReleaseBase = ReleaseBase>(config: ReleaseRuntimeConfig<TAssets, TRelease>): ReleaseLoaderState<TAssets, TRelease>;
|
|
165
164
|
//# sourceMappingURL=useReleaseRuntime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReleaseRuntime.d.ts","sourceRoot":"","sources":["../../lib/runtime/useReleaseRuntime.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"useReleaseRuntime.d.ts","sourceRoot":"","sources":["../../lib/runtime/useReleaseRuntime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,QAAQ,SAAS,WAAW,GAAG,WAAW;IAC1E;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IAEtB,QAAQ,EAAE,QAAQ,EAAE,CAAA;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,MAAM,EAAE,WAAW,CAAA;IAEnB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IAEvC,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CA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,CAAA;IAE3B;;;OAGG;IACH,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAA;IAElC;;OAEG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAE3B;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAA;IAErB;;OAEG;IACH,SAAS,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAExC;;;OAGG;IACH,YAAY,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;CAC1C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,QAAQ,SAAS,WAAW,GAAG,WAAW,EACpF,MAAM,EAAE,oBAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAC7C,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,CA2JvC"}
|
|
@@ -2,27 +2,14 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* `useReleaseRuntime` — the headless load-orchestration hook shared by every mailwoman browser surface (the
|
|
7
|
-
* inline doc-embeds via `RuntimeEmbed`, and the geocoder). It owns the version-selection state
|
|
8
|
-
* machine, the per-version load SEQUENCING, cancellation, and the ready / loading / error state — but
|
|
9
|
-
* NOTHING model- or map-specific. The actual asset fetchers (the ONNX classifier factory, the httpvfs
|
|
10
|
-
* WOF opener, the FST fetch, the releases.json fetch) are INJECTED by the host as async functions, so
|
|
11
|
-
* this module imports only React: no `onnxruntime-web`, no `sql.js-httpvfs`, no `maplibre-gl`, no
|
|
12
|
-
* `fetch`-specific plumbing. That keeps it node-import-safe and root-exportable from
|
|
13
|
-
* `@mailwoman/react` — the exact interface `PipelineRuntime` established, generalized to the loader itself.
|
|
14
|
-
*
|
|
15
|
-
* The hook is generic over `TAssets` (the opaque bundle the host's `loadAssets` returns — classifier,
|
|
16
|
-
* FST, WOF lookup, calibrator, …) and `TRelease` (the host's release-manifest entry). The package
|
|
17
|
-
* never inspects either; it just holds, reveals, and re-loads them across version/backend switches.
|
|
18
5
|
*/
|
|
19
6
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
20
7
|
/**
|
|
21
|
-
*
|
|
8
|
+
* Loads the release manifest on mount and the selected release's assets whenever
|
|
9
|
+
* the version or `forceWASM` changes.
|
|
22
10
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* `loadAssets` resolves (so `ready` flips exactly once per load), and consumers wait on `ready`.
|
|
11
|
+
* Each reload aborts the previous load and disposes the old assets.
|
|
12
|
+
* `ready` becomes true after the new assets load.
|
|
26
13
|
*/
|
|
27
14
|
export function useReleaseRuntime(config) {
|
|
28
15
|
const { initialProgress = "Loading releases…" } = config;
|
|
@@ -34,21 +21,19 @@ export function useReleaseRuntime(config) {
|
|
|
34
21
|
const [loadingStepLabels, setLoadingStepLabels] = useState([]);
|
|
35
22
|
const [errorMessage, setErrorMessage] = useState(null);
|
|
36
23
|
const [activeBackend, setActiveBackend] = useState("");
|
|
24
|
+
const [loadingByteFraction, setLoadingByteFraction] = useState(null);
|
|
37
25
|
const [forceWASM, setForceWASMState] = useState(false);
|
|
38
|
-
// Latest-ref the injected loaders: a host that re-creates them each render (an inline arrow) must NOT retrigger the
|
|
39
|
-
// load effects, which key ONLY on version/backend. The effects read `.current` at run time.
|
|
40
26
|
const loadManifestRef = useRef(config.loadManifest);
|
|
41
27
|
const loadAssetsRef = useRef(config.loadAssets);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// null → defaultVersion already fires it once).
|
|
28
|
+
const disposeAssetsRef = useRef(config.disposeAssets);
|
|
29
|
+
const liveAssetsRef = useRef(null);
|
|
45
30
|
const manifestRef = useRef(null);
|
|
46
31
|
useEffect(() => {
|
|
47
32
|
loadManifestRef.current = config.loadManifest;
|
|
48
33
|
loadAssetsRef.current = config.loadAssets;
|
|
34
|
+
disposeAssetsRef.current = config.disposeAssets;
|
|
49
35
|
manifestRef.current = manifest;
|
|
50
|
-
}, [config.loadAssets, config.loadManifest, manifest]);
|
|
51
|
-
// Mount: fetch the manifest, then select the default version.
|
|
36
|
+
}, [config.disposeAssets, config.loadAssets, config.loadManifest, manifest]);
|
|
52
37
|
useEffect(() => {
|
|
53
38
|
const controller = new AbortController();
|
|
54
39
|
void (async () => {
|
|
@@ -69,7 +54,6 @@ export function useReleaseRuntime(config) {
|
|
|
69
54
|
})();
|
|
70
55
|
return () => controller.abort();
|
|
71
56
|
}, []);
|
|
72
|
-
// Load the per-version asset bundle when the version (or the backend force) changes.
|
|
73
57
|
useEffect(() => {
|
|
74
58
|
if (!selectedVersion)
|
|
75
59
|
return;
|
|
@@ -85,10 +69,16 @@ export function useReleaseRuntime(config) {
|
|
|
85
69
|
};
|
|
86
70
|
void (async () => {
|
|
87
71
|
try {
|
|
72
|
+
const outgoing = liveAssetsRef.current;
|
|
73
|
+
liveAssetsRef.current = null;
|
|
74
|
+
if (outgoing) {
|
|
75
|
+
await disposeAssetsRef.current?.(outgoing);
|
|
76
|
+
}
|
|
88
77
|
setAssets(null);
|
|
89
78
|
setLoadingStepIndex(-1);
|
|
90
79
|
setLoadingStepLabels([]);
|
|
91
80
|
setActiveBackend("");
|
|
81
|
+
setLoadingByteFraction(null);
|
|
92
82
|
const ctx = {
|
|
93
83
|
signal,
|
|
94
84
|
forceWASM,
|
|
@@ -96,12 +86,17 @@ export function useReleaseRuntime(config) {
|
|
|
96
86
|
setStepLabels: (labels) => guard(() => setLoadingStepLabels(labels)),
|
|
97
87
|
setStepIndex: (index) => guard(() => setLoadingStepIndex(index)),
|
|
98
88
|
setBackend: (backend) => guard(() => setActiveBackend(backend)),
|
|
89
|
+
setByteFraction: (fraction) => guard(() => setLoadingByteFraction(fraction)),
|
|
99
90
|
};
|
|
100
91
|
const loaded = await loadAssetsRef.current(release, ctx);
|
|
101
|
-
if (signal.aborted)
|
|
92
|
+
if (signal.aborted) {
|
|
93
|
+
await disposeAssetsRef.current?.(loaded);
|
|
102
94
|
return;
|
|
95
|
+
}
|
|
96
|
+
liveAssetsRef.current = loaded;
|
|
103
97
|
setAssets(loaded);
|
|
104
98
|
setLoadingProgress("");
|
|
99
|
+
setLoadingByteFraction(null);
|
|
105
100
|
}
|
|
106
101
|
catch (error) {
|
|
107
102
|
if (signal.aborted)
|
|
@@ -112,6 +107,15 @@ export function useReleaseRuntime(config) {
|
|
|
112
107
|
})();
|
|
113
108
|
return () => controller.abort();
|
|
114
109
|
}, [selectedVersion, forceWASM]);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
return () => {
|
|
112
|
+
const live = liveAssetsRef.current;
|
|
113
|
+
liveAssetsRef.current = null;
|
|
114
|
+
if (live) {
|
|
115
|
+
void disposeAssetsRef.current?.(live);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}, []);
|
|
115
119
|
const selectVersion = useCallback((version) => {
|
|
116
120
|
setSelectedVersion(version);
|
|
117
121
|
setErrorMessage(null);
|
|
@@ -127,6 +131,7 @@ export function useReleaseRuntime(config) {
|
|
|
127
131
|
loadingProgress,
|
|
128
132
|
loadingStepIndex,
|
|
129
133
|
loadingStepLabels,
|
|
134
|
+
loadingByteFraction,
|
|
130
135
|
errorMessage,
|
|
131
136
|
activeBackend,
|
|
132
137
|
forceWASM,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReleaseRuntime.js","sourceRoot":"","sources":["../../lib/runtime/useReleaseRuntime.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"useReleaseRuntime.js","sourceRoot":"","sources":["../../lib/runtime/useReleaseRuntime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAqLzE;;;;;;GAMG;AACH,MAAM,UAAU,iB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AAE,CAAC;gBACV,KAAK,gBAAgB,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAA;YACtC,CAAC;QACF,CAAC,CAAA;IACF,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,aAAa,GAAG,WAAW,CAAC,CAAC,OAAe,EAAE,EAAE;QACrD,kBAAkB,CAAC,OAAO,CAAC,CAAA;QAC3B,eAAe,CAAC,IAAI,CAAC,CAAA;IACtB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,IAAa,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;IAEhF,MAAM,eAAe,GAAG,OAAO,CAC9B,GAAG,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,eAAe,CAAC,IAAI,IAAI,EAC3E,CAAC,QAAQ,EAAE,eAAe,CAAC,CAC3B,CAAA;IAED,OAAO;QACN,QAAQ;QACR,eAAe;QACf,eAAe;QACf,MAAM;QACN,KAAK,EAAE,MAAM,KAAK,IAAI;QACtB,eAAe;QACf,gBAAgB;QAChB,iBAAiB;QACjB,mBAAmB;QACnB,YAAY;QACZ,aAAa;QACb,SAAS;QACT,aAAa;QACb,YAAY;KACZ,CAAA;AACF,CAAC"}
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { useReleaseRuntime } from "#runtime/useReleaseRuntime";
|
|
8
8
|
export type { AssetsLoadContext, ReleaseBase, ReleaseLoaderState, ReleaseManifest, ReleaseRuntimeConfig, } from "#runtime/useReleaseRuntime";
|
|
9
|
-
//# sourceMappingURL=
|
|
9
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../lib/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAE9D,YAAY,EACX,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,oBAAoB,GACpB,MAAM,4BAA4B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../lib/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The docs search modal. A native `<dialog>` opened with `showModal()` supplies the focus trap, the inert
|
|
7
|
+
* background, the backdrop, the close on Escape and the return of focus to the opener. The query field is an
|
|
8
|
+
* `<input type="search">` with the ARIA combobox role. DOM focus stays on the input, and the selected hit is
|
|
9
|
+
* named by `aria-activedescendant`. The component owns no data access: `search` is passed in.
|
|
10
|
+
*/
|
|
11
|
+
import type { SearchHit, SearchResponse } from "./types.ts";
|
|
12
|
+
export interface SearchModalProps {
|
|
13
|
+
open: boolean;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Called with the hit's site-relative link on Enter or on an unmodified click.
|
|
17
|
+
* Absent, the link navigates as an ordinary anchor.
|
|
18
|
+
*/
|
|
19
|
+
onNavigate?: (href: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Runs the query.
|
|
22
|
+
*
|
|
23
|
+
* The function must keep a stable identity across renders (for example through `useCallback`),
|
|
24
|
+
* because a new identity refires the request for the current query.
|
|
25
|
+
*/
|
|
26
|
+
search: (q: string, signal: AbortSignal) => Promise<SearchResponse>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The site-relative link for a hit.
|
|
30
|
+
*/
|
|
31
|
+
export declare function hitHref(hit: Pick<SearchHit, "url" | "anchor">): string;
|
|
32
|
+
export declare function SearchModal({ open, onClose, onNavigate, search }: SearchModalProps): import("react").JSX.Element;
|
|
33
|
+
//# sourceMappingURL=SearchModal.d.ts.map
|