@defra/interactive-map 0.0.55-alpha → 0.0.57-alpha

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 (502) hide show
  1. package/assets/templates/style-switcher.njk +2 -2
  2. package/dist/esm/im-core.js +1 -1
  3. package/dist/esm/im-shell.js +1 -1
  4. package/dist/umd/im-core.js +1 -1
  5. package/dist/umd/index.js +1 -1
  6. package/docs/api/button-definition.md +11 -0
  7. package/docs/api/context.md +4 -0
  8. package/docs/api.md +20 -2
  9. package/docs/architecture/interactive-map.likec4 +4 -4
  10. package/docs/plugins/datasets.md +11 -0
  11. package/docs/plugins/draw.md +197 -35
  12. package/docs/plugins/interact.md +24 -1
  13. package/docs/plugins/search.md +2 -2
  14. package/docusaurus.config.cjs +25 -3
  15. package/govuk-prototype-kit.config.json +6 -7
  16. package/package.json +20 -23
  17. package/plugins/datasets/dist/esm/im-datasets-esri-adapter.js +1 -1
  18. package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
  19. package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
  20. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  21. package/plugins/datasets/dist/esm/index.js +1 -1
  22. package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
  23. package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
  24. package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
  25. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  26. package/plugins/datasets/dist/umd/index.js +1 -1
  27. package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +18 -16
  28. package/plugins/datasets/src/adapters/esri/esriLayerAdapter.test.js +2 -2
  29. package/plugins/datasets/src/adapters/esri/registry/esriDataset.js +2 -3
  30. package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +1 -1
  31. package/plugins/datasets/src/adapters/loadLayerAdapter.js +2 -20
  32. package/plugins/datasets/src/adapters/loadLayerAdapter.test.js +9 -9
  33. package/plugins/datasets/src/adapters/mapboxStyleLayerAdapter.js +7 -7
  34. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +19 -19
  35. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +1 -1
  36. package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +1 -1
  37. package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +2 -2
  38. package/plugins/datasets/src/adapters/openlayers/layerBuilders.test.js +1 -1
  39. package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.js +21 -21
  40. package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +5 -5
  41. package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +2 -3
  42. package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +2 -2
  43. package/plugins/datasets/src/api/getOpacity.js +1 -2
  44. package/plugins/datasets/src/api/getOpacity.test.js +9 -12
  45. package/plugins/datasets/src/api/getStyle.js +1 -2
  46. package/plugins/datasets/src/api/getStyle.test.js +5 -8
  47. package/plugins/datasets/src/api/removeDataset.js +2 -4
  48. package/plugins/datasets/src/api/removeDataset.test.js +5 -10
  49. package/plugins/datasets/src/api/setData.js +2 -4
  50. package/plugins/datasets/src/api/setData.test.js +6 -14
  51. package/plugins/datasets/src/api/setFeatureVisibility.js +1 -2
  52. package/plugins/datasets/src/api/setFeatureVisibility.test.js +8 -11
  53. package/plugins/datasets/src/components/LayersMenu/LayersMenu.jsx +1 -0
  54. package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.jsx +1 -3
  55. package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.test.jsx +13 -18
  56. package/plugins/datasets/src/index.js +2 -2
  57. package/plugins/datasets/src/index.test.js +8 -1
  58. package/plugins/datasets/src/initialise/DatasetsInit.jsx +37 -26
  59. package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +120 -89
  60. package/plugins/datasets/src/initialise/initialiseDatasets.js +2 -3
  61. package/plugins/datasets/src/initialise/initialiseDatasets.test.js +23 -10
  62. package/plugins/datasets/src/manifest.js +53 -44
  63. package/plugins/datasets/src/manifest.test.js +36 -4
  64. package/plugins/datasets/src/reducers/pluginState.js +5 -5
  65. package/plugins/datasets/src/reducers/pluginState.test.js +21 -20
  66. package/plugins/datasets/src/registry/__mocks__/datasetRegistry.js +7 -6
  67. package/plugins/datasets/src/registry/createDataset.js +2 -2
  68. package/plugins/datasets/src/registry/dataset.js +9 -10
  69. package/plugins/datasets/src/registry/dataset.test.js +63 -64
  70. package/plugins/datasets/src/registry/datasetRegistry.js +39 -10
  71. package/plugins/datasets/src/registry/datasetRegistry.test.js +83 -1
  72. package/plugins/datasets/src/registry/globalDataset.js +9 -17
  73. package/plugins/datasets/src/registry/isVisibleWhen.js +9 -17
  74. package/plugins/datasets/src/registry/isVisibleWhen.test.js +27 -20
  75. package/plugins/datasets/src/registry/mapboxStyleDataset.test.js +26 -27
  76. package/plugins/datasets/src/utils/hasLayersMenu.js +13 -0
  77. package/plugins/datasets/src/utils/hasLayersMenu.test.js +25 -0
  78. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  79. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  80. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  81. package/plugins/draw/dist/esm/index.js +1 -1
  82. package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
  83. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
  84. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  85. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  86. package/plugins/draw/dist/umd/index.js +1 -1
  87. package/plugins/draw/src/DrawInit.jsx +53 -29
  88. package/plugins/draw/src/DrawInit.test.jsx +105 -2
  89. package/plugins/draw/src/adapterEvents.js +78 -44
  90. package/plugins/draw/src/adapters/adapterContract.test.js +3 -3
  91. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +18 -10
  92. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +31 -22
  93. package/plugins/draw/src/adapters/maplibre/drawEvents.js +2 -1
  94. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +13 -12
  95. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +5 -5
  96. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.js +1 -1
  97. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +2 -2
  98. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +6 -9
  99. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +4 -4
  100. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +6 -9
  101. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +1 -1
  102. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.js +8 -14
  103. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.test.js +37 -8
  104. package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +11 -1
  105. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +14 -19
  106. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +41 -4
  107. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +12 -1
  108. package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +3 -1
  109. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.js +9 -10
  110. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.test.js +5 -24
  111. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +10 -7
  112. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +12 -7
  113. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +5 -0
  114. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +7 -3
  115. package/plugins/draw/src/adapters/openlayers/core/styles.test.js +1 -1
  116. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +11 -11
  117. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +15 -15
  118. package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +21 -28
  119. package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +26 -5
  120. package/plugins/draw/src/adapters/openlayers/edit/selectionState.js +5 -6
  121. package/plugins/draw/src/adapters/openlayers/edit/selectionState.test.js +2 -12
  122. package/plugins/draw/src/adapters/openlayers/edit/undoOps.js +9 -0
  123. package/plugins/draw/src/adapters/openlayers/edit/undoOps.test.js +7 -0
  124. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +6 -9
  125. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +3 -3
  126. package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +18 -9
  127. package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +29 -4
  128. package/plugins/draw/src/adapters/openlayers/point/pointOps.js +3 -2
  129. package/plugins/draw/src/adapters/openlayers/point/pointOps.test.js +6 -0
  130. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.js +3 -4
  131. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.test.js +2 -12
  132. package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +1 -1
  133. package/plugins/draw/src/api/createNewShape.js +4 -4
  134. package/plugins/draw/src/api/createNewShape.test.js +1 -1
  135. package/plugins/draw/src/api/editFeature.js +8 -11
  136. package/plugins/draw/src/api/editFeature.test.js +33 -22
  137. package/plugins/draw/src/api/newLine.test.js +3 -3
  138. package/plugins/draw/src/api/newPoint.js +4 -5
  139. package/plugins/draw/src/api/newPoint.test.js +3 -3
  140. package/plugins/draw/src/api/newPolygon.test.js +3 -3
  141. package/plugins/draw/src/api/recheckGeometry.js +32 -0
  142. package/plugins/draw/src/api/recheckGeometry.test.js +55 -0
  143. package/plugins/draw/src/api/setGeometry.js +33 -0
  144. package/plugins/draw/src/api/setGeometry.test.js +48 -0
  145. package/plugins/draw/src/api/split.js +23 -22
  146. package/plugins/draw/src/api/split.test.js +33 -18
  147. package/plugins/draw/src/events.js +265 -77
  148. package/plugins/draw/src/events.test.js +708 -34
  149. package/plugins/draw/src/hooks/useSpatialList.js +10 -11
  150. package/plugins/draw/src/hooks/useSpatialList.test.js +3 -3
  151. package/plugins/draw/src/manifest.js +33 -17
  152. package/plugins/draw/src/manifest.test.js +104 -10
  153. package/plugins/draw/src/reducer.js +31 -9
  154. package/plugins/draw/src/reducer.test.js +35 -3
  155. package/plugins/draw/src/utils/drawModes.js +27 -0
  156. package/plugins/draw/src/utils/drawModes.test.js +27 -0
  157. package/plugins/draw/src/utils/needsDrawTarget.js +18 -0
  158. package/plugins/draw/src/utils/needsDrawTarget.test.js +32 -0
  159. package/plugins/draw/src/utils/touchTarget.js +34 -26
  160. package/plugins/draw/src/utils/touchTarget.test.js +32 -20
  161. package/plugins/draw/src/validation/commitChecks.js +185 -0
  162. package/plugins/draw/src/validation/commitChecks.test.js +205 -0
  163. package/plugins/draw/src/validation/liveDrawChecks.js +11 -11
  164. package/plugins/draw/src/validation/liveDrawChecks.test.js +37 -37
  165. package/plugins/draw/src/validation/liveStroke.js +6 -6
  166. package/plugins/draw/src/validation/liveStroke.test.js +27 -27
  167. package/plugins/draw/src/validation/rules.js +16 -14
  168. package/plugins/draw/src/validation/rules.test.js +5 -5
  169. package/plugins/draw/src/validation/validateGeometry.js +58 -31
  170. package/plugins/draw/src/validation/validateGeometry.test.js +68 -44
  171. package/plugins/draw-es/dist/esm/index.js +1 -0
  172. package/plugins/{beta/draw-es → draw-es}/src/DrawInit.jsx +1 -1
  173. package/plugins/{beta/draw-es → draw-es}/src/events.test.js +1 -1
  174. package/plugins/{beta/draw-es → draw-es}/src/graphic.js +1 -1
  175. package/plugins/frame/dist/esm/index.js +1 -0
  176. package/plugins/{beta/frame → frame}/dist/umd/im-frame-plugin.js +1 -1
  177. package/plugins/{beta/frame → frame}/dist/umd/index.js +1 -1
  178. package/plugins/{beta/frame → frame}/package.json +2 -2
  179. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  180. package/plugins/interact/dist/esm/index.js +1 -1
  181. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  182. package/plugins/interact/dist/umd/index.js +1 -1
  183. package/plugins/interact/src/InteractInit.jsx +3 -3
  184. package/plugins/interact/src/api/enable.test.js +13 -0
  185. package/plugins/interact/src/defaults.js +1 -0
  186. package/plugins/interact/src/hooks/useCrossHairVisibility.js +27 -17
  187. package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +72 -7
  188. package/plugins/interact/src/hooks/useInteractionHandlers.js +3 -5
  189. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +4 -3
  190. package/plugins/interact/src/hooks/useSpatialList.js +16 -17
  191. package/plugins/interact/src/hooks/useSpatialList.test.js +9 -9
  192. package/plugins/interact/src/manifest.js +4 -4
  193. package/plugins/interact/src/manifest.test.js +29 -0
  194. package/plugins/interact/src/reducer.js +7 -2
  195. package/plugins/interact/src/reducer.test.js +12 -2
  196. package/plugins/interact/src/utils/needsTarget.js +20 -0
  197. package/plugins/interact/src/utils/needsTarget.test.js +36 -0
  198. package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
  199. package/plugins/map-key/dist/esm/index.js +1 -1
  200. package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
  201. package/plugins/map-key/dist/umd/index.js +1 -1
  202. package/plugins/map-key/src/components/Key/KeySvgSymbol.jsx +4 -0
  203. package/plugins/map-key/src/components/Key/MapKey.jsx +15 -15
  204. package/plugins/map-key/src/components/Key/MapKey.test.jsx +29 -15
  205. package/plugins/map-key/src/initialise/MapKeyInit.jsx +5 -8
  206. package/plugins/map-key/src/initialise/MapKeyInit.test.jsx +9 -7
  207. package/plugins/map-key/src/manifest.test.js +0 -1
  208. package/plugins/map-key/src/reducers/mergeKeyGroupItems.js +14 -33
  209. package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +34 -50
  210. package/plugins/map-key/src/reducers/pluginState.js +6 -1
  211. package/plugins/map-key/src/reducers/pluginState.test.js +13 -4
  212. package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +1 -0
  213. package/plugins/map-styles/dist/esm/index.js +1 -0
  214. package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -0
  215. package/plugins/{beta/map-styles → map-styles}/dist/umd/index.js +1 -1
  216. package/plugins/{beta/map-styles → map-styles}/src/MapStyles.jsx +3 -3
  217. package/plugins/{beta/map-styles → map-styles}/src/MapStylesInit.jsx +1 -1
  218. package/plugins/menu/dist/esm/index.js +1 -1
  219. package/plugins/scale-bar/dist/esm/index.js +1 -0
  220. package/plugins/{beta/scale-bar → scale-bar}/dist/umd/im-scale-bar-plugin.js +1 -1
  221. package/plugins/{beta/scale-bar → scale-bar}/dist/umd/index.js +1 -1
  222. package/plugins/{beta/scale-bar → scale-bar}/package.json +2 -2
  223. package/plugins/search/dist/esm/im-search-plugin.js +1 -1
  224. package/plugins/search/dist/esm/index.js +1 -1
  225. package/plugins/search/dist/umd/im-search-plugin.js +1 -1
  226. package/plugins/search/dist/umd/index.js +1 -1
  227. package/plugins/search/src/components/Suggestions/Suggestions.jsx +3 -1
  228. package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +11 -0
  229. package/plugins/search/src/utils/markedToElements.jsx +25 -0
  230. package/plugins/search/src/utils/markedToElements.test.jsx +49 -0
  231. package/plugins/search/src/utils/parseOsNamesResults.js +6 -4
  232. package/plugins/search/src/utils/parseOsNamesResults.test.js +18 -0
  233. package/plugins/use-location/dist/esm/index.js +1 -0
  234. package/plugins/{beta/use-location → use-location}/dist/umd/im-use-location-plugin.js +1 -1
  235. package/plugins/{beta/use-location → use-location}/dist/umd/index.js +1 -1
  236. package/providers/esri/dist/esm/index.js +1 -0
  237. package/providers/{beta/esri → esri}/src/esriProvider.js +1 -1
  238. package/providers/{beta/esri → esri}/src/mapEvents.js +2 -2
  239. package/providers/maplibre/dist/esm/index.js +1 -1
  240. package/providers/maplibre/dist/umd/index.js +1 -1
  241. package/providers/maplibre/src/index.js +11 -2
  242. package/providers/maplibre/src/index.test.js +23 -1
  243. package/providers/maplibre/src/utils/detectModuleWorker.js +8 -19
  244. package/providers/maplibre/src/utils/detectModuleWorker.test.js +19 -23
  245. package/providers/maplibre/src/utils/workerUrl.js +12 -0
  246. package/providers/maplibre/src/utils/workerUrl.test.js +14 -1
  247. package/providers/open-names/dist/esm/index.js +1 -0
  248. package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js +1 -1
  249. package/providers/{beta/open-names → open-names}/dist/umd/index.js +1 -1
  250. package/providers/openlayers/dist/esm/index.js +1 -0
  251. package/providers/openlayers/dist/umd/im-openlayers-provider.js +2 -0
  252. package/providers/{beta/openlayers → openlayers}/dist/umd/index.js +1 -1
  253. package/providers/{beta/openlayers → openlayers}/src/index.js +4 -4
  254. package/providers/{beta/openlayers → openlayers}/src/mapEvents.js +2 -2
  255. package/providers/{beta/openlayers → openlayers}/src/mapEvents.test.js +2 -2
  256. package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.js +3 -3
  257. package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.js +1 -1
  258. package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.js +1 -1
  259. package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.js +1 -1
  260. package/rollup.esm.mjs +43 -47
  261. package/sonar-project.properties +1 -1
  262. package/src/App/App.jsx +4 -1
  263. package/src/App/App.test.jsx +6 -0
  264. package/src/App/components/MapButton/MapButton.jsx +6 -0
  265. package/src/App/components/MapButton/MapButton.test.jsx +10 -0
  266. package/src/App/components/Markers/Markers.jsx +3 -5
  267. package/src/App/components/Markers/Markers.test.jsx +9 -11
  268. package/src/App/components/Panel/Panel.jsx +2 -9
  269. package/src/App/hooks/useInterfaceAPI.js +16 -4
  270. package/src/App/hooks/useInterfaceAPI.test.js +66 -1
  271. package/src/App/renderer/PluginInits.jsx +8 -7
  272. package/src/App/renderer/PluginInits.test.jsx +20 -5
  273. package/src/App/renderer/SlotItemsProvider.jsx +33 -0
  274. package/src/App/renderer/SlotItemsProvider.test.jsx +59 -0
  275. package/src/App/renderer/SlotRenderer.jsx +3 -14
  276. package/src/App/renderer/SlotRenderer.test.jsx +11 -44
  277. package/src/App/renderer/mapButtons.js +24 -12
  278. package/src/App/renderer/mapButtons.test.js +32 -1
  279. package/src/App/renderer/mapControls.js +6 -8
  280. package/src/App/renderer/mapControls.test.js +10 -0
  281. package/src/App/renderer/mapPanels.js +16 -19
  282. package/src/App/renderer/mapPanels.test.js +37 -9
  283. package/src/App/renderer/pluginWrapper.js +10 -8
  284. package/src/App/renderer/pluginWrapper.test.js +23 -9
  285. package/src/App/renderer/slotAggregator.js +18 -5
  286. package/src/App/renderer/slotAggregator.test.js +68 -25
  287. package/src/App/renderer/slotHelpers.js +13 -0
  288. package/src/App/renderer/slotHelpers.test.js +16 -1
  289. package/src/App/store/AppProvider.jsx +19 -1
  290. package/src/App/store/AppProvider.test.jsx +41 -0
  291. package/src/App/store/MapProvider.jsx +3 -0
  292. package/src/App/store/MapProvider.test.jsx +24 -0
  293. package/src/App/store/appActionsMap.js +10 -1
  294. package/src/App/store/appActionsMap.test.js +21 -0
  295. package/src/App/store/appDispatchMiddleware.js +29 -17
  296. package/src/App/store/appDispatchMiddleware.test.js +31 -0
  297. package/src/InteractiveMap/parseDataProperties.js +4 -4
  298. package/src/InteractiveMap/parseDataProperties.test.js +62 -6
  299. package/src/config/events.js +4 -2
  300. package/src/config/mapSizeScales.js +3 -0
  301. package/src/scss/tools/_govuk-content.scss +4 -3
  302. package/src/types.js +4 -0
  303. package/src/utils/focusAfterPanelClose.js +9 -0
  304. package/src/utils/focusAfterPanelClose.test.js +40 -0
  305. package/webpack.dev.mjs +9 -3
  306. package/webpack.prod.mjs +11 -4
  307. package/webpack.umd.mjs +6 -7
  308. package/plugins/beta/draw-es/dist/esm/index.js +0 -1
  309. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +0 -1
  310. package/plugins/beta/draw-ml/dist/esm/index.js +0 -1
  311. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +0 -1
  312. package/plugins/beta/draw-ml/dist/umd/index.js +0 -2
  313. package/plugins/beta/draw-ml/src/DrawInit.jsx +0 -85
  314. package/plugins/beta/draw-ml/src/api/addFeature.js +0 -27
  315. package/plugins/beta/draw-ml/src/api/deleteFeature.js +0 -13
  316. package/plugins/beta/draw-ml/src/api/editFeature.js +0 -75
  317. package/plugins/beta/draw-ml/src/api/merge.js +0 -9
  318. package/plugins/beta/draw-ml/src/api/newLine.js +0 -68
  319. package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -68
  320. package/plugins/beta/draw-ml/src/api/split.js +0 -81
  321. package/plugins/beta/draw-ml/src/defaults.js +0 -17
  322. package/plugins/beta/draw-ml/src/draw.scss +0 -26
  323. package/plugins/beta/draw-ml/src/events.js +0 -185
  324. package/plugins/beta/draw-ml/src/index.js +0 -13
  325. package/plugins/beta/draw-ml/src/manifest.js +0 -110
  326. package/plugins/beta/draw-ml/src/mapboxDraw.js +0 -143
  327. package/plugins/beta/draw-ml/src/mapboxSnap.js +0 -321
  328. package/plugins/beta/draw-ml/src/modes/createDrawMode.js +0 -552
  329. package/plugins/beta/draw-ml/src/modes/disabledMode.js +0 -23
  330. package/plugins/beta/draw-ml/src/modes/drawLineMode.js +0 -18
  331. package/plugins/beta/draw-ml/src/modes/drawPolygonMode.js +0 -16
  332. package/plugins/beta/draw-ml/src/modes/editVertex/geometryHelpers.js +0 -135
  333. package/plugins/beta/draw-ml/src/modes/editVertex/helpers.js +0 -2
  334. package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +0 -142
  335. package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +0 -133
  336. package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +0 -142
  337. package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +0 -121
  338. package/plugins/beta/draw-ml/src/modes/editVertexMode.js +0 -495
  339. package/plugins/beta/draw-ml/src/reducer.js +0 -90
  340. package/plugins/beta/draw-ml/src/styles.js +0 -190
  341. package/plugins/beta/draw-ml/src/undoStack.js +0 -50
  342. package/plugins/beta/draw-ml/src/utils/debounce.js +0 -16
  343. package/plugins/beta/draw-ml/src/utils/flattenStyleProperties.js +0 -49
  344. package/plugins/beta/draw-ml/src/utils/snapHelpers.js +0 -200
  345. package/plugins/beta/draw-ml/src/utils/spatial.js +0 -258
  346. package/plugins/beta/draw-ol/dist/css/index.css +0 -1
  347. package/plugins/beta/draw-ol/dist/esm/DrawMode.js +0 -1
  348. package/plugins/beta/draw-ol/dist/esm/EditMode.js +0 -1
  349. package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +0 -1
  350. package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +0 -1
  351. package/plugins/beta/draw-ol/dist/esm/index.js +0 -1
  352. package/plugins/beta/draw-ol/src/DrawInit.jsx +0 -65
  353. package/plugins/beta/draw-ol/src/api/addFeature.js +0 -29
  354. package/plugins/beta/draw-ol/src/api/deleteFeature.js +0 -11
  355. package/plugins/beta/draw-ol/src/api/editFeature.js +0 -50
  356. package/plugins/beta/draw-ol/src/api/newLine.js +0 -44
  357. package/plugins/beta/draw-ol/src/api/newPolygon.js +0 -44
  358. package/plugins/beta/draw-ol/src/core/OLDrawManager.js +0 -153
  359. package/plugins/beta/draw-ol/src/core/featureStore.js +0 -65
  360. package/plugins/beta/draw-ol/src/core/styles.js +0 -98
  361. package/plugins/beta/draw-ol/src/core/undoStack.js +0 -31
  362. package/plugins/beta/draw-ol/src/defaults.js +0 -16
  363. package/plugins/beta/draw-ol/src/draw/DrawMode.js +0 -121
  364. package/plugins/beta/draw-ol/src/draw/drawInput.js +0 -243
  365. package/plugins/beta/draw-ol/src/draw.scss +0 -17
  366. package/plugins/beta/draw-ol/src/edit/EditMode.js +0 -424
  367. package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +0 -229
  368. package/plugins/beta/draw-ol/src/edit/midpointLayer.js +0 -57
  369. package/plugins/beta/draw-ol/src/edit/touchHandler.js +0 -171
  370. package/plugins/beta/draw-ol/src/edit/undoOps.js +0 -95
  371. package/plugins/beta/draw-ol/src/edit/vertexHitTest.js +0 -72
  372. package/plugins/beta/draw-ol/src/edit/vertexLayer.js +0 -49
  373. package/plugins/beta/draw-ol/src/edit/vertexOps.js +0 -99
  374. package/plugins/beta/draw-ol/src/events.js +0 -114
  375. package/plugins/beta/draw-ol/src/index.js +0 -12
  376. package/plugins/beta/draw-ol/src/manifest.js +0 -125
  377. package/plugins/beta/draw-ol/src/olDraw.js +0 -38
  378. package/plugins/beta/draw-ol/src/reducer.js +0 -41
  379. package/plugins/beta/draw-ol/src/snap/snapEngine.js +0 -153
  380. package/plugins/beta/draw-ol/src/snap/snapGeometry.js +0 -177
  381. package/plugins/beta/draw-ol/src/snap/snapIndicator.js +0 -81
  382. package/plugins/beta/draw-ol/src/snap/snapInteraction.js +0 -57
  383. package/plugins/beta/draw-ol/src/snap/snapManager.js +0 -99
  384. package/plugins/beta/draw-ol/src/utils/flattenStyleProperties.js +0 -47
  385. package/plugins/beta/draw-ol/src/utils/geometryHelpers.js +0 -103
  386. package/plugins/beta/draw-ol/src/utils/olCoords.js +0 -35
  387. package/plugins/beta/draw-ol/src/utils/resolveColors.js +0 -39
  388. package/plugins/beta/draw-ol/src/utils/spatial.js +0 -24
  389. package/plugins/beta/draw-ol/src/utils/touchTarget.js +0 -61
  390. package/plugins/beta/frame/dist/esm/index.js +0 -1
  391. package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +0 -1
  392. package/plugins/beta/map-styles/dist/esm/index.js +0 -1
  393. package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +0 -1
  394. package/plugins/beta/scale-bar/dist/esm/index.js +0 -1
  395. package/plugins/beta/use-location/dist/esm/index.js +0 -1
  396. package/plugins/map-key/src/registry/getDatasetRegistry.js +0 -6
  397. package/plugins/map-key/src/registry/getDatasetRegistry.test.js +0 -23
  398. package/plugins/map-key/src/registry/index.js +0 -1
  399. package/plugins/map-key/src/registry/index.test.js +0 -7
  400. package/providers/beta/esri/dist/esm/index.js +0 -1
  401. package/providers/beta/open-names/dist/esm/index.js +0 -1
  402. package/providers/beta/openlayers/dist/esm/index.js +0 -1
  403. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +0 -2
  404. package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +0 -1
  405. /package/plugins/{beta/draw-es → draw-es}/dist/esm/im-draw-es-plugin.js +0 -0
  406. /package/plugins/{beta/draw-es → draw-es}/src/api/addFeature.js +0 -0
  407. /package/plugins/{beta/draw-es → draw-es}/src/api/deleteFeature.js +0 -0
  408. /package/plugins/{beta/draw-es → draw-es}/src/api/editFeature.js +0 -0
  409. /package/plugins/{beta/draw-es → draw-es}/src/api/newPolygon.js +0 -0
  410. /package/plugins/{beta/draw-es → draw-es}/src/api/removeSafeZone.js +0 -0
  411. /package/plugins/{beta/draw-es → draw-es}/src/events.js +0 -0
  412. /package/plugins/{beta/draw-es → draw-es}/src/index.js +0 -0
  413. /package/plugins/{beta/draw-es → draw-es}/src/manifest.js +0 -0
  414. /package/plugins/{beta/draw-es → draw-es}/src/reducer.js +0 -0
  415. /package/plugins/{beta/draw-es → draw-es}/src/sketchViewModel.js +0 -0
  416. /package/plugins/{beta/frame → frame}/dist/css/index.css +0 -0
  417. /package/plugins/{beta/frame → frame}/dist/esm/im-frame-plugin.js +0 -0
  418. /package/plugins/{beta/draw-ml → frame}/dist/umd/index.js.LICENSE.txt +0 -0
  419. /package/plugins/{beta/frame → frame}/src/Frame.jsx +0 -0
  420. /package/plugins/{beta/frame → frame}/src/FrameInit.jsx +0 -0
  421. /package/plugins/{beta/frame → frame}/src/api/addFrame.js +0 -0
  422. /package/plugins/{beta/frame → frame}/src/api/editFeature.js +0 -0
  423. /package/plugins/{beta/frame → frame}/src/config.js +0 -0
  424. /package/plugins/{beta/frame → frame}/src/frame.scss +0 -0
  425. /package/plugins/{beta/frame → frame}/src/index.js +0 -0
  426. /package/plugins/{beta/frame → frame}/src/manifest.js +0 -0
  427. /package/plugins/{beta/frame → frame}/src/reducer.js +0 -0
  428. /package/plugins/{beta/frame → frame}/src/utils.js +0 -0
  429. /package/plugins/{beta/map-styles → map-styles}/dist/css/index.css +0 -0
  430. /package/plugins/{beta/frame → map-styles}/dist/umd/index.js.LICENSE.txt +0 -0
  431. /package/plugins/{beta/map-styles → map-styles}/src/config.js +0 -0
  432. /package/plugins/{beta/map-styles → map-styles}/src/index.js +0 -0
  433. /package/plugins/{beta/map-styles → map-styles}/src/manifest.js +0 -0
  434. /package/plugins/{beta/map-styles → map-styles}/src/mapStyles.scss +0 -0
  435. /package/plugins/{beta/scale-bar → scale-bar}/dist/css/index.css +0 -0
  436. /package/plugins/{beta/scale-bar → scale-bar}/dist/esm/im-scale-bar-plugin.js +0 -0
  437. /package/plugins/{beta/map-styles → scale-bar}/dist/umd/index.js.LICENSE.txt +0 -0
  438. /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.jsx +0 -0
  439. /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.test.jsx +0 -0
  440. /package/plugins/{beta/scale-bar → scale-bar}/src/index.js +0 -0
  441. /package/plugins/{beta/scale-bar → scale-bar}/src/index.test.js +0 -0
  442. /package/plugins/{beta/scale-bar → scale-bar}/src/manifest.js +0 -0
  443. /package/plugins/{beta/scale-bar → scale-bar}/src/scaleBar.scss +0 -0
  444. /package/plugins/{beta/scale-bar → scale-bar}/src/utils.js +0 -0
  445. /package/plugins/{beta/scale-bar → scale-bar}/src/utils.test.js +0 -0
  446. /package/plugins/{beta/use-location → use-location}/dist/esm/im-use-location-plugin.js +0 -0
  447. /package/plugins/{beta/scale-bar → use-location}/dist/umd/index.js.LICENSE.txt +0 -0
  448. /package/plugins/{beta/use-location → use-location}/src/UseLocation.jsx +0 -0
  449. /package/plugins/{beta/use-location → use-location}/src/UseLocationInit.jsx +0 -0
  450. /package/plugins/{beta/use-location → use-location}/src/defaults.js +0 -0
  451. /package/plugins/{beta/use-location → use-location}/src/events.js +0 -0
  452. /package/plugins/{beta/use-location → use-location}/src/index.js +0 -0
  453. /package/plugins/{beta/use-location → use-location}/src/manifest.js +0 -0
  454. /package/plugins/{beta/use-location → use-location}/src/reducer.js +0 -0
  455. /package/providers/{beta/esri → esri}/dist/css/index.css +0 -0
  456. /package/providers/{beta/esri → esri}/dist/esm/im-esri-provider.js +0 -0
  457. /package/providers/{beta/esri → esri}/src/appEvents.js +0 -0
  458. /package/providers/{beta/esri → esri}/src/defaults.js +0 -0
  459. /package/providers/{beta/esri → esri}/src/esriProvider.scss +0 -0
  460. /package/providers/{beta/esri → esri}/src/index.js +0 -0
  461. /package/providers/{beta/esri → esri}/src/utils/coords.js +0 -0
  462. /package/providers/{beta/esri → esri}/src/utils/coords.test.js +0 -0
  463. /package/providers/{beta/esri → esri}/src/utils/detectWebGL.js +0 -0
  464. /package/providers/{beta/esri → esri}/src/utils/esriFixes.js +0 -0
  465. /package/providers/{beta/esri → esri}/src/utils/query.js +0 -0
  466. /package/providers/{beta/esri → esri}/src/utils/spatial.js +0 -0
  467. /package/providers/{beta/esri → esri}/src/utils/spatial.test.js +0 -0
  468. /package/providers/{beta/open-names → open-names}/dist/esm/im-reverse-geocode.js +0 -0
  469. /package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js.LICENSE.txt +0 -0
  470. /package/{plugins/beta/use-location → providers/open-names}/dist/umd/index.js.LICENSE.txt +0 -0
  471. /package/providers/{beta/open-names → open-names}/src/index.js +0 -0
  472. /package/providers/{beta/open-names → open-names}/src/reverseGeocode.js +0 -0
  473. /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.js +0 -0
  474. /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.test.js +0 -0
  475. /package/providers/{beta/openlayers → openlayers}/dist/esm/im-openlayers-provider.js +0 -0
  476. /package/providers/{beta/openlayers → openlayers}/dist/umd/im-openlayers-provider.js.LICENSE.txt +0 -0
  477. /package/providers/{beta/open-names → openlayers}/dist/umd/index.js.LICENSE.txt +0 -0
  478. /package/providers/{beta/openlayers → openlayers}/src/appEvents.js +0 -0
  479. /package/providers/{beta/openlayers → openlayers}/src/appEvents.test.js +0 -0
  480. /package/providers/{beta/openlayers → openlayers}/src/defaults.js +0 -0
  481. /package/providers/{beta/openlayers → openlayers}/src/index.test.js +0 -0
  482. /package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.test.js +0 -0
  483. /package/providers/{beta/openlayers → openlayers}/src/utils/bngProjection.js +0 -0
  484. /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.js +0 -0
  485. /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.test.js +0 -0
  486. /package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.test.js +0 -0
  487. /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.js +0 -0
  488. /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.test.js +0 -0
  489. /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.js +0 -0
  490. /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.test.js +0 -0
  491. /package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.test.js +0 -0
  492. /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.js +0 -0
  493. /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.test.js +0 -0
  494. /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.js +0 -0
  495. /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.test.js +0 -0
  496. /package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.test.js +0 -0
  497. /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.js +0 -0
  498. /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.test.js +0 -0
  499. /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.js +0 -0
  500. /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.test.js +0 -0
  501. /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.js +0 -0
  502. /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.test.js +0 -0
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("defra",[],e):"object"==typeof exports?exports.defra=e():(t.defra=t.defra||{},t.defra.drawPlugin=e())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var t,e,r={738:function(t){t.exports=preactCompat}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t].call(i.exports,i,i.exports,o),i.exports}o.m=r,o.d=function(t,e){for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=function(t){return Promise.all(Object.keys(o.f).reduce(function(e,r){return o.f[r](t,e),e},[]))},o.u=function(t){return{356:"im-draw-ml-adapter",568:"im-draw-plugin",722:"im-draw-ol-adapter"}[t]+".js"},o.miniCssF=function(t){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t={},e="defra.drawPlugin:",o.l=function(r,n,i,u){if(t[r])t[r].push(n);else{var c,a;if(void 0!==i)for(var f=document.getElementsByTagName("script"),l=0;l<f.length;l++){var p=f[l];if(p.getAttribute("src")==r||p.getAttribute("data-webpack")==e+i){c=p;break}}c||(a=!0,(c=document.createElement("script")).charset="utf-8",o.nc&&c.setAttribute("nonce",o.nc),c.setAttribute("data-webpack",e+i),c.src=r),t[r]=[n];var s=function(e,n){c.onerror=c.onload=null,clearTimeout(d);var o=t[r];if(delete t[r],c.parentNode&&c.parentNode.removeChild(c),o&&o.forEach(function(t){return t(n)}),e)return e(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=s.bind(null,c.onerror),c.onload=s.bind(null,c.onload),a&&document.head.appendChild(c)}},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},function(){var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t}(),function(){var t={57:0};o.f.j=function(e,r){var n=o.o(t,e)?t[e]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=t[e]=[r,o]});r.push(n[2]=i);var u=o.p+o.u(e),c=new Error;o.l(u,function(r){if(o.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+i+": "+u+")",c.name="ChunkLoadError",c.type=i,c.request=u,n[1](c)}},"chunk-"+e,e)}};var e=function(e,r){var n,i,u=r[0],c=r[1],a=r[2],f=0;if(u.some(function(e){return 0!==t[e]})){for(n in c)o.o(c,n)&&(o.m[n]=c[n]);a&&a(o)}for(e&&e(r);f<u.length;f++)i=u[f],o.o(t,i)&&t[i]&&t[i][0](),t[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))}();var i={};function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function c(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof f?n:f,l=Object.create(c.prototype);return a(l,"_invoke",function(r,n,o){var i,c,a,f=0,l=o||[],p=!1,s={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,c=0,a=t,s.n=r,u}};function d(r,n){for(c=r,a=n,e=0;!p&&f&&!o&&e<l.length;e++){var o,i=l[e],d=s.p,b=i[2];r>3?(o=b===n)&&(a=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,s.v=n,s.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,s.n=b,c=0))}if(o||r>1)return u;throw p=!0,n}return function(o,l,b){if(f>1)throw TypeError("Generator is already running");for(p&&1===l&&d(l,b),c=l,a=b;(e=c<2?t:a)||!p;){i||(c?c<3?(c>1&&(s.n=-1),d(c,a)):s.n=a:s.v=a);try{if(f=2,i){if(c||(o="next"),e=i[o]){if(!(e=e.call(i,a)))throw TypeError("iterator result is not an object");if(!e.done)return e;a=e.value,c<2&&(c=0)}else 1===c&&(e=i.return)&&e.call(i),c<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=t}else if((e=(p=s.n<0)?a:r.call(n,s))!==u)break}catch(e){i=t,c=1,a=e}finally{f=1}}return{value:e,done:p}}}(r,o,i),!0),l}var u={};function f(){}function l(){}function p(){}e=Object.getPrototypeOf;var s=[][n]?e(e([][n]())):(a(e={},n,function(){return this}),e),d=p.prototype=f.prototype=Object.create(s);function b(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,a(t,o,"GeneratorFunction")),t.prototype=Object.create(d),t}return l.prototype=p,a(d,"constructor",p),a(p,"constructor",l),l.displayName="GeneratorFunction",a(p,o,"GeneratorFunction"),a(d),a(d,o,"Generator"),a(d,n,function(){return this}),a(d,"toString",function(){return"[object Generator]"}),(c=function(){return{w:i,m:b}})()}function a(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}a=function(t,e,r,n){function i(e,r){a(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},a(t,e,r,n)}function f(t,e,r,n,o,i,u){try{var c=t[i](u),a=c.value}catch(t){return void r(t)}c.done?e(a):Promise.resolve(a).then(n,o)}function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?l(Object(r),!0).forEach(function(e){s(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function s(t,e,r){return(e=function(t){var e=function(t){if("object"!=u(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==u(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function d(){var t,e;return p(p({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"draw",load:(t=c().m(function t(){var e;return c().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,o.e(568).then(o.bind(o,957));case 1:return e=t.v.manifest,t.a(2,e)}},t)}),e=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function u(t){f(i,n,o,u,c,"next",t)}function c(t){f(i,n,o,u,c,"throw",t)}u(void 0)})},function(){return e.apply(this,arguments)})})}return o.d(i,{default:function(){return d}}),i.default}()});
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("defra",[],e):"object"==typeof exports?exports.defra=e():(t.defra=t.defra||{},t.defra.drawPlugin=e())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var t,e,r={738:function(t){t.exports=preactCompat}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t].call(i.exports,i,i.exports,o),i.exports}o.m=r,o.d=function(t,e){for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=function(t){return Promise.all(Object.keys(o.f).reduce(function(e,r){return o.f[r](t,e),e},[]))},o.u=function(t){return{356:"im-draw-ml-adapter",568:"im-draw-plugin",722:"im-draw-ol-adapter"}[t]+".js"},o.miniCssF=function(t){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t={},e="defra.drawPlugin:",o.l=function(r,n,i,u){if(t[r])t[r].push(n);else{var c,a;if(void 0!==i)for(var f=document.getElementsByTagName("script"),l=0;l<f.length;l++){var p=f[l];if(p.getAttribute("src")==r||p.getAttribute("data-webpack")==e+i){c=p;break}}c||(a=!0,(c=document.createElement("script")).charset="utf-8",o.nc&&c.setAttribute("nonce",o.nc),c.setAttribute("data-webpack",e+i),c.src=r),t[r]=[n];var s=function(e,n){c.onerror=c.onload=null,clearTimeout(d);var o=t[r];if(delete t[r],c.parentNode&&c.parentNode.removeChild(c),o&&o.forEach(function(t){return t(n)}),e)return e(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=s.bind(null,c.onerror),c.onload=s.bind(null,c.onload),a&&document.head.appendChild(c)}},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},function(){var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t}(),function(){var t={57:0};o.f.j=function(e,r){var n=o.o(t,e)?t[e]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(function(r,o){n=t[e]=[r,o]});r.push(n[2]=i);var u=o.p+o.u(e),c=new Error;o.l(u,function(r){if(o.o(t,e)&&(0!==(n=t[e])&&(t[e]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+i+": "+u+")",c.name="ChunkLoadError",c.type=i,c.request=u,n[1](c)}},"chunk-"+e,e)}};var e=function(e,r){var n,i,u=r[0],c=r[1],a=r[2],f=0;if(u.some(function(e){return 0!==t[e]})){for(n in c)o.o(c,n)&&(o.m[n]=c[n]);a&&a(o)}for(e&&e(r);f<u.length;f++)i=u[f],o.o(t,i)&&t[i]&&t[i][0](),t[i]=0},r=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))}();var i={};function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function c(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof f?n:f,l=Object.create(c.prototype);return a(l,"_invoke",function(r,n,o){var i,c,a,f=0,l=o||[],p=!1,s={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,c=0,a=t,s.n=r,u}};function d(r,n){for(c=r,a=n,e=0;!p&&f&&!o&&e<l.length;e++){var o,i=l[e],d=s.p,b=i[2];r>3?(o=b===n)&&(a=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,s.v=n,s.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,s.n=b,c=0))}if(o||r>1)return u;throw p=!0,n}return function(o,l,b){if(f>1)throw TypeError("Generator is already running");for(p&&1===l&&d(l,b),c=l,a=b;(e=c<2?t:a)||!p;){i||(c?c<3?(c>1&&(s.n=-1),d(c,a)):s.n=a:s.v=a);try{if(f=2,i){if(c||(o="next"),e=i[o]){if(!(e=e.call(i,a)))throw TypeError("iterator result is not an object");if(!e.done)return e;a=e.value,c<2&&(c=0)}else 1===c&&(e=i.return)&&e.call(i),c<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=t}else if((e=(p=s.n<0)?a:r.call(n,s))!==u)break}catch(e){i=t,c=1,a=e}finally{f=1}}return{value:e,done:p}}}(r,o,i),!0),l}var u={};function f(){}function l(){}function p(){}e=Object.getPrototypeOf;var s=[][n]?e(e([][n]())):(a(e={},n,function(){return this}),e),d=p.prototype=f.prototype=Object.create(s);function b(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,a(t,o,"GeneratorFunction")),t.prototype=Object.create(d),t}return l.prototype=p,a(d,"constructor",p),a(p,"constructor",l),l.displayName="GeneratorFunction",a(p,o,"GeneratorFunction"),a(d),a(d,o,"Generator"),a(d,n,function(){return this}),a(d,"toString",function(){return"[object Generator]"}),(c=function(){return{w:i,m:b}})()}function a(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}a=function(t,e,r,n){function i(e,r){a(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},a(t,e,r,n)}function f(t,e,r,n,o,i,u){try{var c=t[i](u),a=c.value}catch(t){return void r(t)}c.done?e(a):Promise.resolve(a).then(n,o)}function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?l(Object(r),!0).forEach(function(e){s(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function s(t,e,r){return(e=function(t){var e=function(t){if("object"!=u(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==u(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function d(){var t,e;return p(p({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"draw",load:(t=c().m(function t(){var e;return c().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,o.e(568).then(o.bind(o,362));case 1:return e=t.v.manifest,t.a(2,e)}},t)}),e=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function u(t){f(i,n,o,u,c,"next",t)}function c(t){f(i,n,o,u,c,"throw",t)}u(void 0)})},function(){return e.apply(this,arguments)})})}return o.d(i,{default:function(){return d}}),i.default}()});
@@ -4,54 +4,77 @@ import { loadDrawAdapter } from './adapters/loadDrawAdapter.js'
4
4
  import { attachEvents } from './events.js'
5
5
  import { useSpatialList } from './hooks/useSpatialList.js'
6
6
  import { APPLICATION_MODE_ID } from './defaults.js'
7
+ import { needsDrawTarget } from './utils/needsDrawTarget.js'
8
+ import { isDrawingMode, isSessionMode } from './utils/drawModes.js'
7
9
  import { logger } from '../../../src/services/logger.js'
8
10
 
9
- // Loads the draw adapter once the map is ready; tears it down (and releases MapControls' D-pad)
10
- // on cleanup.
11
+ // Resolves in a later task, after any effects Preact is still running
12
+ const nextTask = () => new Promise(resolve => setTimeout(resolve, 0))
13
+
14
+ // Loads the draw adapter once per mount, once the map is ready; tears it down (and releases
15
+ // MapControls' D-pad) on unmount.
16
+ //
17
+ // The load starts in a later task. When the adapter is available straight away (its file is
18
+ // cached, or bundled with the plugin), creating it and changing plugin state in the same task
19
+ // as this effect makes Preact 10.29.6+ run the effect again without end (#622). Loading at most
20
+ // once per mount stops a repeat run creating a second adapter.
11
21
  function useLoadDrawAdapter ({ mapState, pluginConfig, pluginState, mapProvider, eventBus, symbolRegistry }) {
22
+ const isMountedRef = useRef(true)
23
+ const isLoadStartedRef = useRef(false)
24
+
12
25
  useEffect(() => {
13
- if (!mapState.isMapReady) {
14
- return undefined
26
+ if (!mapState.isMapReady || isLoadStartedRef.current) {
27
+ return
15
28
  }
29
+ isLoadStartedRef.current = true
16
30
 
17
- let isMounted = true
18
-
19
- loadDrawAdapter(mapProvider, {
20
- mapStyle: mapState.mapStyle,
21
- snapLayers: pluginConfig.snapLayers,
22
- pluginConfig,
23
- events: EVENTS,
24
- eventBus,
25
- symbolRegistry
26
- }).then(adapter => {
27
- if (!isMounted) { return }
31
+ const load = async () => {
32
+ await nextTask()
33
+ if (!isMountedRef.current) {
34
+ return
35
+ }
36
+ const adapter = await loadDrawAdapter(mapProvider, {
37
+ mapStyle: mapState.mapStyle,
38
+ snapLayers: pluginConfig.snapLayers,
39
+ pluginConfig,
40
+ events: EVENTS,
41
+ eventBus,
42
+ symbolRegistry
43
+ })
44
+ // Unmounted while loading: remove it rather than leave it attached to the map
45
+ if (!isMountedRef.current) {
46
+ adapter.remove()
47
+ return
48
+ }
28
49
  mapProvider.draw = adapter
29
50
  pluginState.dispatch({ type: 'SET_HAS_SNAP_LAYERS', payload: pluginConfig.snapLayers?.length > 0 })
30
51
  eventBus.emit('draw:ready')
31
- }).catch((error) => logger.error('[draw] failed to load the draw adapter', error))
32
-
33
- return () => {
34
- isMounted = false
35
- mapProvider.draw?.remove()
36
- mapProvider.draw = null
37
- // Release MapControls' D-pad if this plugin instance still held it.
38
- mapProvider.activeMoveTarget = null
39
52
  }
53
+
54
+ load().catch((error) => logger.error('[draw] failed to load the draw adapter', error))
40
55
  }, [mapState.isMapReady])
56
+
57
+ useEffect(() => () => {
58
+ isMountedRef.current = false
59
+ mapProvider.draw?.remove()
60
+ mapProvider.draw = null
61
+ // Release MapControls' D-pad if this plugin instance still held it.
62
+ mapProvider.activeMoveTarget = null
63
+ }, [])
41
64
  }
42
65
 
43
66
  export const DrawInit = ({ appState, appConfig, mapState, pluginConfig, pluginState, services, mapProvider, buttonConfig, setApplicationMode, clearApplicationMode }) => {
44
67
  const { eventBus, hints, symbolRegistry } = services
45
68
  const { crossHair } = mapState
46
- const isTouchOrKeyboard = ['touch', 'keyboard'].includes(appState.interfaceType)
47
69
 
48
70
  useSpatialList({ mapState, pluginState, services, mapProvider, spatialListRegistry: appState.spatialListRegistry, viewportRef: appState.layoutRefs.viewportRef })
49
71
 
50
72
  // Mirrored in the render body so the crosshair effect's cleanup below can read the CURRENT
51
73
  // shouldShowCrosshair decision, not the stale one its closure captured when it last ran.
52
74
  const shouldShowCrosshairRef = useRef(false)
53
- shouldShowCrosshairRef.current = ['draw_polygon', 'draw_line', 'draw_point'].includes(pluginState.mode) &&
54
- (isTouchOrKeyboard || appState.expandedButtons?.has('mapControls'))
75
+ // Not while a finished shape is held waiting on its check — there's nothing left to place.
76
+ shouldShowCrosshairRef.current = !pluginState.holding && (needsDrawTarget({ appState, pluginState }) ||
77
+ (isDrawingMode(pluginState.mode) && appState.interfaceType === 'keyboard'))
55
78
 
56
79
  useLoadDrawAdapter({ mapState, pluginConfig, pluginState, mapProvider, eventBus, symbolRegistry })
57
80
 
@@ -90,12 +113,12 @@ export const DrawInit = ({ appState, appConfig, mapState, pluginConfig, pluginSt
90
113
  crossHair.hide()
91
114
  }
92
115
  }
93
- }, [pluginState.mode, appState.interfaceType, appState.expandedButtons])
116
+ }, [pluginState.mode, pluginState.holding, appState.interfaceType, appState.expandedButtons])
94
117
 
95
118
  // Keep the active draw/edit session's interface type in sync so the touch offset target and
96
119
  // rubber band update immediately if the input device changes mid-session.
97
120
  useEffect(() => {
98
- if (!['edit_vertex', 'edit_point', 'draw_polygon', 'draw_line', 'draw_point'].includes(pluginState.mode) || !mapProvider.draw) {
121
+ if (!isSessionMode(pluginState.mode) || !mapProvider.draw) {
99
122
  return undefined
100
123
  }
101
124
  mapProvider.draw.setInterfaceType(appState.interfaceType)
@@ -117,7 +140,8 @@ export const DrawInit = ({ appState, appConfig, mapState, pluginConfig, pluginSt
117
140
  pluginState,
118
141
  events: EVENTS,
119
142
  eventBus,
120
- hints
143
+ hints,
144
+ announce: services.announce
121
145
  })
122
146
  }, [mapProvider, appState, pluginState])
123
147
  }
@@ -37,6 +37,12 @@ const makeProps = (overrides = {}) => {
37
37
 
38
38
  const renderInit = async (props) => render(<DrawInit {...props} />)
39
39
 
40
+ // The adapter load starts a task after the effect; let that task and the load finish
41
+ const waitForAdapter = () => act(async () => {
42
+ await Promise.resolve()
43
+ await new Promise((resolve) => setTimeout(resolve, 0))
44
+ })
45
+
40
46
  beforeEach(() => jest.clearAllMocks())
41
47
 
42
48
  describe('adapter lifecycle', () => {
@@ -56,6 +62,7 @@ describe('adapter lifecycle', () => {
56
62
  const { props, adapter } = makeProps()
57
63
 
58
64
  await renderInit(props)
65
+ await waitForAdapter()
59
66
 
60
67
  expect(loadDrawAdapter).toHaveBeenCalledWith(props.mapProvider, expect.objectContaining({
61
68
  mapStyle: props.mapState.mapStyle,
@@ -70,6 +77,56 @@ describe('adapter lifecycle', () => {
70
77
  expect(props.services.eventBus.emit).toHaveBeenCalledWith('draw:ready')
71
78
  })
72
79
 
80
+ describe('with fake timers, to control when the next task runs', () => {
81
+ beforeEach(() => jest.useFakeTimers())
82
+ afterEach(() => jest.useRealTimers())
83
+
84
+ const runNextTask = () => act(async () => {
85
+ jest.runOnlyPendingTimers()
86
+ for (let i = 0; i < 5; i++) { await Promise.resolve() }
87
+ })
88
+
89
+ test('starts loading in a later task, not straight after the effect', async () => {
90
+ const { props, adapter } = makeProps()
91
+
92
+ await renderInit(props)
93
+ await act(async () => { await Promise.resolve() })
94
+
95
+ expect(loadDrawAdapter).not.toHaveBeenCalled()
96
+ expect(props.mapProvider.draw).toBeNull()
97
+
98
+ await runNextTask()
99
+
100
+ expect(loadDrawAdapter).toHaveBeenCalledTimes(1)
101
+ expect(props.mapProvider.draw).toBe(adapter)
102
+ expect(props.pluginState.dispatch).toHaveBeenCalledWith({ type: 'SET_HAS_SNAP_LAYERS', payload: true })
103
+ })
104
+
105
+ test('does not load at all if unmounted before the load starts', async () => {
106
+ const { props } = makeProps()
107
+
108
+ const result = await renderInit(props)
109
+ result.unmount()
110
+ await runNextTask()
111
+
112
+ expect(loadDrawAdapter).not.toHaveBeenCalled()
113
+ expect(props.services.eventBus.emit).not.toHaveBeenCalledWith('draw:ready')
114
+ })
115
+ })
116
+
117
+ test('loads the adapter at most once per mount', async () => {
118
+ const { props } = makeProps()
119
+ const notReady = { ...props.mapState, isMapReady: false }
120
+
121
+ const result = await renderInit(props)
122
+ result.rerender(<DrawInit {...props} mapState={notReady} />)
123
+ result.rerender(<DrawInit {...props} />)
124
+ await waitForAdapter()
125
+
126
+ expect(loadDrawAdapter).toHaveBeenCalledTimes(1)
127
+ expect(props.services.eventBus.emit.mock.calls.filter(([name]) => name === 'draw:ready')).toHaveLength(1)
128
+ })
129
+
73
130
  test('does not load when the map is not ready', async () => {
74
131
  const { props } = makeProps({
75
132
  mapState: { isMapReady: false, mapStyle: {}, crossHair: { isVisible: false, fixAtCenter: jest.fn(), hide: jest.fn() } }
@@ -81,6 +138,7 @@ describe('adapter lifecycle', () => {
81
138
  test('removes the adapter, clears the reference, and releases activeMoveTarget on unmount', async () => {
82
139
  const { props, adapter } = makeProps()
83
140
  const result = await renderInit(props)
141
+ await waitForAdapter()
84
142
  expect(props.mapProvider.draw).toBe(adapter)
85
143
  props.mapProvider.activeMoveTarget = { move: jest.fn(), label: 'vertex' }
86
144
 
@@ -91,15 +149,18 @@ describe('adapter lifecycle', () => {
91
149
  expect(props.mapProvider.activeMoveTarget).toBeNull()
92
150
  })
93
151
 
94
- test('ignores a late-resolving adapter after unmount', async () => {
152
+ test('removes, rather than uses, an adapter that loads after unmount', async () => {
95
153
  const { props, adapter } = makeProps()
96
154
  let resolveAdapter
97
155
  loadDrawAdapter.mockReturnValue(new Promise((resolve) => { resolveAdapter = resolve }))
98
156
 
99
157
  const result = render(<DrawInit {...props} />)
158
+ await waitForAdapter()
159
+ expect(loadDrawAdapter).toHaveBeenCalled()
100
160
  result.unmount()
101
- await act(async () => { resolveAdapter(adapter); await Promise.resolve() })
161
+ await act(async () => { resolveAdapter(adapter) })
102
162
 
163
+ expect(adapter.remove).toHaveBeenCalled()
103
164
  expect(props.mapProvider.draw).toBeNull()
104
165
  expect(props.services.eventBus.emit).not.toHaveBeenCalledWith('draw:ready')
105
166
  })
@@ -202,6 +263,33 @@ describe('crosshair', () => {
202
263
  expect(props.mapState.crossHair.fixAtCenter).toHaveBeenCalled()
203
264
  })
204
265
 
266
+ test('fixes the crosshair at centre while drawing on a keyboard interface', async () => {
267
+ const { props } = makeProps({
268
+ appState: { interfaceType: 'keyboard', mode: null, layoutRefs: { viewportRef: { current: null } } },
269
+ pluginState: { dispatch: jest.fn(), mode: 'draw_line' }
270
+ })
271
+ await renderInit(props)
272
+ expect(props.mapState.crossHair.fixAtCenter).toHaveBeenCalled()
273
+ })
274
+
275
+ test('fixes the crosshair at centre while drawing with a mouse once the map controls are open', async () => {
276
+ const { props } = makeProps({
277
+ appState: { interfaceType: 'mouse', mode: null, expandedButtons: new Set(['mapControls']), layoutRefs: { viewportRef: { current: null } } },
278
+ pluginState: { dispatch: jest.fn(), mode: 'draw_point' }
279
+ })
280
+ await renderInit(props)
281
+ expect(props.mapState.crossHair.fixAtCenter).toHaveBeenCalled()
282
+ })
283
+
284
+ test('leaves the crosshair alone while drawing with a mouse and the map controls closed', async () => {
285
+ const { props } = makeProps({
286
+ appState: { interfaceType: 'mouse', mode: null, expandedButtons: new Set(), layoutRefs: { viewportRef: { current: null } } },
287
+ pluginState: { dispatch: jest.fn(), mode: 'draw_polygon' }
288
+ })
289
+ await renderInit(props)
290
+ expect(props.mapState.crossHair.fixAtCenter).not.toHaveBeenCalled()
291
+ })
292
+
205
293
  test('leaves the crosshair alone when not drawing', async () => {
206
294
  const { props } = makeProps({
207
295
  appState: { interfaceType: 'touch', mode: null, layoutRefs: { viewportRef: { current: null } } },
@@ -226,6 +314,21 @@ describe('crosshair', () => {
226
314
 
227
315
  expect(props.mapState.crossHair.hide).toHaveBeenCalled()
228
316
  })
317
+
318
+ test('hides the crosshair while a finished shape is held waiting on its check', async () => {
319
+ const { props } = makeProps({
320
+ appState: { interfaceType: 'touch', mode: null, layoutRefs: { viewportRef: { current: null } } },
321
+ pluginState: { dispatch: jest.fn(), mode: 'draw_polygon', holding: false }
322
+ })
323
+ const result = await renderInit(props)
324
+ expect(props.mapState.crossHair.fixAtCenter).toHaveBeenCalled()
325
+
326
+ // Holding doesn't change the mode, so the effect must re-run on holding itself
327
+ props.pluginState.holding = true
328
+ result.rerender(<DrawInit {...props} />)
329
+
330
+ expect(props.mapState.crossHair.hide).toHaveBeenCalled()
331
+ })
229
332
  })
230
333
 
231
334
  describe('interface type sync', () => {
@@ -1,47 +1,52 @@
1
1
  /**
2
- * What stage of the draw/edit lifecycle a geometry validation call is running at.
3
- * Passed as `context.phase` through validateGeometry (validation/validateGeometry.js)
4
- * to the default rules (validation/rules.js) and the user's `onGeometryChange` callback.
2
+ * What stage of the draw/edit lifecycle a geometry check is running at. Passed as
3
+ * `context.phase` through validateGeometry (validation/validateGeometry.js) to the
4
+ * default rules (validation/rules.js) and to the user's callbacks:
5
+ * - 'preview' and 'place' go to `onGeometryPreview`, which must answer synchronously
6
+ * - every other phase goes to `onGeometryChange`, which may return a Promise
5
7
  *
6
- * @typedef {'preview' | 'place' | 'create' | 'edit-start' |
7
- * 'commit-add' | 'commit-move' | 'commit-insert' | 'commit-delete'} GeometryChangePhase
8
+ * @typedef {'preview' | 'place' | 'change' | 'create' | 'edit-start' | 'edit-finish' | 'recheck'} GeometryChangePhase
8
9
  *
9
- * 'preview' - live, in-progress feedback (drag / rubber-band); nothing
10
- * has committed yet, and nothing can be vetoed at this stage.
11
- * While drawing, this single check also drives the
12
- * Add-point button (see liveDrawChecks.js) — it isn't only
13
- * a display concern, just never a commit/veto one.
14
- * 'place' - a candidate vertex is genuinely about to be committed
15
- * (a real click/tap/Add-point press), evaluated once,
16
- * synchronously; a HARD_RULES failure vetoes it outright
17
- * and it never appears. Never fires continuously — that's
18
- * 'preview''s job (see above).
19
- * 'create' - a whole new feature just finished being drawn.
20
- * 'edit-start' - an existing feature was just loaded into an edit session;
21
- * nothing has changed yet, this is the baseline check.
22
- * 'commit-add' - a vertex was added while drawing.
23
- * 'commit-move' - a vertex was dragged/nudged while editing.
24
- * 'commit-insert' - a vertex was inserted at a midpoint while editing.
25
- * 'commit-delete' - a vertex was removed while editing.
10
+ * 'preview' - live, in-progress feedback (drag / rubber-band); nothing
11
+ * has committed yet, and nothing can be vetoed at this stage.
12
+ * While drawing, this single check also drives the
13
+ * Add-point button (see liveDrawChecks.js); while editing,
14
+ * it also gates Done.
15
+ * 'place' - a candidate vertex is genuinely about to be committed
16
+ * (a real click/tap/Add-point press), evaluated once,
17
+ * synchronously; a PLACE_RULES failure vetoes it outright
18
+ * and it never appears. Never fires continuously — that's
19
+ * 'preview''s job (see above).
20
+ * 'create' - a whole new feature finished without a passing or pending
21
+ * result for its final geometry (e.g. a new point), or its
22
+ * last result asked for recheckOnFinish, so it's checked now.
23
+ * 'edit-start' - an existing feature was just loaded into an edit session;
24
+ * nothing has changed yet, this is the baseline check.
25
+ * 'edit-finish' - Done was pressed on an edit whose last result asked for
26
+ * recheckOnFinish, so it's checked now.
27
+ * 'recheck' - the unchanged shape is checked again (recheckGeometry), with
28
+ * any detail it was given as `event.detail`.
29
+ * 'change' - the shape changed: a vertex was added, moved, inserted or
30
+ * removed, the whole shape was replaced (setGeometry), or a
31
+ * change was undone.
26
32
  */
27
33
 
34
+ // The phase every committed change reports (see GeometryChangePhase)
35
+ export const CHANGE_PHASE = 'change'
36
+
28
37
  /**
29
- * The single event object passed to a user's `onGeometryChange` callback
30
- * (validateGeometry.js) — `onGeometryChange({ feature, ...context })`. Not every
31
- * field is present on every phase; see each field's own doc below.
38
+ * The event object passed to a user's `onGeometryPreview` or `onGeometryChange`
39
+ * callback — `callback({ feature, ...context })`. Not every field is present on every
40
+ * phase; see each field's own doc below.
32
41
  *
33
- * While drawing, every rubber-band mouse-move invokes this callback ONCE,
42
+ * While drawing, every rubber-band mouse-move invokes `onGeometryPreview` ONCE,
34
43
  * throttled to one call per animation frame, always with `phase: 'preview'` —
35
44
  * even before any vertex is committed, since a location-based rule can be
36
45
  * meaningful against a single candidate point. Its verdict is combined
37
46
  * (internally, in liveDrawChecks.js) with two independently-floored built-in
38
- * checks to drive BOTH the dashed stroke / Done gate AND the Add-point button —
39
- * you don't need to do anything to support both; they share this one call. A
40
- * separate, genuinely momentary call with `phase: 'place'` (see
41
- * GeometryChangePhase) fires only for a real placement attempt, evaluated
42
- * synchronously, never continuously. Earlier versions of this plugin called
43
- * the callback twice per mouse-move (once per phase, for the same instant) —
44
- * that's been unified into the single 'preview' call described here.
47
+ * checks to drive BOTH the dashed stroke AND the Add-point button. A separate,
48
+ * genuinely momentary call with `phase: 'place'` (see GeometryChangePhase) fires
49
+ * only for a real placement attempt, evaluated synchronously, never continuously.
45
50
  *
46
51
  * @typedef {object} GeometryChangeEvent
47
52
  * @property {object} feature - GeoJSON feature representing the shape at this
@@ -50,19 +55,45 @@
50
55
  * committed/candidate feature for that specific change.
51
56
  * @property {GeometryChangePhase} phase - what stage of the draw/edit lifecycle
52
57
  * this is. Always present.
53
- * @property {'draw_polygon' | 'draw_line' | 'edit_vertex'} mode - the active draw
54
- * mode. Always present.
58
+ * @property {'draw_polygon' | 'draw_line' | 'draw_point' | 'edit_vertex' | 'edit_point'} mode -
59
+ * the active draw mode. Always present.
55
60
  * @property {number} [vertexIndex] - index of the vertex being placed, added,
56
- * moved, inserted, or deleted. Present on 'place' and every 'commit-*' phase;
57
- * absent on 'preview', 'create', and 'edit-start' (those have no single vertex
58
- * to point at).
61
+ * moved, inserted, or deleted. Present on 'place' and on a 'change' to a single
62
+ * vertex; absent on 'preview', 'create', 'edit-start', 'edit-finish', 'recheck' and a
63
+ * setGeometry 'change' (those have no single vertex to point at).
59
64
  * @property {number} [numVertices] - count of already-committed vertices,
60
65
  * excluding any in-progress rubber-band cursor point. Present on every
61
66
  * 'preview' call, with no minimum — including 0, against the very first
62
67
  * candidate point, before any vertex is committed. Note this is a lower bar
63
- * than the built-in live rules, which stay skipped until the geometry type's
68
+ * than the built-in preview rules, which stay skipped until the geometry type's
64
69
  * minimum vertex count is reached (self-intersection/area are meaningless
65
70
  * below that).
71
+ * @property {*} [detail] - the value passed to recheckGeometry(detail). Present on
72
+ * 'recheck' only, when one was given.
73
+ */
74
+
75
+ /**
76
+ * What a user's `onGeometryPreview` or `onGeometryChange` callback returns, after
77
+ * normaliseResult (validation/validateGeometry.js). `true`/`undefined` and `false`
78
+ * are shorthands for valid and invalid.
79
+ *
80
+ * @typedef {object} GeometryCheckResult
81
+ * @property {boolean} valid
82
+ * @property {string} [reason] - shown as a hint toast and sent with draw:geometryinvalid
83
+ * @property {string} [announcement] - announced to screen readers in place of draw's own
84
+ * message; the reason then isn't shown as a hint, as the consumer presents it
85
+ * @property {boolean} [recheckOnFinish] - `onGeometryChange` only: don't reuse this
86
+ * result when the shape is finished, check it again with phase 'create'
87
+ */
88
+
89
+ /**
90
+ * The second argument passed to a user's `onGeometryChange` callback —
91
+ * `onGeometryChange(event, { signal, revision })` (validation/commitChecks.js).
92
+ *
93
+ * @typedef {object} GeometryCheckContext
94
+ * @property {AbortSignal} signal - aborted when a newer change is checked or the
95
+ * session ends; a result for an aborted check is ignored.
96
+ * @property {number} revision - increases with every check.
66
97
  */
67
98
 
68
99
  /**
@@ -89,14 +120,17 @@
89
120
  * - Preview (draw/split live update): the in-progress
90
121
  * feature itself (has `coordinates`, no `phase`).
91
122
  * - Commit-level validation: `{ feature, phase, vertexIndex }`
92
- * where phase ∈ 'commit-add' | 'commit-move' |
93
- * 'commit-insert' | 'commit-delete' (see GeometryChangePhase).
94
- * events.js validates these and reverts invalid ones.
123
+ * where phase is 'change' (CHANGE_PHASE, see
124
+ * GeometryChangePhase). events.js checks these
125
+ * (validation/commitChecks.js) to gate Done; it never
126
+ * reverts them.
95
127
  * Listeners must guard for the shape they expect.
96
128
  * INTERFACE_TYPE_CHANGE { interfaceType: 'mouse' | 'touch' | 'keyboard' }
97
- * PLACEMENT_BLOCKED { feature, reason, phase: 'place', mode, vertexIndex } —
129
+ * PLACEMENT_BLOCKED { feature, reason, source, announcement?, phase: 'place', mode, vertexIndex } —
130
+ * built by validateGeometry.js's toPlacementBlocked; source is
131
+ * 'rules' or 'callback'.
98
132
  * a REAL placement attempt (click/tap/Add-point press)
99
- * was rejected by validatePlacement (hard rule or user
133
+ * was rejected by validatePlacement (placement rule or user
100
134
  * callback), evaluated once, synchronously; feature is
101
135
  * the candidate geometry that was refused. Distinct from
102
136
  * CAN_PLACE_CHANGE below, which is a continuous forecast
@@ -25,7 +25,7 @@ const CONTRACT_METHODS = [
25
25
  'setSnapLayers',
26
26
  'isSnapEnabled',
27
27
  'setFeatureProperty',
28
- 'setGeometryValid',
28
+ 'setCanFinish',
29
29
  'setInvalid',
30
30
  'on',
31
31
  'off',
@@ -40,8 +40,8 @@ describe.each([
40
40
  expect(typeof Adapter.prototype[method]).toBe('function')
41
41
  })
42
42
 
43
- test('exposes the _geometryValidator accessor pair (user callback storage)', () => {
44
- const descriptor = Object.getOwnPropertyDescriptor(Adapter.prototype, '_geometryValidator')
43
+ test('exposes the _previewValidator accessor pair (onGeometryPreview storage)', () => {
44
+ const descriptor = Object.getOwnPropertyDescriptor(Adapter.prototype, '_previewValidator')
45
45
  expect(typeof descriptor?.get).toBe('function')
46
46
  expect(typeof descriptor?.set).toBe('function')
47
47
  })
@@ -64,6 +64,7 @@ export const displayedShape = (mode, coordinates) => {
64
64
  * done() / cancel() / undo() / deleteVertex()
65
65
  * nudgeSelectedVertex(dx, dy, isLargeStep)
66
66
  * getVertexItems() / selectVertex(index) / insertVertexAtMidpoint(index)
67
+ * setGeometry(geometry)
67
68
  * get(id) / add(feature) / setStyle(id, properties) / delete(id) / deleteAll()
68
69
  * setSnapEnabled(bool) / setSnapLayers(layers) / isSnapEnabled()
69
70
  * setFeatureProperty(id, property, value) / setDrawingPreviewProperty(property, value)
@@ -202,9 +203,9 @@ export class MaplibreDrawAdapter {
202
203
  const shape = displayedShape(mode, event.coordinates)
203
204
  if (!shape) { return }
204
205
  if (mode === 'draw_polygon' || mode === 'draw_line') {
205
- this._liveDrawChecks.update({ feature: shape.feature, numVertices: shape.numVertices, context: { mode }, onGeometryChange: this._geometryValidator })
206
+ this._liveDrawChecks.update({ feature: shape.feature, numVertices: shape.numVertices, context: { mode }, onGeometryPreview: this._previewValidator })
206
207
  } else {
207
- this._liveStroke.update({ ...shape, context: { mode }, onGeometryChange: this._geometryValidator })
208
+ this._liveStroke.update({ ...shape, context: { mode }, onGeometryPreview: this._previewValidator })
208
209
  }
209
210
  }
210
211
 
@@ -282,16 +283,23 @@ export class MaplibreDrawAdapter {
282
283
  this._map.fire(CUSTOM_DRAW_EVENTS.INSERT_VERTEX_AT_MIDPOINT, { index })
283
284
  }
284
285
 
285
- // Record the current geometry validity so the draw mode can block finish gestures
286
- // (double-click / click-to-close) while the in-progress shape is invalid.
287
- setGeometryValid (valid) {
288
- this._map._drawGeometryValid = valid
286
+ // Replaces the edited shape as a single undoable change. Bridged into
287
+ // the mode via a custom event, same pattern as insertVertexAtMidpoint.
288
+ setGeometry (geometry) {
289
+ this._map.fire(CUSTOM_DRAW_EVENTS.SET_GEOMETRY, { geometry })
289
290
  }
290
291
 
291
- // The api entry points assign the active user validator to the adapter; store it
292
- // on the map (like _drawGeometryValid) so modes can veto placements synchronously.
293
- set _geometryValidator (fn) { this._map._drawGeometryValidator = fn }
294
- get _geometryValidator () { return this._map._drawGeometryValidator }
292
+ // Record whether the in-progress shape can be finished, so the draw mode can block finish
293
+ // gestures (double-click / click-to-close) while its latest check has failed.
294
+ setCanFinish (canFinish) {
295
+ this._map._drawCanFinish = canFinish
296
+ }
297
+
298
+ // The api entry points assign the session's onGeometryPreview callback to the adapter
299
+ // (see validation/commitChecks.js's startCheckSession); store it on the map (like
300
+ // _drawCanFinish) so modes can veto placements synchronously.
301
+ set _previewValidator (fn) { this._map._drawPreviewValidator = fn }
302
+ get _previewValidator () { return this._map._drawPreviewValidator }
295
303
 
296
304
  // Committed-verdict write (events.js, edit mode): routed through the live-stroke
297
305
  // controller so its cached state stays in sync with the rendered layers.