@mapcairn/map 0.0.0-stage → 0.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (315) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +167 -2
  3. package/dist/chrome/Attribution/Attribution.js +304 -0
  4. package/dist/chrome/Attribution/Attribution.js.map +1 -0
  5. package/dist/chrome/Attribution/Attribution.styles.js +10 -0
  6. package/dist/chrome/Attribution/Attribution.styles.js.map +1 -0
  7. package/dist/chrome/Attribution/AttributionSkeleton.js +29 -0
  8. package/dist/chrome/Attribution/AttributionSkeleton.js.map +1 -0
  9. package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js +83 -0
  10. package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js.map +1 -0
  11. package/dist/chrome/EndStack/EndStack.js +157 -0
  12. package/dist/chrome/EndStack/EndStack.js.map +1 -0
  13. package/dist/chrome/EndStack/EndStack.styles.js +12 -0
  14. package/dist/chrome/EndStack/EndStack.styles.js.map +1 -0
  15. package/dist/chrome/EndStack/EndStackSkeleton.js +78 -0
  16. package/dist/chrome/EndStack/EndStackSkeleton.js.map +1 -0
  17. package/dist/chrome/EndStack/endStackHeight.js +22 -0
  18. package/dist/chrome/EndStack/endStackHeight.js.map +1 -0
  19. package/dist/chrome/MapChrome/MapChrome.js +488 -0
  20. package/dist/chrome/MapChrome/MapChrome.js.map +1 -0
  21. package/dist/chrome/MapChrome/MapChrome.styles.js +15 -0
  22. package/dist/chrome/MapChrome/MapChrome.styles.js.map +1 -0
  23. package/dist/chrome/MapChrome/chromeSurface.js +18 -0
  24. package/dist/chrome/MapChrome/chromeSurface.js.map +1 -0
  25. package/dist/chrome/MapChrome/chromeVars.js +71 -0
  26. package/dist/chrome/MapChrome/chromeVars.js.map +1 -0
  27. package/dist/chrome/MapChrome/mapKeyPlacement.js +41 -0
  28. package/dist/chrome/MapChrome/mapKeyPlacement.js.map +1 -0
  29. package/dist/chrome/MapChrome/sharesWidth.js +13 -0
  30. package/dist/chrome/MapChrome/sharesWidth.js.map +1 -0
  31. package/dist/chrome/MapReadout/MapReadout.js +199 -0
  32. package/dist/chrome/MapReadout/MapReadout.js.map +1 -0
  33. package/dist/chrome/MapReadout/MapReadout.styles.js +14 -0
  34. package/dist/chrome/MapReadout/MapReadout.styles.js.map +1 -0
  35. package/dist/chrome/Sheet/Sheet.js +412 -0
  36. package/dist/chrome/Sheet/Sheet.js.map +1 -0
  37. package/dist/chrome/Sheet/Sheet.styles.js +14 -0
  38. package/dist/chrome/Sheet/Sheet.styles.js.map +1 -0
  39. package/dist/chrome/focusRegistry.js +76 -0
  40. package/dist/chrome/focusRegistry.js.map +1 -0
  41. package/dist/chrome/layoutContext.js +30 -0
  42. package/dist/chrome/layoutContext.js.map +1 -0
  43. package/dist/chrome/useScrollEdges.js +53 -0
  44. package/dist/chrome/useScrollEdges.js.map +1 -0
  45. package/dist/host/MapContext.js +16 -0
  46. package/dist/host/MapContext.js.map +1 -0
  47. package/dist/host/MapView.js +189 -0
  48. package/dist/host/MapView.js.map +1 -0
  49. package/dist/host/MapView.styles.js +16 -0
  50. package/dist/host/MapView.styles.js.map +1 -0
  51. package/dist/host/overlays/AccuracyCircle.js +36 -0
  52. package/dist/host/overlays/AccuracyCircle.js.map +1 -0
  53. package/dist/host/overlays/CentreCrosshair.js +40 -0
  54. package/dist/host/overlays/CentreCrosshair.js.map +1 -0
  55. package/dist/host/overlays/DrawOverlay.js +221 -0
  56. package/dist/host/overlays/DrawOverlay.js.map +1 -0
  57. package/dist/host/overlays/MapOverlayLayer.js +27 -0
  58. package/dist/host/overlays/MapOverlayLayer.js.map +1 -0
  59. package/dist/host/overlays/MeasureOverlay.js +87 -0
  60. package/dist/host/overlays/MeasureOverlay.js.map +1 -0
  61. package/dist/host/overlays/PinMarker.js +40 -0
  62. package/dist/host/overlays/PinMarker.js.map +1 -0
  63. package/dist/host/overlays/geometry.js +41 -0
  64. package/dist/host/overlays/geometry.js.map +1 -0
  65. package/dist/host/overlays/overlays.styles.js +27 -0
  66. package/dist/host/overlays/overlays.styles.js.map +1 -0
  67. package/dist/host/pointerTargets.js +22 -0
  68. package/dist/host/pointerTargets.js.map +1 -0
  69. package/dist/host/useLongPress.js +102 -0
  70. package/dist/host/useLongPress.js.map +1 -0
  71. package/dist/host/useMapEngine.js +352 -0
  72. package/dist/host/useMapEngine.js.map +1 -0
  73. package/dist/host/usePointerPosition.js +60 -0
  74. package/dist/host/usePointerPosition.js.map +1 -0
  75. package/dist/index.d.ts +3845 -0
  76. package/dist/index.js +89 -0
  77. package/dist/layers/CatalogueStatus.js +138 -0
  78. package/dist/layers/CatalogueStatus.js.map +1 -0
  79. package/dist/layers/DateTimeControl.js +101 -0
  80. package/dist/layers/DateTimeControl.js.map +1 -0
  81. package/dist/layers/FeatureCard.js +147 -0
  82. package/dist/layers/FeatureCard.js.map +1 -0
  83. package/dist/layers/FeatureChoices.js +101 -0
  84. package/dist/layers/FeatureChoices.js.map +1 -0
  85. package/dist/layers/FeatureGlyph.js +56 -0
  86. package/dist/layers/FeatureGlyph.js.map +1 -0
  87. package/dist/layers/IdentifyStatus.js +36 -0
  88. package/dist/layers/IdentifyStatus.js.map +1 -0
  89. package/dist/layers/LayerItem.js +321 -0
  90. package/dist/layers/LayerItem.js.map +1 -0
  91. package/dist/layers/LayerKey.js +36 -0
  92. package/dist/layers/LayerKey.js.map +1 -0
  93. package/dist/layers/Layers.styles.js +50 -0
  94. package/dist/layers/Layers.styles.js.map +1 -0
  95. package/dist/layers/LayersSection.js +267 -0
  96. package/dist/layers/LayersSection.js.map +1 -0
  97. package/dist/layers/MapDataLayers.js +261 -0
  98. package/dist/layers/MapDataLayers.js.map +1 -0
  99. package/dist/layers/MapKey.js +131 -0
  100. package/dist/layers/MapKey.js.map +1 -0
  101. package/dist/layers/MapKey.styles.js +16 -0
  102. package/dist/layers/MapKey.styles.js.map +1 -0
  103. package/dist/layers/MarkerGlyph.js +84 -0
  104. package/dist/layers/MarkerGlyph.js.map +1 -0
  105. package/dist/layers/SelectionProvider.js +27 -0
  106. package/dist/layers/SelectionProvider.js.map +1 -0
  107. package/dist/layers/ShapeGlyph.js +122 -0
  108. package/dist/layers/ShapeGlyph.js.map +1 -0
  109. package/dist/layers/TurnOffActions.js +147 -0
  110. package/dist/layers/TurnOffActions.js.map +1 -0
  111. package/dist/layers/answersTap.js +16 -0
  112. package/dist/layers/answersTap.js.map +1 -0
  113. package/dist/layers/catalogueNotice.js +65 -0
  114. package/dist/layers/catalogueNotice.js.map +1 -0
  115. package/dist/layers/catalogueReconcile.js +55 -0
  116. package/dist/layers/catalogueReconcile.js.map +1 -0
  117. package/dist/layers/catalogueView.js +32 -0
  118. package/dist/layers/catalogueView.js.map +1 -0
  119. package/dist/layers/featureTitle.js +14 -0
  120. package/dist/layers/featureTitle.js.map +1 -0
  121. package/dist/layers/identifyFeedback.js +30 -0
  122. package/dist/layers/identifyFeedback.js.map +1 -0
  123. package/dist/layers/identifyRun.js +148 -0
  124. package/dist/layers/identifyRun.js.map +1 -0
  125. package/dist/layers/layerStatus.js +13 -0
  126. package/dist/layers/layerStatus.js.map +1 -0
  127. package/dist/layers/loadOutcome.js +107 -0
  128. package/dist/layers/loadOutcome.js.map +1 -0
  129. package/dist/layers/loadReport.js +33 -0
  130. package/dist/layers/loadReport.js.map +1 -0
  131. package/dist/layers/loadRequests.js +73 -0
  132. package/dist/layers/loadRequests.js.map +1 -0
  133. package/dist/layers/mapFeatures.js +307 -0
  134. package/dist/layers/mapFeatures.js.map +1 -0
  135. package/dist/layers/mapKeyBlocks.js +24 -0
  136. package/dist/layers/mapKeyBlocks.js.map +1 -0
  137. package/dist/layers/reveal.js +119 -0
  138. package/dist/layers/reveal.js.map +1 -0
  139. package/dist/layers/selectionMessages.js +53 -0
  140. package/dist/layers/selectionMessages.js.map +1 -0
  141. package/dist/layers/selectionResolve.js +111 -0
  142. package/dist/layers/selectionResolve.js.map +1 -0
  143. package/dist/layers/useDataLayers.js +940 -0
  144. package/dist/layers/useDataLayers.js.map +1 -0
  145. package/dist/layers/useFeatureSelection.js +179 -0
  146. package/dist/layers/useFeatureSelection.js.map +1 -0
  147. package/dist/layers/useScrolls.js +37 -0
  148. package/dist/layers/useScrolls.js.map +1 -0
  149. package/dist/panels/BasemapPicker/BasemapPicker.js +169 -0
  150. package/dist/panels/BasemapPicker/BasemapPicker.js.map +1 -0
  151. package/dist/panels/BasemapPicker/BasemapPicker.styles.js +42 -0
  152. package/dist/panels/BasemapPicker/BasemapPicker.styles.js.map +1 -0
  153. package/dist/panels/ExportSection/ExportSection.js +91 -0
  154. package/dist/panels/ExportSection/ExportSection.js.map +1 -0
  155. package/dist/panels/HelpSection/HelpSection.js +163 -0
  156. package/dist/panels/HelpSection/HelpSection.js.map +1 -0
  157. package/dist/panels/HelpSection/HelpSection.styles.js +9 -0
  158. package/dist/panels/HelpSection/HelpSection.styles.js.map +1 -0
  159. package/dist/panels/PinSection/PinSection.js +39 -0
  160. package/dist/panels/PinSection/PinSection.js.map +1 -0
  161. package/dist/panels/Section/Section.js +43 -0
  162. package/dist/panels/Section/Section.js.map +1 -0
  163. package/dist/panels/Section/Section.styles.js +13 -0
  164. package/dist/panels/Section/Section.styles.js.map +1 -0
  165. package/dist/panels/SettingsSection/LanguageField.js +126 -0
  166. package/dist/panels/SettingsSection/LanguageField.js.map +1 -0
  167. package/dist/panels/SettingsSection/SettingsSection.js +175 -0
  168. package/dist/panels/SettingsSection/SettingsSection.js.map +1 -0
  169. package/dist/panels/SettingsSection/SettingsSection.styles.js +9 -0
  170. package/dist/panels/SettingsSection/SettingsSection.styles.js.map +1 -0
  171. package/dist/panels/ShapesSection/ShapesSection.js +229 -0
  172. package/dist/panels/ShapesSection/ShapesSection.js.map +1 -0
  173. package/dist/panels/ShapesSection/ShapesSection.styles.js +7 -0
  174. package/dist/panels/ShapesSection/ShapesSection.styles.js.map +1 -0
  175. package/dist/panels/SheetContent/SheetContent.js +92 -0
  176. package/dist/panels/SheetContent/SheetContent.js.map +1 -0
  177. package/dist/panels/SheetContent/SheetContent.styles.js +6 -0
  178. package/dist/panels/SheetContent/SheetContent.styles.js.map +1 -0
  179. package/dist/services/ServicesProvider.js +42 -0
  180. package/dist/services/ServicesProvider.js.map +1 -0
  181. package/dist/services/activeMessages.js +140 -0
  182. package/dist/services/activeMessages.js.map +1 -0
  183. package/dist/services/basemapAvailability.js +78 -0
  184. package/dist/services/basemapAvailability.js.map +1 -0
  185. package/dist/services/englishMessages.js +10 -0
  186. package/dist/services/englishMessages.js.map +1 -0
  187. package/dist/services/hooks.js +214 -0
  188. package/dist/services/hooks.js.map +1 -0
  189. package/dist/styles.css +2866 -0
  190. package/dist/styles.css.d.ts +1 -0
  191. package/dist/tools/Directions/Directions.styles.js +25 -0
  192. package/dist/tools/Directions/Directions.styles.js.map +1 -0
  193. package/dist/tools/Directions/DirectionsOverlay.js +46 -0
  194. package/dist/tools/Directions/DirectionsOverlay.js.map +1 -0
  195. package/dist/tools/Directions/DirectionsPanel.js +428 -0
  196. package/dist/tools/Directions/DirectionsPanel.js.map +1 -0
  197. package/dist/tools/Directions/MapDirections.js +84 -0
  198. package/dist/tools/Directions/MapDirections.js.map +1 -0
  199. package/dist/tools/Directions/useDirections.js +226 -0
  200. package/dist/tools/Directions/useDirections.js.map +1 -0
  201. package/dist/tools/Directions/useFreeCentre.js +30 -0
  202. package/dist/tools/Directions/useFreeCentre.js.map +1 -0
  203. package/dist/tools/DrawToolbar/DrawMapBindings.js +34 -0
  204. package/dist/tools/DrawToolbar/DrawMapBindings.js.map +1 -0
  205. package/dist/tools/DrawToolbar/DrawToolbar.js +296 -0
  206. package/dist/tools/DrawToolbar/DrawToolbar.js.map +1 -0
  207. package/dist/tools/DrawToolbar/DrawToolbar.styles.js +21 -0
  208. package/dist/tools/DrawToolbar/DrawToolbar.styles.js.map +1 -0
  209. package/dist/tools/DrawToolbar/imageDrawing.js +24 -0
  210. package/dist/tools/DrawToolbar/imageDrawing.js.map +1 -0
  211. package/dist/tools/DrawToolbar/useDraw.js +543 -0
  212. package/dist/tools/DrawToolbar/useDraw.js.map +1 -0
  213. package/dist/tools/MeasureToolbar/MeasureToolbar.js +116 -0
  214. package/dist/tools/MeasureToolbar/MeasureToolbar.js.map +1 -0
  215. package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js +12 -0
  216. package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js.map +1 -0
  217. package/dist/tools/MeasureToolbar/useMeasure.js +75 -0
  218. package/dist/tools/MeasureToolbar/useMeasure.js.map +1 -0
  219. package/dist/tools/PinCard/PinCard.js +174 -0
  220. package/dist/tools/PinCard/PinCard.js.map +1 -0
  221. package/dist/tools/PinCard/PinCard.styles.js +16 -0
  222. package/dist/tools/PinCard/PinCard.styles.js.map +1 -0
  223. package/dist/tools/PinCard/useReverseAddress.js +77 -0
  224. package/dist/tools/PinCard/useReverseAddress.js.map +1 -0
  225. package/dist/tools/SearchPill/SearchPill.js +292 -0
  226. package/dist/tools/SearchPill/SearchPill.js.map +1 -0
  227. package/dist/tools/SearchPill/SearchPill.styles.js +16 -0
  228. package/dist/tools/SearchPill/SearchPill.styles.js.map +1 -0
  229. package/dist/tools/SearchPill/SearchPillSkeleton.js +41 -0
  230. package/dist/tools/SearchPill/SearchPillSkeleton.js.map +1 -0
  231. package/dist/tools/SearchPill/useSearch.js +143 -0
  232. package/dist/tools/SearchPill/useSearch.js.map +1 -0
  233. package/dist/tools/SearchPill/useSuggestions.js +105 -0
  234. package/dist/tools/SearchPill/useSuggestions.js.map +1 -0
  235. package/dist/tools/Tour/TourCard.js +156 -0
  236. package/dist/tools/Tour/TourCard.js.map +1 -0
  237. package/dist/tools/Tour/TourCard.styles.js +10 -0
  238. package/dist/tools/Tour/TourCard.styles.js.map +1 -0
  239. package/dist/tools/Tour/useTour.js +110 -0
  240. package/dist/tools/Tour/useTour.js.map +1 -0
  241. package/dist/tools/locate/useLocate.js +94 -0
  242. package/dist/tools/locate/useLocate.js.map +1 -0
  243. package/dist/ui/Button/Button.js +36 -0
  244. package/dist/ui/Button/Button.js.map +1 -0
  245. package/dist/ui/Button/Button.styles.js +17 -0
  246. package/dist/ui/Button/Button.styles.js.map +1 -0
  247. package/dist/ui/Chip/Chip.js +37 -0
  248. package/dist/ui/Chip/Chip.js.map +1 -0
  249. package/dist/ui/Chip/Chip.styles.js +29 -0
  250. package/dist/ui/Chip/Chip.styles.js.map +1 -0
  251. package/dist/ui/ControlGroup/ControlGroup.js +23 -0
  252. package/dist/ui/ControlGroup/ControlGroup.js.map +1 -0
  253. package/dist/ui/ControlGroup/ControlGroup.styles.js +6 -0
  254. package/dist/ui/ControlGroup/ControlGroup.styles.js.map +1 -0
  255. package/dist/ui/EmptyState/EmptyState.js +37 -0
  256. package/dist/ui/EmptyState/EmptyState.js.map +1 -0
  257. package/dist/ui/EmptyState/EmptyState.styles.js +10 -0
  258. package/dist/ui/EmptyState/EmptyState.styles.js.map +1 -0
  259. package/dist/ui/Icon/Icon.js +28 -0
  260. package/dist/ui/Icon/Icon.js.map +1 -0
  261. package/dist/ui/Icon/Icon.styles.js +8 -0
  262. package/dist/ui/Icon/Icon.styles.js.map +1 -0
  263. package/dist/ui/IconButton/IconButton.js +47 -0
  264. package/dist/ui/IconButton/IconButton.js.map +1 -0
  265. package/dist/ui/IconButton/IconButton.styles.js +27 -0
  266. package/dist/ui/IconButton/IconButton.styles.js.map +1 -0
  267. package/dist/ui/Isolate/Isolate.js +26 -0
  268. package/dist/ui/Isolate/Isolate.js.map +1 -0
  269. package/dist/ui/Isolate/fillSlots.js +27 -0
  270. package/dist/ui/Isolate/fillSlots.js.map +1 -0
  271. package/dist/ui/ListRow/ListRow.js +59 -0
  272. package/dist/ui/ListRow/ListRow.js.map +1 -0
  273. package/dist/ui/ListRow/ListRow.styles.js +30 -0
  274. package/dist/ui/ListRow/ListRow.styles.js.map +1 -0
  275. package/dist/ui/LiveRegion/LiveRegion.js +88 -0
  276. package/dist/ui/LiveRegion/LiveRegion.js.map +1 -0
  277. package/dist/ui/LiveRegion/announcer.js +114 -0
  278. package/dist/ui/LiveRegion/announcer.js.map +1 -0
  279. package/dist/ui/SegmentedControl/SegmentedControl.js +55 -0
  280. package/dist/ui/SegmentedControl/SegmentedControl.js.map +1 -0
  281. package/dist/ui/SegmentedControl/SegmentedControl.styles.js +9 -0
  282. package/dist/ui/SegmentedControl/SegmentedControl.styles.js.map +1 -0
  283. package/dist/ui/SkipLink/SkipLink.js +35 -0
  284. package/dist/ui/SkipLink/SkipLink.js.map +1 -0
  285. package/dist/ui/SkipLink/SkipLink.styles.js +6 -0
  286. package/dist/ui/SkipLink/SkipLink.styles.js.map +1 -0
  287. package/dist/ui/Slider/Slider.js +68 -0
  288. package/dist/ui/Slider/Slider.js.map +1 -0
  289. package/dist/ui/Slider/Slider.styles.js +13 -0
  290. package/dist/ui/Slider/Slider.styles.js.map +1 -0
  291. package/dist/ui/StatusMessage/StatusMessage.js +124 -0
  292. package/dist/ui/StatusMessage/StatusMessage.js.map +1 -0
  293. package/dist/ui/StatusMessage/StatusMessage.styles.js +28 -0
  294. package/dist/ui/StatusMessage/StatusMessage.styles.js.map +1 -0
  295. package/dist/ui/StatusMessage/StatusMessageFocus.js +30 -0
  296. package/dist/ui/StatusMessage/StatusMessageFocus.js.map +1 -0
  297. package/dist/ui/Surface/Surface.js +22 -0
  298. package/dist/ui/Surface/Surface.js.map +1 -0
  299. package/dist/ui/Surface/Surface.styles.js +27 -0
  300. package/dist/ui/Surface/Surface.styles.js.map +1 -0
  301. package/dist/ui/Switch/Switch.js +58 -0
  302. package/dist/ui/Switch/Switch.js.map +1 -0
  303. package/dist/ui/Switch/Switch.styles.js +13 -0
  304. package/dist/ui/Switch/Switch.styles.js.map +1 -0
  305. package/dist/ui/Tooltip/Tooltip.js +66 -0
  306. package/dist/ui/Tooltip/Tooltip.js.map +1 -0
  307. package/dist/ui/Tooltip/Tooltip.styles.js +6 -0
  308. package/dist/ui/Tooltip/Tooltip.styles.js.map +1 -0
  309. package/dist/ui/Tooltip/inheritColours.js +27 -0
  310. package/dist/ui/Tooltip/inheritColours.js.map +1 -0
  311. package/dist/ui/VisuallyHidden/VisuallyHidden.js +16 -0
  312. package/dist/ui/VisuallyHidden/VisuallyHidden.js.map +1 -0
  313. package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js +6 -0
  314. package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js.map +1 -0
  315. package/package.json +82 -4
@@ -0,0 +1,140 @@
1
+ import { resolveLanguage } from "@mapcairn/core";
2
+ import { createContext, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/services/activeMessages.tsx
5
+ /** The active catalogue, or null outside {@link ActiveMessagesProvider}. */
6
+ var ActiveMessagesContext = createContext(null);
7
+ /**
8
+ * The state of the language load, or null outside {@link ActiveMessagesProvider}
9
+ * and for a host with no `Services.languages`.
10
+ */
11
+ var LanguageLoadContext = createContext(null);
12
+ /** Subscribes to a store whose server snapshot is its client one, as the other hooks do. */
13
+ function useStoreValue(subscribe, get) {
14
+ return useSyncExternalStore(subscribe, get, get);
15
+ }
16
+ /** Whether two language lists hold the same tags in the same order. */
17
+ function sameTags(a, b) {
18
+ return a.length === b.length && a.every((tag, index) => tag === b[index]);
19
+ }
20
+ /** Whether `request` already answers for `next`, so no load is needed. */
21
+ function answers(request, next) {
22
+ if (request === void 0 || request.tag !== next.tag || request.messages !== next.messages || request.languages !== next.languages) return false;
23
+ return !request.failed || request.choice === next.choice && sameTags(request.browserLanguages, next.browserLanguages);
24
+ }
25
+ /** Whether a load returned a promise rather than a ready catalogue. */
26
+ function isPending(loaded) {
27
+ return loaded instanceof Promise;
28
+ }
29
+ /**
30
+ * Keeps the catalogue the ui speaks, in one place for the whole tree, so a
31
+ * language loads once however many components read it.
32
+ *
33
+ * @remarks Without `Services.languages` the catalogue is `Services.messages`,
34
+ * always. With it, the language is resolved from the person's setting and
35
+ * the browser's languages and then loaded. The first render, and every
36
+ * render until a load finishes, uses `Services.messages` or the last
37
+ * catalogue that loaded, so the first client render matches the server's
38
+ * and a slow load never blanks the text. A load that finishes after
39
+ * another language was asked for is dropped. One that fails keeps the
40
+ * previous catalogue and warns, and the language is requested again the
41
+ * next time the setting or the browser's languages resolve, even to the
42
+ * same tag; a load that is in flight or has succeeded is not repeated.
43
+ * `LanguageLoadContext` says which language failed and offers a retry that
44
+ * asks for it again whatever the setting is. {@link ServicesProvider} mounts it.
45
+ */
46
+ function ActiveMessagesProvider({ services, children }) {
47
+ const { messages, languages, settings, preferences } = services;
48
+ const subscribeSettings = useCallback((listener) => settings.subscribe(listener), [settings]);
49
+ const subscribePreferences = useCallback((listener) => preferences.subscribe(listener), [preferences]);
50
+ const choice = useStoreValue(subscribeSettings, () => settings.get()).language;
51
+ const browserLanguages = useStoreValue(subscribePreferences, () => preferences.get()).languages;
52
+ const [active, setActive] = useState(messages);
53
+ const requested = useRef(void 0);
54
+ const [failed, setFailed] = useState(null);
55
+ const [pending, setPending] = useState(null);
56
+ const tag = languages === void 0 ? void 0 : resolveLanguage(choice, languages.languages.map((language) => language.tag), browserLanguages, languages.defaultLanguage);
57
+ const startLoad = useCallback((inputs) => {
58
+ const { tag: wanted, languages: offered } = inputs;
59
+ const request = {
60
+ ...inputs,
61
+ failed: false
62
+ };
63
+ requested.current = request;
64
+ setFailed((previous) => previous === wanted ? previous : null);
65
+ setPending(wanted);
66
+ const succeed = (catalogue) => {
67
+ if (requested.current === request) {
68
+ setActive(catalogue);
69
+ setFailed(null);
70
+ setPending(null);
71
+ }
72
+ };
73
+ const fail = (error) => {
74
+ if (requested.current === request) {
75
+ requested.current = {
76
+ ...request,
77
+ failed: true
78
+ };
79
+ setFailed(wanted);
80
+ setPending(null);
81
+ }
82
+ console.warn(`Could not load the "${wanted}" language.`, error);
83
+ };
84
+ try {
85
+ const loaded = offered.load(wanted);
86
+ if (isPending(loaded)) loaded.then(succeed, fail);
87
+ else succeed(loaded);
88
+ } catch (error) {
89
+ fail(error);
90
+ }
91
+ }, []);
92
+ useEffect(() => {
93
+ if (languages === void 0 || tag === void 0) return;
94
+ if (tag === messages.language) {
95
+ requested.current = void 0;
96
+ setActive(messages);
97
+ setFailed(null);
98
+ setPending(null);
99
+ return;
100
+ }
101
+ const inputs = {
102
+ tag,
103
+ messages,
104
+ languages,
105
+ choice,
106
+ browserLanguages
107
+ };
108
+ if (!answers(requested.current, inputs)) startLoad(inputs);
109
+ }, [
110
+ languages,
111
+ messages,
112
+ tag,
113
+ choice,
114
+ browserLanguages,
115
+ startLoad
116
+ ]);
117
+ const retry = useCallback(() => {
118
+ const last = requested.current;
119
+ if (last?.failed) startLoad(last);
120
+ }, [startLoad]);
121
+ const load = useMemo(() => ({
122
+ failed,
123
+ retrying: failed !== null && pending === failed,
124
+ retry
125
+ }), [
126
+ failed,
127
+ pending,
128
+ retry
129
+ ]);
130
+ return /* @__PURE__ */ jsx(ActiveMessagesContext.Provider, {
131
+ value: languages === void 0 ? messages : active,
132
+ children: /* @__PURE__ */ jsx(LanguageLoadContext.Provider, {
133
+ value: languages === void 0 ? null : load,
134
+ children
135
+ })
136
+ });
137
+ }
138
+ export { ActiveMessagesContext, ActiveMessagesProvider, LanguageLoadContext };
139
+
140
+ //# sourceMappingURL=activeMessages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activeMessages.js","names":[],"sources":["../../src/services/activeMessages.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n type LanguageCatalogue,\n type MessageCatalogue,\n resolveLanguage,\n type Services,\n} from \"@mapcairn/core\";\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\n\n/** The active catalogue, or null outside {@link ActiveMessagesProvider}. */\nexport const ActiveMessagesContext = createContext<MessageCatalogue | null>(\n null,\n);\n\n/** What {@link useLanguageLoad} returns. */\nexport interface LanguageLoad {\n /**\n * The tag whose messages could not be loaded, while the interface is still in\n * the language before it, or null when no load has failed.\n */\n readonly failed: string | null;\n /** Whether a load of {@link LanguageLoad.failed} is under way again. */\n readonly retrying: boolean;\n /** Loads the failed language again. It does nothing when none has failed. */\n readonly retry: () => void;\n}\n\n/**\n * The state of the language load, or null outside {@link ActiveMessagesProvider}\n * and for a host with no `Services.languages`.\n */\nexport const LanguageLoadContext = createContext<LanguageLoad | null>(null);\n\n/** Subscribes to a store whose server snapshot is its client one, as the other hooks do. */\nfunction useStoreValue<T>(\n subscribe: (listener: () => void) => () => void,\n get: () => T,\n): T {\n return useSyncExternalStore(subscribe, get, get);\n}\n\n/**\n * The load in flight, or the last one to finish, for one language, with the\n * inputs it was made under. A failed one is tried again only once the setting\n * or the browser's languages have changed, so a failure never loops.\n */\ninterface LanguageRequest {\n readonly tag: string;\n readonly messages: MessageCatalogue;\n readonly languages: LanguageCatalogue;\n readonly choice: string | null;\n readonly browserLanguages: readonly string[];\n readonly failed: boolean;\n}\n\n/** Whether two language lists hold the same tags in the same order. */\nfunction sameTags(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((tag, index) => tag === b[index]);\n}\n\n/** Whether `request` already answers for `next`, so no load is needed. */\nfunction answers(\n request: LanguageRequest | undefined,\n next: Omit<LanguageRequest, \"failed\">,\n): boolean {\n if (\n request === undefined ||\n request.tag !== next.tag ||\n request.messages !== next.messages ||\n request.languages !== next.languages\n ) {\n return false;\n }\n return (\n !request.failed ||\n (request.choice === next.choice &&\n sameTags(request.browserLanguages, next.browserLanguages))\n );\n}\n\n/** Whether a load returned a promise rather than a ready catalogue. */\nfunction isPending(\n loaded: MessageCatalogue | Promise<MessageCatalogue>,\n): loaded is Promise<MessageCatalogue> {\n return loaded instanceof Promise;\n}\n\n/**\n * Keeps the catalogue the ui speaks, in one place for the whole tree, so a\n * language loads once however many components read it.\n *\n * @remarks Without `Services.languages` the catalogue is `Services.messages`,\n * always. With it, the language is resolved from the person's setting and\n * the browser's languages and then loaded. The first render, and every\n * render until a load finishes, uses `Services.messages` or the last\n * catalogue that loaded, so the first client render matches the server's\n * and a slow load never blanks the text. A load that finishes after\n * another language was asked for is dropped. One that fails keeps the\n * previous catalogue and warns, and the language is requested again the\n * next time the setting or the browser's languages resolve, even to the\n * same tag; a load that is in flight or has succeeded is not repeated.\n * `LanguageLoadContext` says which language failed and offers a retry that\n * asks for it again whatever the setting is. {@link ServicesProvider} mounts it.\n */\nexport function ActiveMessagesProvider({\n services,\n children,\n}: {\n readonly services: Services;\n readonly children: ReactNode;\n}) {\n const { messages, languages, settings, preferences } = services;\n const subscribeSettings = useCallback(\n (listener: () => void) => settings.subscribe(listener),\n [settings],\n );\n const subscribePreferences = useCallback(\n (listener: () => void) => preferences.subscribe(listener),\n [preferences],\n );\n const choice = useStoreValue(subscribeSettings, () =>\n settings.get(),\n ).language;\n const browserLanguages = useStoreValue(subscribePreferences, () =>\n preferences.get(),\n ).languages;\n const [active, setActive] = useState<MessageCatalogue>(messages);\n const requested = useRef<LanguageRequest>(undefined);\n const [failed, setFailed] = useState<string | null>(null);\n const [pending, setPending] = useState<string | null>(null);\n\n const tag =\n languages === undefined\n ? undefined\n : resolveLanguage(\n choice,\n languages.languages.map((language) => language.tag),\n browserLanguages,\n languages.defaultLanguage,\n );\n\n const startLoad = useCallback((inputs: Omit<LanguageRequest, \"failed\">) => {\n const { tag: wanted, languages: offered } = inputs;\n const request = { ...inputs, failed: false };\n requested.current = request;\n setFailed((previous) => (previous === wanted ? previous : null));\n setPending(wanted);\n const succeed = (catalogue: MessageCatalogue) => {\n if (requested.current === request) {\n setActive(catalogue);\n setFailed(null);\n setPending(null);\n }\n };\n const fail = (error: unknown) => {\n if (requested.current === request) {\n requested.current = { ...request, failed: true };\n setFailed(wanted);\n setPending(null);\n }\n console.warn(`Could not load the \"${wanted}\" language.`, error);\n };\n try {\n const loaded = offered.load(wanted);\n if (isPending(loaded)) {\n loaded.then(succeed, fail);\n } else {\n succeed(loaded);\n }\n } catch (error) {\n fail(error);\n }\n }, []);\n\n useEffect(() => {\n if (languages === undefined || tag === undefined) {\n return;\n }\n if (tag === messages.language) {\n requested.current = undefined;\n setActive(messages);\n setFailed(null);\n setPending(null);\n return;\n }\n const inputs = { tag, messages, languages, choice, browserLanguages };\n if (!answers(requested.current, inputs)) {\n startLoad(inputs);\n }\n }, [languages, messages, tag, choice, browserLanguages, startLoad]);\n\n const retry = useCallback(() => {\n const last = requested.current;\n if (last?.failed) {\n startLoad(last);\n }\n }, [startLoad]);\n const load = useMemo(\n () => ({ failed, retrying: failed !== null && pending === failed, retry }),\n [failed, pending, retry],\n );\n\n return (\n <ActiveMessagesContext.Provider\n value={languages === undefined ? messages : active}\n >\n <LanguageLoadContext.Provider\n value={languages === undefined ? null : load}\n >\n {children}\n </LanguageLoadContext.Provider>\n </ActiveMessagesContext.Provider>\n );\n}\n"],"mappings":"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"}
@@ -0,0 +1,78 @@
1
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ // src/services/basemapAvailability.tsx
4
+ /**
5
+ * How long a basemap stays marked unavailable before it is offered normally again.
6
+ *
7
+ * @internal
8
+ */
9
+ var UNAVAILABLE_FOR_MS = 3e5;
10
+ var BasemapAvailabilityContext = createContext(null);
11
+ /**
12
+ * Keeps which basemaps are not working, for the picker (which disables their
13
+ * tiles) and for the app (which marks a basemap whose tiles all failed).
14
+ * {@link ServicesProvider} mounts it, so every component below can read it.
15
+ */
16
+ function BasemapAvailabilityProvider({ children }) {
17
+ const [unavailable, setUnavailable] = useState(() => /* @__PURE__ */ new Set());
18
+ const timers = useRef(/* @__PURE__ */ new Map());
19
+ const forget = useCallback((id) => {
20
+ clearTimeout(timers.current.get(id));
21
+ timers.current.delete(id);
22
+ }, []);
23
+ const markUnavailable = useCallback((id) => {
24
+ forget(id);
25
+ timers.current.set(id, setTimeout(() => {
26
+ timers.current.delete(id);
27
+ setUnavailable((current) => withoutId(current, id));
28
+ }, UNAVAILABLE_FOR_MS));
29
+ setUnavailable((current) => current.has(id) ? current : new Set(current).add(id));
30
+ }, [forget]);
31
+ const clear = useCallback((id) => {
32
+ if (id === void 0) {
33
+ for (const pending of [...timers.current.keys()]) forget(pending);
34
+ setUnavailable((current) => current.size === 0 ? current : /* @__PURE__ */ new Set());
35
+ return;
36
+ }
37
+ forget(id);
38
+ setUnavailable((current) => withoutId(current, id));
39
+ }, [forget]);
40
+ useEffect(() => {
41
+ const pending = timers.current;
42
+ return () => {
43
+ for (const timer of pending.values()) clearTimeout(timer);
44
+ pending.clear();
45
+ };
46
+ }, []);
47
+ const value = useMemo(() => ({
48
+ unavailable,
49
+ markUnavailable,
50
+ clear
51
+ }), [
52
+ unavailable,
53
+ markUnavailable,
54
+ clear
55
+ ]);
56
+ return /* @__PURE__ */ jsx(BasemapAvailabilityContext.Provider, {
57
+ value,
58
+ children
59
+ });
60
+ }
61
+ function withoutId(set, id) {
62
+ if (!set.has(id)) return set;
63
+ const next = new Set(set);
64
+ next.delete(id);
65
+ return next;
66
+ }
67
+ /**
68
+ * Which basemaps are not working right now, and how to mark one. Throws
69
+ * outside a {@link ServicesProvider}, because a missing provider is a wiring bug.
70
+ */
71
+ function useBasemapAvailability() {
72
+ const value = useContext(BasemapAvailabilityContext);
73
+ if (!value) throw new Error("useBasemapAvailability must be used inside a ServicesProvider.");
74
+ return value;
75
+ }
76
+ export { BasemapAvailabilityProvider, UNAVAILABLE_FOR_MS, useBasemapAvailability };
77
+
78
+ //# sourceMappingURL=basemapAvailability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basemapAvailability.js","names":[],"sources":["../../src/services/basemapAvailability.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\n/**\n * How long a basemap stays marked unavailable before it is offered normally again.\n *\n * @internal\n */\nexport const UNAVAILABLE_FOR_MS = 5 * 60 * 1000;\n\n/** What {@link useBasemapAvailability} returns. */\nexport interface BasemapAvailability {\n /** The ids of the basemaps that are not working right now. Held in memory, never stored. */\n readonly unavailable: ReadonlySet<string>;\n /**\n * Marks a basemap unavailable. The mark lapses after\n * {@link UNAVAILABLE_FOR_MS}, so a provider that recovers returns without a\n * reload, and marking it again restarts that time.\n */\n readonly markUnavailable: (id: string) => void;\n /** Marks one basemap, or every basemap when no id is given, available again. */\n readonly clear: (id?: string) => void;\n}\n\nconst BasemapAvailabilityContext = createContext<BasemapAvailability | null>(\n null,\n);\n\n/**\n * Keeps which basemaps are not working, for the picker (which disables their\n * tiles) and for the app (which marks a basemap whose tiles all failed).\n * {@link ServicesProvider} mounts it, so every component below can read it.\n */\nexport function BasemapAvailabilityProvider({\n children,\n}: {\n readonly children: ReactNode;\n}) {\n const [unavailable, setUnavailable] = useState<ReadonlySet<string>>(\n () => new Set(),\n );\n const timers = useRef(new Map<string, ReturnType<typeof setTimeout>>());\n\n const forget = useCallback((id: string) => {\n clearTimeout(timers.current.get(id));\n timers.current.delete(id);\n }, []);\n\n const markUnavailable = useCallback(\n (id: string) => {\n forget(id);\n timers.current.set(\n id,\n setTimeout(() => {\n timers.current.delete(id);\n setUnavailable((current) => withoutId(current, id));\n }, UNAVAILABLE_FOR_MS),\n );\n setUnavailable((current) =>\n current.has(id) ? current : new Set(current).add(id),\n );\n },\n [forget],\n );\n\n const clear = useCallback(\n (id?: string) => {\n if (id === undefined) {\n for (const pending of [...timers.current.keys()]) {\n forget(pending);\n }\n setUnavailable((current) => (current.size === 0 ? current : new Set()));\n return;\n }\n forget(id);\n setUnavailable((current) => withoutId(current, id));\n },\n [forget],\n );\n\n useEffect(() => {\n const pending = timers.current;\n return () => {\n for (const timer of pending.values()) {\n clearTimeout(timer);\n }\n pending.clear();\n };\n }, []);\n\n const value = useMemo(\n () => ({ unavailable, markUnavailable, clear }),\n [unavailable, markUnavailable, clear],\n );\n return (\n <BasemapAvailabilityContext.Provider value={value}>\n {children}\n </BasemapAvailabilityContext.Provider>\n );\n}\n\nfunction withoutId(set: ReadonlySet<string>, id: string): ReadonlySet<string> {\n if (!set.has(id)) {\n return set;\n }\n const next = new Set(set);\n next.delete(id);\n return next;\n}\n\n/**\n * Which basemaps are not working right now, and how to mark one. Throws\n * outside a {@link ServicesProvider}, because a missing provider is a wiring bug.\n */\nexport function useBasemapAvailability(): BasemapAvailability {\n const value = useContext(BasemapAvailabilityContext);\n if (!value) {\n throw new Error(\n \"useBasemapAvailability must be used inside a ServicesProvider.\",\n );\n }\n return value;\n}\n"],"mappings":";;;;;;;;AAkBA,IAAa,qBAAqB;AAgBlC,IAAM,6BAA6B,cACjC,IACF;;;;;;AAOA,SAAgB,4BAA4B,EAC1C,YAGC;CACD,MAAM,CAAC,aAAa,kBAAkB,+BAC9B,IAAI,IAAI,CAChB;CACA,MAAM,SAAS,uBAAO,IAAI,IAA2C,CAAC;CAEtE,MAAM,SAAS,aAAa,OAAe;EACzC,aAAa,OAAO,QAAQ,IAAI,EAAE,CAAC;EACnC,OAAO,QAAQ,OAAO,EAAE;CAC1B,GAAG,CAAC,CAAC;CAEL,MAAM,kBAAkB,aACrB,OAAe;EACd,OAAO,EAAE;EACT,OAAO,QAAQ,IACb,IACA,iBAAiB;GACf,OAAO,QAAQ,OAAO,EAAE;GACxB,gBAAgB,YAAY,UAAU,SAAS,EAAE,CAAC;EACpD,GAAG,kBAAkB,CACvB;EACA,gBAAgB,YACd,QAAQ,IAAI,EAAE,IAAI,UAAU,IAAI,IAAI,OAAO,CAAC,CAAC,IAAI,EAAE,CACrD;CACF,GACA,CAAC,MAAM,CACT;CAEA,MAAM,QAAQ,aACX,OAAgB;EACf,IAAI,OAAO,KAAA,GAAW;GACpB,KAAK,MAAM,WAAW,CAAC,GAAG,OAAO,QAAQ,KAAK,CAAC,GAC7C,OAAO,OAAO;GAEhB,gBAAgB,YAAa,QAAQ,SAAS,IAAI,0BAAU,IAAI,IAAI,CAAE;GACtE;EACF;EACA,OAAO,EAAE;EACT,gBAAgB,YAAY,UAAU,SAAS,EAAE,CAAC;CACpD,GACA,CAAC,MAAM,CACT;CAEA,gBAAgB;EACd,MAAM,UAAU,OAAO;EACvB,aAAa;GACX,KAAK,MAAM,SAAS,QAAQ,OAAO,GACjC,aAAa,KAAK;GAEpB,QAAQ,MAAM;EAChB;CACF,GAAG,CAAC,CAAC;CAEL,MAAM,QAAQ,eACL;EAAE;EAAa;EAAiB;CAAM,IAC7C;EAAC;EAAa;EAAiB;CAAK,CACtC;CACA,OACE,oBAAC,2BAA2B,UAA5B;EAA4C;EACzC;CACkC,CAAA;AAEzC;AAEA,SAAS,UAAU,KAA0B,IAAiC;CAC5E,IAAI,CAAC,IAAI,IAAI,EAAE,GACb,OAAO;CAET,MAAM,OAAO,IAAI,IAAI,GAAG;CACxB,KAAK,OAAO,EAAE;CACd,OAAO;AACT;;;;;AAMA,SAAgB,yBAA8C;CAC5D,MAAM,QAAQ,WAAW,0BAA0B;CACnD,IAAI,CAAC,OACH,MAAM,IAAI,MACR,gEACF;CAEF,OAAO;AACT"}
@@ -0,0 +1,10 @@
1
+ import { EN_GB_CATALOGUE, createMessageCatalogue } from "@mapcairn/core";
2
+ // src/services/englishMessages.ts
3
+ /**
4
+ * The SDK's own English catalogue, for the few pieces that must still speak
5
+ * when a test or a host mounts them without a services provider.
6
+ */
7
+ var ENGLISH_MESSAGES = createMessageCatalogue("en-GB", EN_GB_CATALOGUE, EN_GB_CATALOGUE);
8
+ export { ENGLISH_MESSAGES };
9
+
10
+ //# sourceMappingURL=englishMessages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"englishMessages.js","names":[],"sources":["../../src/services/englishMessages.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n createMessageCatalogue,\n EN_GB_CATALOGUE,\n type MessageCatalogue,\n} from \"@mapcairn/core\";\n\n/**\n * The SDK's own English catalogue, for the few pieces that must still speak\n * when a test or a host mounts them without a services provider.\n */\nexport const ENGLISH_MESSAGES: MessageCatalogue = createMessageCatalogue(\n \"en-GB\",\n EN_GB_CATALOGUE,\n EN_GB_CATALOGUE,\n);\n"],"mappings":";;;;;;AAYA,IAAa,mBAAqC,uBAChD,SACA,iBACA,eACF"}
@@ -0,0 +1,214 @@
1
+ import { ActiveMessagesContext, LanguageLoadContext } from "./activeMessages.js";
2
+ import { ENGLISH_MESSAGES } from "./englishMessages.js";
3
+ import { useOptionalServices, useServices } from "./ServicesProvider.js";
4
+ import { BUILT_IN_BASEMAP_CATALOGUE, formatMessage, resolveText, resolveTheme } from "@mapcairn/core";
5
+ import { useCallback, useContext, useEffect, useSyncExternalStore } from "react";
6
+ // src/services/hooks.ts
7
+ /** The map adapter factory, used by the map host to pick an engine for a basemap. */
8
+ function useMapAdapterFactory() {
9
+ return useServices().createMapAdapter;
10
+ }
11
+ /** The place search provider. Debounce and cancellation live in `useSearch`, not here. */
12
+ function useSearchProvider() {
13
+ return useServices().search;
14
+ }
15
+ /**
16
+ * The suggestion provider, or `undefined` when the host supplies none. The
17
+ * search pill suggests places as the person types only when it exists, so a
18
+ * host without one keeps submit-only search. Nothing is requested until the
19
+ * person has typed.
20
+ */
21
+ function useSuggestionProvider() {
22
+ return useServices().suggestions;
23
+ }
24
+ /**
25
+ * The routing provider, or `undefined` when the host supplies none. The
26
+ * Directions tool needs it, so a host without one gets no such tool. Nothing
27
+ * is requested until a user action asks for a route or area.
28
+ */
29
+ function useRoutingProvider() {
30
+ return useServices().routing;
31
+ }
32
+ /** The location provider. Nothing is requested until a user action calls it. */
33
+ function useLocationProvider() {
34
+ return useServices().location;
35
+ }
36
+ /** The clipboard port. */
37
+ function useClipboard() {
38
+ return useServices().clipboard;
39
+ }
40
+ /** The file saver, which offers a file the ui built as a download. */
41
+ function useFileSaver() {
42
+ return useServices().fileSaver;
43
+ }
44
+ /**
45
+ * The file opener, which asks the person for a file and reads it in the
46
+ * browser, or `undefined` when the host supplies none. Shape import needs it,
47
+ * so a host without one gets no Import control.
48
+ */
49
+ function useFileOpener() {
50
+ return useServices().fileOpener;
51
+ }
52
+ /** The shareable URL state port. */
53
+ function useUrlState() {
54
+ return useServices().url;
55
+ }
56
+ /** The theme source. Most components want {@link useTheme} instead. */
57
+ function useThemeSource() {
58
+ return useServices().theme;
59
+ }
60
+ /**
61
+ * The active message catalogue, for `t`/`plural`/`list` calls that look up
62
+ * copy by key instead of writing it inline. With `Services.languages` it is
63
+ * the language the person's setting, or else the browser's languages, resolve
64
+ * to; the catalogue changes when either does, and keeps the previous one while
65
+ * a lazily loaded language is still arriving. Without it, it is always
66
+ * `Services.messages`.
67
+ */
68
+ function useMessages() {
69
+ const services = useServices();
70
+ return useContext(ActiveMessagesContext) ?? services.messages;
71
+ }
72
+ /**
73
+ * Reads a definition's text in the active language: a message key is looked
74
+ * up in the catalogue, a plain string is returned as written (see
75
+ * `resolveText`). The function is stable while the catalogue is.
76
+ */
77
+ function useResolveText() {
78
+ const messages = useMessages();
79
+ return useCallback((text) => resolveText(messages, text), [messages]);
80
+ }
81
+ /**
82
+ * As {@link useMessages}, but without a {@link ServicesProvider} above it the
83
+ * SDK's English catalogue, so a piece a consumer may render on its own (the
84
+ * skip link, a status message) keeps working. Inside a provider it is the
85
+ * active catalogue.
86
+ */
87
+ function useOptionalMessages() {
88
+ const services = useOptionalServices();
89
+ return useContext(ActiveMessagesContext) ?? services?.messages ?? ENGLISH_MESSAGES;
90
+ }
91
+ /**
92
+ * The languages the host offers, or `undefined` when it offers none to choose
93
+ * between. The Settings panel shows its language switcher only when there is
94
+ * more than one.
95
+ */
96
+ function useLanguages() {
97
+ return useServices().languages;
98
+ }
99
+ /**
100
+ * Whether the messages for the language the person chose have failed to load,
101
+ * and a way to try again, or `undefined` when the host offers no languages. The
102
+ * interface stays in the language it was in until a load succeeds, so a status
103
+ * built from this reads in that language. {@link LanguageLoad.retry} also works
104
+ * when the setting has not changed, which a failed load otherwise waits for.
105
+ */
106
+ function useLanguageLoad() {
107
+ return useContext(LanguageLoadContext) ?? void 0;
108
+ }
109
+ /**
110
+ * Formats a core {@link Message} (a key and its parameters) with the active
111
+ * catalogue, for text a component shows or hands on as a string. The function
112
+ * is stable while the catalogue is.
113
+ */
114
+ function useFormatMessage() {
115
+ const messages = useMessages();
116
+ return useCallback((message) => formatMessage(messages, message), [messages]);
117
+ }
118
+ /** Device and accessibility preferences (reduced motion, fine pointer, save data), updating live. */
119
+ function usePreferences() {
120
+ const { preferences } = useServices();
121
+ const subscribe = useCallback((listener) => preferences.subscribe(listener), [preferences]);
122
+ const getSnapshot = useCallback(() => preferences.get(), [preferences]);
123
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
124
+ }
125
+ /**
126
+ * Whether the browser says the device has a connection, updating live. It is
127
+ * a hint: a device can report online with no route, and `true` where the host
128
+ * gives no signal.
129
+ */
130
+ function useOnline() {
131
+ return usePreferences().online !== false;
132
+ }
133
+ /**
134
+ * Whether Save data mode is on: the person's own choice from Settings when
135
+ * they made one, otherwise the device's signal (a data saver or a very slow
136
+ * connection, where the browser reports one). Re-renders when either changes.
137
+ */
138
+ function useSaveData() {
139
+ const { settings } = useSettings();
140
+ const { saveData } = usePreferences();
141
+ return settings.saveData ?? saveData;
142
+ }
143
+ /**
144
+ * The basemaps on offer: the host's catalogue, or the built-in basemaps when
145
+ * it supplies none.
146
+ */
147
+ function useBasemaps() {
148
+ return useServices().basemaps ?? BUILT_IN_BASEMAP_CATALOGUE;
149
+ }
150
+ /**
151
+ * The data layer catalogue: a store of the host's layer definitions and
152
+ * whether they have loaded. Read it with `useSyncExternalStore` and pass
153
+ * `getState` as the server snapshot, as `useDataLayers` does.
154
+ */
155
+ function useLayers() {
156
+ return useServices().layers;
157
+ }
158
+ /**
159
+ * The store of selected features, or `undefined` when the host supplies none.
160
+ * Nothing in the ui selects a feature without it. A component that needs the
161
+ * set to follow changes reads it with `useSyncExternalStore`, passing
162
+ * `getState` as the server snapshot.
163
+ */
164
+ function useSelectionStore() {
165
+ return useServices().selection;
166
+ }
167
+ /**
168
+ * The query for the features inside a shape, or `undefined` when the host
169
+ * supplies none. Selecting by shape needs it, so a host without one offers no
170
+ * such action. Nothing is requested until a user action asks.
171
+ */
172
+ function useFeatureQuery() {
173
+ return useServices().featureQuery;
174
+ }
175
+ /** Subscribes to the settings store. Re-renders only when a setting changes. */
176
+ function useSettings() {
177
+ const { settings: store } = useServices();
178
+ const subscribe = useCallback((listener) => store.subscribe(listener), [store]);
179
+ const getSnapshot = useCallback(() => store.get(), [store]);
180
+ return {
181
+ settings: useSyncExternalStore(subscribe, getSnapshot, getSnapshot),
182
+ update: useCallback((patch) => {
183
+ store.set(patch);
184
+ }, [store]),
185
+ persistent: store.persistent
186
+ };
187
+ }
188
+ /**
189
+ * Combines the stored theme choice with the system preference, follows system
190
+ * changes live without a reload, and reflects the result onto the document
191
+ * through the theme source.
192
+ */
193
+ function useTheme() {
194
+ const source = useThemeSource();
195
+ const { settings, update } = useSettings();
196
+ const subscribeSystem = useCallback((listener) => source.subscribe(listener), [source]);
197
+ const getSystem = useCallback(() => source.getSystemTheme(), [source]);
198
+ const system = useSyncExternalStore(subscribeSystem, getSystem, getSystem);
199
+ const resolved = resolveTheme(settings.theme, system);
200
+ useEffect(() => {
201
+ source.apply(resolved);
202
+ }, [source, resolved]);
203
+ const setChoice = useCallback((choice) => {
204
+ update({ theme: choice });
205
+ }, [update]);
206
+ return {
207
+ choice: settings.theme,
208
+ resolved,
209
+ setChoice
210
+ };
211
+ }
212
+ export { useBasemaps, useClipboard, useFeatureQuery, useFileOpener, useFileSaver, useFormatMessage, useLanguageLoad, useLanguages, useLayers, useLocationProvider, useMapAdapterFactory, useMessages, useOnline, useOptionalMessages, usePreferences, useResolveText, useRoutingProvider, useSaveData, useSearchProvider, useSelectionStore, useSettings, useSuggestionProvider, useTheme, useThemeSource, useUrlState };
213
+
214
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","names":[],"sources":["../../src/services/hooks.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n type BasemapCatalogue,\n BUILT_IN_BASEMAP_CATALOGUE,\n type ClipboardPort,\n type DefinitionText,\n type DevicePreferencesValue,\n type FeatureQuery,\n type FeatureSelection,\n type FileOpener,\n type FileSaver,\n formatMessage,\n type LanguageCatalogue,\n type LayerCatalogue,\n type LocationProvider,\n type MapAdapterFactory,\n type Message,\n type MessageCatalogue,\n type ResolvedTheme,\n type RoutingProvider,\n resolveText,\n resolveTheme,\n type SearchProvider,\n type Settings,\n type SuggestionProvider,\n type ThemeChoice,\n type ThemeSource,\n type UrlState,\n} from \"@mapcairn/core\";\nimport {\n useCallback,\n useContext,\n useEffect,\n useSyncExternalStore,\n} from \"react\";\nimport {\n ActiveMessagesContext,\n type LanguageLoad,\n LanguageLoadContext,\n} from \"./activeMessages\";\nimport { ENGLISH_MESSAGES } from \"./englishMessages\";\nimport { useOptionalServices, useServices } from \"./ServicesProvider\";\n\n/** The map adapter factory, used by the map host to pick an engine for a basemap. */\nexport function useMapAdapterFactory(): MapAdapterFactory {\n return useServices().createMapAdapter;\n}\n\n/** The place search provider. Debounce and cancellation live in `useSearch`, not here. */\nexport function useSearchProvider(): SearchProvider {\n return useServices().search;\n}\n\n/**\n * The suggestion provider, or `undefined` when the host supplies none. The\n * search pill suggests places as the person types only when it exists, so a\n * host without one keeps submit-only search. Nothing is requested until the\n * person has typed.\n */\nexport function useSuggestionProvider(): SuggestionProvider | undefined {\n return useServices().suggestions;\n}\n\n/**\n * The routing provider, or `undefined` when the host supplies none. The\n * Directions tool needs it, so a host without one gets no such tool. Nothing\n * is requested until a user action asks for a route or area.\n */\nexport function useRoutingProvider(): RoutingProvider | undefined {\n return useServices().routing;\n}\n\n/** The location provider. Nothing is requested until a user action calls it. */\nexport function useLocationProvider(): LocationProvider {\n return useServices().location;\n}\n\n/** The clipboard port. */\nexport function useClipboard(): ClipboardPort {\n return useServices().clipboard;\n}\n\n/** The file saver, which offers a file the ui built as a download. */\nexport function useFileSaver(): FileSaver {\n return useServices().fileSaver;\n}\n\n/**\n * The file opener, which asks the person for a file and reads it in the\n * browser, or `undefined` when the host supplies none. Shape import needs it,\n * so a host without one gets no Import control.\n */\nexport function useFileOpener(): FileOpener | undefined {\n return useServices().fileOpener;\n}\n\n/** The shareable URL state port. */\nexport function useUrlState(): UrlState {\n return useServices().url;\n}\n\n/** The theme source. Most components want {@link useTheme} instead. */\nexport function useThemeSource(): ThemeSource {\n return useServices().theme;\n}\n\n/**\n * The active message catalogue, for `t`/`plural`/`list` calls that look up\n * copy by key instead of writing it inline. With `Services.languages` it is\n * the language the person's setting, or else the browser's languages, resolve\n * to; the catalogue changes when either does, and keeps the previous one while\n * a lazily loaded language is still arriving. Without it, it is always\n * `Services.messages`.\n */\nexport function useMessages(): MessageCatalogue {\n const services = useServices();\n return useContext(ActiveMessagesContext) ?? services.messages;\n}\n\n/**\n * Reads a definition's text in the active language: a message key is looked\n * up in the catalogue, a plain string is returned as written (see\n * `resolveText`). The function is stable while the catalogue is.\n */\nexport function useResolveText(): (text: DefinitionText) => string {\n const messages = useMessages();\n return useCallback((text) => resolveText(messages, text), [messages]);\n}\n\n/**\n * As {@link useMessages}, but without a {@link ServicesProvider} above it the\n * SDK's English catalogue, so a piece a consumer may render on its own (the\n * skip link, a status message) keeps working. Inside a provider it is the\n * active catalogue.\n */\nexport function useOptionalMessages(): MessageCatalogue {\n const services = useOptionalServices();\n const active = useContext(ActiveMessagesContext);\n return active ?? services?.messages ?? ENGLISH_MESSAGES;\n}\n\n/**\n * The languages the host offers, or `undefined` when it offers none to choose\n * between. The Settings panel shows its language switcher only when there is\n * more than one.\n */\nexport function useLanguages(): LanguageCatalogue | undefined {\n return useServices().languages;\n}\n\n/**\n * Whether the messages for the language the person chose have failed to load,\n * and a way to try again, or `undefined` when the host offers no languages. The\n * interface stays in the language it was in until a load succeeds, so a status\n * built from this reads in that language. {@link LanguageLoad.retry} also works\n * when the setting has not changed, which a failed load otherwise waits for.\n */\nexport function useLanguageLoad(): LanguageLoad | undefined {\n return useContext(LanguageLoadContext) ?? undefined;\n}\n\n/**\n * Formats a core {@link Message} (a key and its parameters) with the active\n * catalogue, for text a component shows or hands on as a string. The function\n * is stable while the catalogue is.\n */\nexport function useFormatMessage(): (message: Message) => string {\n const messages = useMessages();\n return useCallback(\n (message: Message) => formatMessage(messages, message),\n [messages],\n );\n}\n\n/** Device and accessibility preferences (reduced motion, fine pointer, save data), updating live. */\nexport function usePreferences(): DevicePreferencesValue {\n const { preferences } = useServices();\n const subscribe = useCallback(\n (listener: () => void) => preferences.subscribe(listener),\n [preferences],\n );\n const getSnapshot = useCallback(() => preferences.get(), [preferences]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\n/**\n * Whether the browser says the device has a connection, updating live. It is\n * a hint: a device can report online with no route, and `true` where the host\n * gives no signal.\n */\nexport function useOnline(): boolean {\n return usePreferences().online !== false;\n}\n\n/**\n * Whether Save data mode is on: the person's own choice from Settings when\n * they made one, otherwise the device's signal (a data saver or a very slow\n * connection, where the browser reports one). Re-renders when either changes.\n */\nexport function useSaveData(): boolean {\n const { settings } = useSettings();\n const { saveData } = usePreferences();\n return settings.saveData ?? saveData;\n}\n\n/**\n * The basemaps on offer: the host's catalogue, or the built-in basemaps when\n * it supplies none.\n */\nexport function useBasemaps(): BasemapCatalogue {\n return useServices().basemaps ?? BUILT_IN_BASEMAP_CATALOGUE;\n}\n\n/**\n * The data layer catalogue: a store of the host's layer definitions and\n * whether they have loaded. Read it with `useSyncExternalStore` and pass\n * `getState` as the server snapshot, as `useDataLayers` does.\n */\nexport function useLayers(): LayerCatalogue {\n return useServices().layers;\n}\n\n/**\n * The store of selected features, or `undefined` when the host supplies none.\n * Nothing in the ui selects a feature without it. A component that needs the\n * set to follow changes reads it with `useSyncExternalStore`, passing\n * `getState` as the server snapshot.\n */\nexport function useSelectionStore(): FeatureSelection | undefined {\n return useServices().selection;\n}\n\n/**\n * The query for the features inside a shape, or `undefined` when the host\n * supplies none. Selecting by shape needs it, so a host without one offers no\n * such action. Nothing is requested until a user action asks.\n */\nexport function useFeatureQuery(): FeatureQuery | undefined {\n return useServices().featureQuery;\n}\n\n/** What {@link useSettings} returns. */\nexport interface UseSettings {\n readonly settings: Settings;\n /** Merges a patch into the stored settings. */\n readonly update: (patch: Partial<Settings>) => void;\n /** False when storage is blocked, so changes will not be remembered. */\n readonly persistent: boolean;\n}\n\n/** Subscribes to the settings store. Re-renders only when a setting changes. */\nexport function useSettings(): UseSettings {\n const { settings: store } = useServices();\n const subscribe = useCallback(\n (listener: () => void) => store.subscribe(listener),\n [store],\n );\n const getSnapshot = useCallback(() => store.get(), [store]);\n const settings = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n const update = useCallback(\n (patch: Partial<Settings>) => {\n store.set(patch);\n },\n [store],\n );\n return { settings, update, persistent: store.persistent };\n}\n\n/** What {@link useTheme} returns. */\nexport interface UseTheme {\n /** What the user chose: system, light or dark. */\n readonly choice: ThemeChoice;\n /** What is actually shown. */\n readonly resolved: ResolvedTheme;\n readonly setChoice: (choice: ThemeChoice) => void;\n}\n\n/**\n * Combines the stored theme choice with the system preference, follows system\n * changes live without a reload, and reflects the result onto the document\n * through the theme source.\n */\nexport function useTheme(): UseTheme {\n const source = useThemeSource();\n const { settings, update } = useSettings();\n const subscribeSystem = useCallback(\n (listener: () => void) => source.subscribe(listener),\n [source],\n );\n const getSystem = useCallback(() => source.getSystemTheme(), [source]);\n const system = useSyncExternalStore(subscribeSystem, getSystem, getSystem);\n const resolved = resolveTheme(settings.theme, system);\n\n useEffect(() => {\n source.apply(resolved);\n }, [source, resolved]);\n\n const setChoice = useCallback(\n (choice: ThemeChoice) => {\n update({ theme: choice });\n },\n [update],\n );\n\n return { choice: settings.theme, resolved, setChoice };\n}\n"],"mappings":"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"}