@defra/interactive-map 0.0.56-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 (137) hide show
  1. package/dist/esm/im-core.js +1 -1
  2. package/dist/umd/im-core.js +1 -1
  3. package/dist/umd/index.js +1 -1
  4. package/docs/api/button-definition.md +11 -0
  5. package/docs/api/context.md +2 -0
  6. package/docs/api.md +3 -1
  7. package/docs/plugins/draw.md +189 -33
  8. package/package.json +1 -1
  9. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  10. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  11. package/plugins/datasets/dist/umd/index.js +1 -1
  12. package/plugins/datasets/src/initialise/DatasetsInit.jsx +6 -17
  13. package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +3 -43
  14. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  15. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  16. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  17. package/plugins/draw/dist/esm/index.js +1 -1
  18. package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
  19. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
  20. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  21. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  22. package/plugins/draw/dist/umd/index.js +1 -1
  23. package/plugins/draw/src/DrawInit.jsx +9 -6
  24. package/plugins/draw/src/DrawInit.test.jsx +15 -0
  25. package/plugins/draw/src/adapterEvents.js +78 -44
  26. package/plugins/draw/src/adapters/adapterContract.test.js +3 -3
  27. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +18 -10
  28. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +31 -22
  29. package/plugins/draw/src/adapters/maplibre/drawEvents.js +2 -1
  30. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +13 -12
  31. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +5 -5
  32. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.js +1 -1
  33. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +2 -2
  34. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +6 -9
  35. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +4 -4
  36. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +6 -9
  37. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +1 -1
  38. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.js +8 -14
  39. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.test.js +37 -8
  40. package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +11 -1
  41. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +14 -19
  42. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +41 -4
  43. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +12 -1
  44. package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +3 -1
  45. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.js +9 -10
  46. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.test.js +5 -24
  47. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +10 -7
  48. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +12 -7
  49. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +5 -0
  50. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +7 -3
  51. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +11 -11
  52. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +15 -15
  53. package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +21 -28
  54. package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +26 -5
  55. package/plugins/draw/src/adapters/openlayers/edit/selectionState.js +5 -6
  56. package/plugins/draw/src/adapters/openlayers/edit/selectionState.test.js +2 -12
  57. package/plugins/draw/src/adapters/openlayers/edit/undoOps.js +9 -0
  58. package/plugins/draw/src/adapters/openlayers/edit/undoOps.test.js +7 -0
  59. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +6 -9
  60. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +3 -3
  61. package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +18 -9
  62. package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +29 -4
  63. package/plugins/draw/src/adapters/openlayers/point/pointOps.js +3 -2
  64. package/plugins/draw/src/adapters/openlayers/point/pointOps.test.js +6 -0
  65. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.js +3 -4
  66. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.test.js +2 -12
  67. package/plugins/draw/src/api/createNewShape.js +4 -4
  68. package/plugins/draw/src/api/createNewShape.test.js +1 -1
  69. package/plugins/draw/src/api/editFeature.js +8 -11
  70. package/plugins/draw/src/api/editFeature.test.js +33 -22
  71. package/plugins/draw/src/api/newLine.test.js +3 -3
  72. package/plugins/draw/src/api/newPoint.js +4 -5
  73. package/plugins/draw/src/api/newPoint.test.js +3 -3
  74. package/plugins/draw/src/api/newPolygon.test.js +3 -3
  75. package/plugins/draw/src/api/recheckGeometry.js +32 -0
  76. package/plugins/draw/src/api/recheckGeometry.test.js +55 -0
  77. package/plugins/draw/src/api/setGeometry.js +33 -0
  78. package/plugins/draw/src/api/setGeometry.test.js +48 -0
  79. package/plugins/draw/src/api/split.js +23 -22
  80. package/plugins/draw/src/api/split.test.js +33 -18
  81. package/plugins/draw/src/events.js +265 -77
  82. package/plugins/draw/src/events.test.js +708 -34
  83. package/plugins/draw/src/hooks/useSpatialList.js +10 -11
  84. package/plugins/draw/src/hooks/useSpatialList.test.js +3 -3
  85. package/plugins/draw/src/manifest.js +30 -15
  86. package/plugins/draw/src/manifest.test.js +91 -9
  87. package/plugins/draw/src/reducer.js +31 -9
  88. package/plugins/draw/src/reducer.test.js +35 -3
  89. package/plugins/draw/src/utils/drawModes.js +27 -0
  90. package/plugins/draw/src/utils/drawModes.test.js +27 -0
  91. package/plugins/draw/src/utils/needsDrawTarget.js +1 -5
  92. package/plugins/draw/src/utils/needsDrawTarget.test.js +1 -11
  93. package/plugins/draw/src/utils/touchTarget.js +34 -26
  94. package/plugins/draw/src/utils/touchTarget.test.js +32 -20
  95. package/plugins/draw/src/validation/commitChecks.js +185 -0
  96. package/plugins/draw/src/validation/commitChecks.test.js +205 -0
  97. package/plugins/draw/src/validation/liveDrawChecks.js +11 -11
  98. package/plugins/draw/src/validation/liveDrawChecks.test.js +37 -37
  99. package/plugins/draw/src/validation/liveStroke.js +6 -6
  100. package/plugins/draw/src/validation/liveStroke.test.js +27 -27
  101. package/plugins/draw/src/validation/rules.js +16 -14
  102. package/plugins/draw/src/validation/rules.test.js +5 -5
  103. package/plugins/draw/src/validation/validateGeometry.js +58 -31
  104. package/plugins/draw/src/validation/validateGeometry.test.js +68 -44
  105. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  106. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  107. package/plugins/interact/dist/umd/index.js +1 -1
  108. package/plugins/interact/src/hooks/useInteractionHandlers.js +3 -5
  109. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +4 -3
  110. package/plugins/interact/src/hooks/useSpatialList.js +16 -17
  111. package/plugins/interact/src/hooks/useSpatialList.test.js +9 -9
  112. package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
  113. package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
  114. package/plugins/map-styles/src/MapStyles.jsx +2 -2
  115. package/providers/maplibre/dist/esm/index.js +1 -1
  116. package/providers/maplibre/dist/umd/index.js +1 -1
  117. package/providers/maplibre/src/index.js +11 -2
  118. package/providers/maplibre/src/index.test.js +23 -1
  119. package/providers/maplibre/src/utils/detectModuleWorker.js +8 -19
  120. package/providers/maplibre/src/utils/detectModuleWorker.test.js +19 -23
  121. package/providers/maplibre/src/utils/workerUrl.js +12 -0
  122. package/providers/maplibre/src/utils/workerUrl.test.js +14 -1
  123. package/src/App/components/MapButton/MapButton.jsx +6 -0
  124. package/src/App/components/MapButton/MapButton.test.jsx +10 -0
  125. package/src/App/components/Markers/Markers.jsx +3 -5
  126. package/src/App/components/Markers/Markers.test.jsx +9 -11
  127. package/src/App/components/Panel/Panel.jsx +2 -9
  128. package/src/App/hooks/useInterfaceAPI.js +16 -4
  129. package/src/App/hooks/useInterfaceAPI.test.js +66 -1
  130. package/src/App/renderer/mapButtons.js +2 -1
  131. package/src/App/renderer/mapButtons.test.js +9 -0
  132. package/src/App/store/MapProvider.jsx +3 -0
  133. package/src/App/store/MapProvider.test.jsx +24 -0
  134. package/src/config/mapSizeScales.js +3 -0
  135. package/src/types.js +4 -0
  136. package/src/utils/focusAfterPanelClose.js +9 -0
  137. package/src/utils/focusAfterPanelClose.test.js +40 -0
@@ -1 +1 @@
1
- "use strict";(Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[]).push([[657],{868:function(e,s,i){i.r(s),i.d(s,{manifest:function(){return m}});var t=i(738),a="app:ready",l=i(287),n={small:1,medium:1.5,large:2},m={InitComponent:function(e){var s=e.pluginConfig,i=e.services.eventBus,n=function(){i.emit("map:initmapstyles",s.mapStyles)};return(0,t.useEffect)(function(){return i.on(a,n),function(){return i.off(a,n)}},[]),(0,l.jsx)(l.Fragment,{})},panels:[{id:"mapStyles",label:"Map styles",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},desktop:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},render:function(e){var s=e.mapState,i=e.pluginConfig,t=e.services,a=e.mapProvider,m=s.mapStyle,c=s.mapSize,r=i.mapStyles,p=t.eventBus,d=a.capabilities.supportsMapSizes;return(0,l.jsxs)("div",{className:"im-c-map-styles",children:[(0,l.jsx)("div",{className:"im-c-map-styles__group",children:(0,l.jsx)("div",{className:"im-c-map-styles__inner",children:r.filter(function(e){return e.url}).map(function(e){return(0,l.jsx)("div",{className:"im-c-map-styles__item",children:(0,l.jsxs)("button",{className:"im-c-map-styles__button","aria-pressed":e.id===m.id,onClick:function(){return s=e,void p.emit("map:setstyle",s);var s},children:[(0,l.jsx)("div",{className:"im-c-map-styles__image",children:(0,l.jsx)("img",{src:e.thumbnail||void 0,alt:"",height:"60",width:"60"})}),e.label]})},e.id)})})}),d&&(0,l.jsxs)("div",{className:"im-c-map-styles__group",children:[(0,l.jsx)("h3",{className:"im-c-map-styles__heading",id:"map-text-sizes",children:"Map size"}),(0,l.jsx)("div",{className:"im-c-map-styles__inner",children:["small","medium","large"].map(function(e){return(0,l.jsx)("div",{className:"im-c-map-styles__item",children:(0,l.jsxs)("button",{className:"im-c-map-styles__button",onClick:function(){return s=e,p.emit("map:setsize",s),void p.emit("map:setpixelratio",window.devicePixelRatio*n[s]);var s},"aria-pressed":e===c,children:[(0,l.jsx)("div",{className:"im-c-map-styles__image",children:(0,l.jsxs)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fillRule:"evenodd",children:[(0,l.jsx)("rect",{className:"im-c-map-styles__image-bg",width:"100%",height:"100%"}),(0,l.jsx)("g",{style:{transform:"scale(".concat(n[e],")"),transformOrigin:"8px 52px"},children:(0,l.jsx)("path",{d:"M8 51.785L12.948 38.9h1.837l5.274 12.885h-1.943l-1.503-3.903h-5.387l-1.415 3.903H8zm3.718-5.291h4.368l-1.345-3.569-.914-2.671c-.164.826-.395 1.646-.694 2.46l-1.415 3.78zm15.592 4.139c-3.698 3.143-7.836.271-6.315-2.562.963-1.794 5.529-1.982 6.183-2.21.022-.825.052-2.27-2.241-2.312-1.751-.031-2.242 1.025-2.435 1.776l-1.547-.211c.234-1.102.963-2.856 4.21-2.874 4.037-.022 3.612 2.962 3.612 3.524v2.11c0 .315 0 3.012.501 3.911h-1.652c-.164-.328-.27-.712-.316-1.152zm-.132-3.533c-.907.37-3.444.694-3.964.914-1.293.548-.911 2.399.225 2.637.639.134 3.739.476 3.739-2.971v-.58z"})})]})}),e[0].toUpperCase()+e.slice(1)]})},e)})})]})]})}}],buttons:[{id:"mapStyles",label:"Styles",panelId:"mapStyles",iconId:"map",mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"map",svgContent:'<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/><path d="M15 5.764v15"/><path d="M9 3.236v15"/>'}]}}}]);
1
+ "use strict";(Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[]).push([[657],{868:function(e,s,i){i.r(s),i.d(s,{manifest:function(){return m}});var t=i(738),a="app:ready",l=i(287),n={small:1,medium:1.5,large:2},m={InitComponent:function(e){var s=e.pluginConfig,i=e.services.eventBus,n=function(){i.emit("map:initmapstyles",s.mapStyles)};return(0,t.useEffect)(function(){return i.on(a,n),function(){return i.off(a,n)}},[]),(0,l.jsx)(l.Fragment,{})},panels:[{id:"mapStyles",label:"Map styles",mobile:{slot:"drawer",modal:!0,dismissible:!0},tablet:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},desktop:{slot:"left-top",modal:!0,width:"400px",dismissible:!0},render:function(e){var s=e.mapState,i=e.pluginConfig,t=e.services,a=e.mapProvider,m=s.mapStyle,r=s.mapSize,c=i.mapStyles,d=t.eventBus,p=a.capabilities.supportsMapSizes;return(0,l.jsxs)("div",{className:"im-c-map-styles",children:[(0,l.jsx)("div",{className:"im-c-map-styles__group",children:(0,l.jsx)("div",{className:"im-c-map-styles__inner",children:c.filter(function(e){return e.url}).map(function(e){return(0,l.jsx)("div",{className:"im-c-map-styles__item",children:(0,l.jsxs)("button",{className:"im-c-map-styles__button","aria-pressed":e.id===m.id,onClick:function(){return s=e,void d.emit("map:setstyle",s);var s},children:[(0,l.jsx)("div",{className:"im-c-map-styles__image",children:(0,l.jsx)("img",{src:e.thumbnail||void 0,alt:"",height:"60",width:"60"})}),e.label]})},e.id)})})}),p&&(0,l.jsxs)("div",{className:"im-c-map-styles__group",children:[(0,l.jsx)("h3",{className:"im-c-map-styles__heading",id:"map-text-sizes",children:"Map size"}),(0,l.jsx)("div",{className:"im-c-map-styles__inner",children:["small","medium","large"].map(function(e){return(0,l.jsx)("div",{className:"im-c-map-styles__item",children:(0,l.jsxs)("button",{className:"im-c-map-styles__button",onClick:function(){return s=e,d.emit("map:setsize",s),void d.emit("map:setpixelratio",window.devicePixelRatio*n[s]);var s},"aria-pressed":e===r,children:[(0,l.jsx)("div",{className:"im-c-map-styles__image",children:(0,l.jsxs)("svg",{width:"60",height:"60",viewBox:"0 0 60 60",fillRule:"evenodd","aria-hidden":"true",children:[(0,l.jsx)("rect",{className:"im-c-map-styles__image-bg",width:"100%",height:"100%"}),(0,l.jsx)("g",{style:{transform:"scale(".concat(n[e],")"),transformOrigin:"8px 52px"},children:(0,l.jsx)("path",{d:"M8 51.785L12.948 38.9h1.837l5.274 12.885h-1.943l-1.503-3.903h-5.387l-1.415 3.903H8zm3.718-5.291h4.368l-1.345-3.569-.914-2.671c-.164.826-.395 1.646-.694 2.46l-1.415 3.78zm15.592 4.139c-3.698 3.143-7.836.271-6.315-2.562.963-1.794 5.529-1.982 6.183-2.21.022-.825.052-2.27-2.241-2.312-1.751-.031-2.242 1.025-2.435 1.776l-1.547-.211c.234-1.102.963-2.856 4.21-2.874 4.037-.022 3.612 2.962 3.612 3.524v2.11c0 .315 0 3.012.501 3.911h-1.652c-.164-.328-.27-.712-.316-1.152zm-.132-3.533c-.907.37-3.444.694-3.964.914-1.293.548-.911 2.399.225 2.637.639.134 3.739.476 3.739-2.971v-.58z"})})]})}),e[0].toUpperCase()+e.slice(1)]})},e)})})]})]})}}],buttons:[{id:"mapStyles",label:"Styles",panelId:"mapStyles",iconId:"map",mobile:{slot:"top-left",showLabel:!1},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"map",svgContent:'<path d="M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"/><path d="M15 5.764v15"/><path d="M9 3.236v15"/>'}]}}}]);
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
2
  import { EVENTS } from '../../../src/config/events.js'
3
3
  import { textSizeSvgPath } from './config.js'
4
- import { scaleFactor } from '../../../src/config/appConfig.js'
4
+ import { scaleFactor } from '../../../src/config/mapSizeScales.js'
5
5
 
6
6
  export const MapStyles = ({ mapState, pluginConfig, services, mapProvider }) => {
7
7
  const { mapStyle: currentMapStyle, mapSize: currentMapSize } = mapState
@@ -42,7 +42,7 @@ export const MapStyles = ({ mapState, pluginConfig, services, mapProvider }) =>
42
42
  <div className='im-c-map-styles__item' key={size}>
43
43
  <button className='im-c-map-styles__button' onClick={() => handleMapSizeClick(size)} aria-pressed={size === currentMapSize}>
44
44
  <div className='im-c-map-styles__image'>
45
- <svg width='60' height='60' viewBox='0 0 60 60' fillRule='evenodd'>
45
+ <svg width='60' height='60' viewBox='0 0 60 60' fillRule='evenodd' aria-hidden='true'>
46
46
  <rect className='im-c-map-styles__image-bg' width='100%' height='100%' />
47
47
  <g style={{ transform: `scale(${scaleFactor[size]})`, transformOrigin: '8px 52px' }}>
48
48
  <path d={textSizeSvgPath} />
@@ -1 +1 @@
1
- import r from"@babel/runtime/helpers/regenerator";import e from"@babel/runtime/helpers/objectSpread2";import t from"@babel/runtime/helpers/asyncToGenerator";import n from"@babel/runtime/helpers/createForOfIteratorHelper";var o=function(r){var e=new URL("maplibre-gl/dist/maplibre-gl-worker.mjs",import.meta.url);return e.searchParams.set("v",r),e.href};function a(){if(document.documentMode)return"Internet Explorer is not supported";var r=function(r){if(!window.WebGLRenderingContext)return{isEnabled:!1,error:"WebGL is not supported"};var e,t=document.createElement("canvas"),o=!1,a=n(r);try{for(a.s();!(e=a.n()).done;){var i=e.value;try{if((o=t.getContext(i))&&"function"==typeof o.getParameter)return{isEnabled:!0}}catch(r){}}}catch(r){a.e(r)}finally{a.f()}return{isEnabled:!1,error:"WebGL is supported, but disabled"}}(["webgl2"]);return r.isEnabled?function(){if("function"!=typeof(null===Intl||void 0===Intl?void 0:Intl.supportedValuesOf))return!1;try{return new RegExp("(?<=a)b").test("ab")}catch(r){return!1}}()?function(){if("undefined"==typeof Worker)return!1;var r=!1,e={get type(){return r=!0,"module"}};try{new Worker("blob://",e).terminate()}catch(r){}return r}()?void 0:"Browser does not support module workers":"Browser does not support the JavaScript features MapLibre requires":r.error}function i(){var n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{checkDeviceCapabilities:function(){var r=a();return{isSupported:!r,error:r}},load:(n=t(r().m(function t(){var n,a,u;return r().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,import("maplibre-gl");case 1:return(n=r.v).setWorkerUrl(i.workerUrl||o(n.getVersion())),r.n=2,import(/* webpackChunkName: "im-maplibre-provider" */ "./im-maplibre-provider.js");case 2:return a=r.v.default,u=e(e({},i),{},{crs:"EPSG:4326"}),r.a(2,{MapProvider:a,mapProviderConfig:u,mapFramework:n})}},t)})),function(){return n.apply(this,arguments)})}}export{i as default};
1
+ import r from"@babel/runtime/helpers/regenerator";import e from"@babel/runtime/helpers/objectSpread2";import t from"@babel/runtime/helpers/asyncToGenerator";import n from"@babel/runtime/helpers/createForOfIteratorHelper";var o=function(r){var e=new URL("maplibre-gl/dist/maplibre-gl-worker.mjs",import.meta.url);return e.searchParams.set("v",r),e.href},i=function(r){return new URL(r).pathname.endsWith("/maplibre-gl/dist/maplibre-gl-worker.mjs")},a="[interactive-map]",p=function(){for(var r,e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(r=console).error.apply(r,[a].concat(t))};function s(){if(document.documentMode)return"Internet Explorer is not supported";var r=function(r){if(!window.WebGLRenderingContext)return{isEnabled:!1,error:"WebGL is not supported"};var e,t=document.createElement("canvas"),o=!1,i=n(r);try{for(i.s();!(e=i.n()).done;){var a=e.value;try{if((o=t.getContext(a))&&"function"==typeof o.getParameter)return{isEnabled:!0}}catch(r){}}}catch(r){i.e(r)}finally{i.f()}return{isEnabled:!1,error:"WebGL is supported, but disabled"}}(["webgl2"]);return r.isEnabled?function(){if("function"!=typeof(null===Intl||void 0===Intl?void 0:Intl.supportedValuesOf))return!1;try{return new RegExp("(?<=a)b").test("ab")}catch(r){return!1}}()?"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("width","calc(infinity * 1px)")?void 0:"Browser does not support module workers":"Browser does not support the JavaScript features MapLibre requires":r.error}function u(){var n,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{checkDeviceCapabilities:function(){var r=s();return{isSupported:!r,error:r}},load:(n=t(r().m(function t(){var n,s,u,l;return r().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,import("maplibre-gl");case 1:return n=r.v,s=a.workerUrl||o(n.getVersion()),!a.workerUrl&&i(s)&&p("MapLibre's worker file wasn't included in the build, so the map can't load. Some bundlers, such as Rollup and esbuild, don't copy it: copy node_modules/maplibre-gl/dist/maplibre-gl-worker.mjs to your assets and set the MapLibre provider's workerUrl option. See https://defra.github.io/interactive-map/api#workerurl"),n.setWorkerUrl(s),r.n=2,import(/* webpackChunkName: "im-maplibre-provider" */ "./im-maplibre-provider.js");case 2:return u=r.v.default,l=e(e({},a),{},{crs:"EPSG:4326"}),r.a(2,{MapProvider:u,mapProviderConfig:l,mapFramework:n})}},t)})),function(){return n.apply(this,arguments)})}}export{u as default};
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("defra",[],r):"object"==typeof exports?exports.defra=r():(e.defra=e.defra||{},e.defra.maplibreProvider=r())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var e,r,t={21:function(e,r,t){e.exports=t.p+"im-maplibre-worker.js"}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.m=t,o.d=function(e,r){for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.f={},o.e=function(e){return Promise.all(Object.keys(o.f).reduce(function(r,t){return o.f[t](e,r),r},[]))},o.u=function(e){return{649:"im-maplibre-framework",772:"im-maplibre-provider"}[e]+".js"},o.miniCssF=function(e){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},e={},r="defra.maplibreProvider:",o.l=function(t,n,i,u){if(e[t])e[t].push(n);else{var a,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),l=0;l<f.length;l++){var p=f[l];if(p.getAttribute("src")==t||p.getAttribute("data-webpack")==r+i){a=p;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",r+i),a.src=t),e[t]=[n];var s=function(r,n){a.onerror=a.onload=null,clearTimeout(d);var o=e[t];if(delete e[t],a.parentNode&&a.parentNode.removeChild(a),o&&o.forEach(function(e){return e(n)}),r)return r(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=s.bind(null,a.onerror),a.onload=s.bind(null,a.onload),c&&document.head.appendChild(a)}},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e;o.g.importScripts&&(e=o.g.location+"");var r=o.g.document;if(!e&&r&&(r.currentScript&&"SCRIPT"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var n=t.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=t[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e}(),function(){o.b="undefined"!=typeof document&&document.baseURI||self.location.href;var e={57:0};o.f.j=function(r,t){var n=o.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else{var i=new Promise(function(t,o){n=e[r]=[t,o]});t.push(n[2]=i);var u=o.p+o.u(r),a=new Error;o.l(u,function(t){if(o.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var i=t&&("load"===t.type?"missing":t.type),u=t&&t.target&&t.target.src;a.message="Loading chunk "+r+" failed.\n("+i+": "+u+")",a.name="ChunkLoadError",a.type=i,a.request=u,n[1](a)}},"chunk-"+r,r)}};var r=function(r,t){var n,i,u=t[0],a=t[1],c=t[2],f=0;if(u.some(function(r){return 0!==e[r]})){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);c&&c(o)}for(r&&r(t);f<u.length;f++)i=u[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},t=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))}();var i={};function u(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}o.d(i,{default:function(){return m}});var a=function(e){if(!window.WebGLRenderingContext)return{isEnabled:!1,error:"WebGL is not supported"};var r,t=document.createElement("canvas"),n=!1,o=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return u(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==t.return||t.return()}finally{if(c)throw i}}}}(e);try{for(o.s();!(r=o.n()).done;){var i=r.value;try{if((n=t.getContext(i))&&"function"==typeof n.getParameter)return{isEnabled:!0}}catch(e){}}}catch(e){o.e(e)}finally{o.f()}return{isEnabled:!1,error:"WebGL is supported, but disabled"}},c=function(){if("undefined"==typeof Worker)return!1;var e=!1,r={get type(){return e=!0,"module"}};try{new Worker("blob://",r).terminate()}catch(e){}return e},f=function(e){var r=new URL(o(21),o.b);return r.searchParams.set("v",e),r.href};function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}function p(){var e,r,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function i(t,n,o,i){var c=n&&n.prototype instanceof a?n:a,f=Object.create(c.prototype);return s(f,"_invoke",function(t,n,o){var i,a,c,f=0,l=o||[],p=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(r,t){return i=r,a=0,c=e,s.n=t,u}};function d(t,n){for(a=t,c=n,r=0;!p&&f&&!o&&r<l.length;r++){var o,i=l[r],d=s.p,b=i[2];t>3?(o=b===n)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=t<2&&d<i[1])?(a=0,s.v=n,s.n=i[1]):d<b&&(o=t<3||i[0]>n||n>b)&&(i[4]=t,i[5]=n,s.n=b,a=0))}if(o||t>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),a=l,c=b;(r=a<2?e:c)||!p;){i||(a?a<3?(a>1&&(s.n=-1),d(a,c)):s.n=c:s.v=c);try{if(f=2,i){if(a||(o="next"),r=i[o]){if(!(r=r.call(i,c)))throw TypeError("iterator result is not an object");if(!r.done)return r;c=r.value,a<2&&(a=0)}else 1===a&&(r=i.return)&&r.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((r=(p=s.n<0)?c:t.call(n,s))!==u)break}catch(r){i=e,a=1,c=r}finally{f=1}}return{value:r,done:p}}}(t,o,i),!0),f}var u={};function a(){}function c(){}function f(){}r=Object.getPrototypeOf;var l=[][n]?r(r([][n]())):(s(r={},n,function(){return this}),r),d=f.prototype=a.prototype=Object.create(l);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,s(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return c.prototype=f,s(d,"constructor",f),s(f,"constructor",c),c.displayName="GeneratorFunction",s(f,o,"GeneratorFunction"),s(d),s(d,o,"Generator"),s(d,n,function(){return this}),s(d,"toString",function(){return"[object Generator]"}),(p=function(){return{w:i,m:b}})()}function s(e,r,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}s=function(e,r,t,n){function i(r,t){s(e,r,function(e){return this._invoke(r,t,e)})}r?o?o(e,r,{value:t,enumerable:!n,configurable:!n,writable:!n}):e[r]=t:(i("next",0),i("throw",1),i("return",2))},s(e,r,t,n)}function d(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function b(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?d(Object(t),!0).forEach(function(r){y(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):d(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function y(e,r,t){return(r=function(e){var r=function(e){if("object"!=l(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var t=r.call(e,"string");if("object"!=l(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==l(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function v(e,r,t,n,o,i,u){try{var a=e[i](u),c=a.value}catch(e){return void t(e)}a.done?r(c):Promise.resolve(c).then(n,o)}function m(){var e,r,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{checkDeviceCapabilities:function(){var e=function(){if(document.documentMode)return"Internet Explorer is not supported";var e=a(["webgl2"]);return e.isEnabled?function(){if("function"!=typeof(null===Intl||void 0===Intl?void 0:Intl.supportedValuesOf))return!1;try{return new RegExp("(?<=a)b").test("ab")}catch(e){return!1}}()?c()?void 0:"Browser does not support module workers":"Browser does not support the JavaScript features MapLibre requires":e.error}();return{isSupported:!e,error:e}},load:(e=p().m(function e(){var r,n,i;return p().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(649).then(o.bind(o,868));case 1:return(r=e.v).setWorkerUrl(t.workerUrl||f(r.getVersion())),e.n=2,o.e(772).then(o.bind(o,988));case 2:return n=e.v.default,i=b(b({},t),{},{crs:"EPSG:4326"}),e.a(2,{MapProvider:n,mapProviderConfig:i,mapFramework:r})}},e)}),r=function(){var r=this,t=arguments;return new Promise(function(n,o){var i=e.apply(r,t);function u(e){v(i,n,o,u,a,"next",e)}function a(e){v(i,n,o,u,a,"throw",e)}u(void 0)})},function(){return r.apply(this,arguments)})}}return i.default}()});
2
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("defra",[],r):"object"==typeof exports?exports.defra=r():(e.defra=e.defra||{},e.defra.maplibreProvider=r())}(Object("undefined"!=typeof self?self:this),function(){return function(){"use strict";var e,r,t={21:function(e,r,t){e.exports=t.p+"im-maplibre-worker.js"}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.m=t,o.d=function(e,r){for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.f={},o.e=function(e){return Promise.all(Object.keys(o.f).reduce(function(r,t){return o.f[t](e,r),r},[]))},o.u=function(e){return{649:"im-maplibre-framework",772:"im-maplibre-provider"}[e]+".js"},o.miniCssF=function(e){},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},e={},r="defra.maplibreProvider:",o.l=function(t,n,i,u){if(e[t])e[t].push(n);else{var a,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),l=0;l<f.length;l++){var p=f[l];if(p.getAttribute("src")==t||p.getAttribute("data-webpack")==r+i){a=p;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",o.nc&&a.setAttribute("nonce",o.nc),a.setAttribute("data-webpack",r+i),a.src=t),e[t]=[n];var s=function(r,n){a.onerror=a.onload=null,clearTimeout(d);var o=e[t];if(delete e[t],a.parentNode&&a.parentNode.removeChild(a),o&&o.forEach(function(e){return e(n)}),r)return r(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=s.bind(null,a.onerror),a.onload=s.bind(null,a.onload),c&&document.head.appendChild(a)}},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e;o.g.importScripts&&(e=o.g.location+"");var r=o.g.document;if(!e&&r&&(r.currentScript&&"SCRIPT"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var n=t.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=t[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e}(),function(){o.b="undefined"!=typeof document&&document.baseURI||self.location.href;var e={57:0};o.f.j=function(r,t){var n=o.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else{var i=new Promise(function(t,o){n=e[r]=[t,o]});t.push(n[2]=i);var u=o.p+o.u(r),a=new Error;o.l(u,function(t){if(o.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var i=t&&("load"===t.type?"missing":t.type),u=t&&t.target&&t.target.src;a.message="Loading chunk "+r+" failed.\n("+i+": "+u+")",a.name="ChunkLoadError",a.type=i,a.request=u,n[1](a)}},"chunk-"+r,r)}};var r=function(r,t){var n,i,u=t[0],a=t[1],c=t[2],f=0;if(u.some(function(r){return 0!==e[r]})){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);c&&c(o)}for(r&&r(t);f<u.length;f++)i=u[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},t=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap=Object("undefined"!=typeof self?self:this).webpackChunkdefra_DefraMap||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))}();var i={};function u(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}o.d(i,{default:function(){return j}});var a=function(e){if(!window.WebGLRenderingContext)return{isEnabled:!1,error:"WebGL is not supported"};var r,t=document.createElement("canvas"),n=!1,o=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return u(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==t.return||t.return()}finally{if(c)throw i}}}}(e);try{for(o.s();!(r=o.n()).done;){var i=r.value;try{if((n=t.getContext(i))&&"function"==typeof n.getParameter)return{isEnabled:!0}}catch(e){}}}catch(e){o.e(e)}finally{o.f()}return{isEnabled:!1,error:"WebGL is supported, but disabled"}},c=function(){return"undefined"!=typeof CSS&&"function"==typeof CSS.supports&&CSS.supports("width","calc(infinity * 1px)")},f=function(e){var r=new URL(o(21),o.b);return r.searchParams.set("v",e),r.href},l=function(e){return new URL(e).pathname.endsWith("/maplibre-gl/dist/maplibre-gl-worker.mjs")},p="[interactive-map]",s={warn:function(){for(var e,r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return(e=console).warn.apply(e,[p].concat(t))},error:function(){for(var e,r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];return(e=console).error.apply(e,[p].concat(t))}};function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function b(){var e,r,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function i(t,n,o,i){var c=n&&n.prototype instanceof a?n:a,f=Object.create(c.prototype);return y(f,"_invoke",function(t,n,o){var i,a,c,f=0,l=o||[],p=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(r,t){return i=r,a=0,c=e,s.n=t,u}};function d(t,n){for(a=t,c=n,r=0;!p&&f&&!o&&r<l.length;r++){var o,i=l[r],d=s.p,b=i[2];t>3?(o=b===n)&&(c=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=t<2&&d<i[1])?(a=0,s.v=n,s.n=i[1]):d<b&&(o=t<3||i[0]>n||n>b)&&(i[4]=t,i[5]=n,s.n=b,a=0))}if(o||t>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),a=l,c=b;(r=a<2?e:c)||!p;){i||(a?a<3?(a>1&&(s.n=-1),d(a,c)):s.n=c:s.v=c);try{if(f=2,i){if(a||(o="next"),r=i[o]){if(!(r=r.call(i,c)))throw TypeError("iterator result is not an object");if(!r.done)return r;c=r.value,a<2&&(a=0)}else 1===a&&(r=i.return)&&r.call(i),a<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=e}else if((r=(p=s.n<0)?c:t.call(n,s))!==u)break}catch(r){i=e,a=1,c=r}finally{f=1}}return{value:r,done:p}}}(t,o,i),!0),f}var u={};function a(){}function c(){}function f(){}r=Object.getPrototypeOf;var l=[][n]?r(r([][n]())):(y(r={},n,function(){return this}),r),p=f.prototype=a.prototype=Object.create(l);function s(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,y(e,o,"GeneratorFunction")),e.prototype=Object.create(p),e}return c.prototype=f,y(p,"constructor",f),y(f,"constructor",c),c.displayName="GeneratorFunction",y(f,o,"GeneratorFunction"),y(p),y(p,o,"Generator"),y(p,n,function(){return this}),y(p,"toString",function(){return"[object Generator]"}),(b=function(){return{w:i,m:s}})()}function y(e,r,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}y=function(e,r,t,n){function i(r,t){y(e,r,function(e){return this._invoke(r,t,e)})}r?o?o(e,r,{value:t,enumerable:!n,configurable:!n,writable:!n}):e[r]=t:(i("next",0),i("throw",1),i("return",2))},y(e,r,t,n)}function v(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function m(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?v(Object(t),!0).forEach(function(r){h(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):v(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function h(e,r,t){return(r=function(e){var r=function(e){if("object"!=d(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var t=r.call(e,"string");if("object"!=d(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==d(r)?r:r+""}(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function g(e,r,t,n,o,i,u){try{var a=e[i](u),c=a.value}catch(e){return void t(e)}a.done?r(c):Promise.resolve(c).then(n,o)}var w="MapLibre's worker file wasn't included in the build, so the map can't load. Some bundlers, such as Rollup and esbuild, don't copy it: copy node_modules/maplibre-gl/dist/maplibre-gl-worker.mjs to your assets and set the MapLibre provider's workerUrl option. See https://defra.github.io/interactive-map/api#workerurl";function j(){var e,r,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{checkDeviceCapabilities:function(){var e=function(){if(document.documentMode)return"Internet Explorer is not supported";var e=a(["webgl2"]);return e.isEnabled?function(){if("function"!=typeof(null===Intl||void 0===Intl?void 0:Intl.supportedValuesOf))return!1;try{return new RegExp("(?<=a)b").test("ab")}catch(e){return!1}}()?c()?void 0:"Browser does not support module workers":"Browser does not support the JavaScript features MapLibre requires":e.error}();return{isSupported:!e,error:e}},load:(e=b().m(function e(){var r,n,i,u;return b().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(649).then(o.bind(o,868));case 1:return r=e.v,n=t.workerUrl||f(r.getVersion()),!t.workerUrl&&l(n)&&s.error(w),r.setWorkerUrl(n),e.n=2,o.e(772).then(o.bind(o,988));case 2:return i=e.v.default,u=m(m({},t),{},{crs:"EPSG:4326"}),e.a(2,{MapProvider:i,mapProviderConfig:u,mapFramework:r})}},e)}),r=function(){var r=this,t=arguments;return new Promise(function(n,o){var i=e.apply(r,t);function u(e){g(i,n,o,u,a,"next",e)}function a(e){g(i,n,o,u,a,"throw",e)}u(void 0)})},function(){return r.apply(this,arguments)})}}return i.default}()});
@@ -7,7 +7,12 @@
7
7
 
8
8
  import { getWebGL } from './utils/detectWebgl.js'
9
9
  import { supportsModuleWorkers } from './utils/detectModuleWorker.js'
10
- import { getWorkerUrl } from './utils/workerUrl.js'
10
+ import { getWorkerUrl, isUnbundledWorkerUrl } from './utils/workerUrl.js'
11
+ import { logger } from '../../../src/services/logger.js'
12
+
13
+ const MISSING_WORKER_MESSAGE = "MapLibre's worker file wasn't included in the build, so the map can't load. " +
14
+ "Some bundlers, such as Rollup and esbuild, don't copy it: copy node_modules/maplibre-gl/dist/maplibre-gl-worker.mjs " +
15
+ 'to your assets and set the MapLibre provider\'s workerUrl option. See https://defra.github.io/interactive-map/api#workerurl'
11
16
 
12
17
  /**
13
18
  * Checks whether the browser can parse and run MapLibre. Its newest syntax is class
@@ -70,7 +75,11 @@ export default function createMapLibreProvider (config = {}) {
70
75
  load: async () => {
71
76
  const mapFramework = await import(/* webpackChunkName: "im-maplibre-framework" */ 'maplibre-gl')
72
77
 
73
- mapFramework.setWorkerUrl(config.workerUrl || getWorkerUrl(mapFramework.getVersion()))
78
+ const workerUrl = config.workerUrl || getWorkerUrl(mapFramework.getVersion())
79
+ if (!config.workerUrl && isUnbundledWorkerUrl(workerUrl)) {
80
+ logger.error(MISSING_WORKER_MESSAGE)
81
+ }
82
+ mapFramework.setWorkerUrl(workerUrl)
74
83
 
75
84
  const MapProvider = (await import(/* webpackChunkName: "im-maplibre-provider" */ './maplibreProvider.js')).default
76
85
 
@@ -2,10 +2,16 @@ import createMapLibreProvider from './index.js'
2
2
  import { getWebGL } from './utils/detectWebgl.js'
3
3
  import { supportsModuleWorkers } from './utils/detectModuleWorker.js'
4
4
  import * as maplibreGl from 'maplibre-gl'
5
+ import { isUnbundledWorkerUrl } from './utils/workerUrl.js'
6
+ import { logger } from '../../../src/services/logger.js'
5
7
 
6
8
  jest.mock('./utils/detectWebgl.js', () => ({ getWebGL: jest.fn() }))
7
9
  jest.mock('./utils/detectModuleWorker.js', () => ({ supportsModuleWorkers: jest.fn() }))
8
- jest.mock('./utils/workerUrl.js', () => ({ getWorkerUrl: (version) => `http://localhost/maplibre-gl-worker.mjs?v=${version}` }))
10
+ jest.mock('./utils/workerUrl.js', () => ({
11
+ getWorkerUrl: (version) => `http://localhost/maplibre-gl-worker.mjs?v=${version}`,
12
+ isUnbundledWorkerUrl: jest.fn(() => false)
13
+ }))
14
+ jest.mock('../../../src/services/logger.js', () => ({ logger: { error: jest.fn() } }))
9
15
  jest.mock('maplibre-gl', () => ({ getVersion: () => '6.0.0', setWorkerUrl: jest.fn() }))
10
16
  jest.mock('./maplibreProvider.js', () => ({ default: class MockProvider {} }))
11
17
 
@@ -118,4 +124,20 @@ describe('createMapLibreProvider', () => {
118
124
 
119
125
  expect(maplibreGl.setWorkerUrl).toHaveBeenCalledWith('http://localhost/maplibre-gl-worker.mjs?v=6.0.0')
120
126
  })
127
+
128
+ test("load explains how to set workerUrl when the build didn't include the worker", async () => {
129
+ isUnbundledWorkerUrl.mockReturnValueOnce(true)
130
+
131
+ await createMapLibreProvider().load()
132
+
133
+ expect(logger.error).toHaveBeenCalledWith(expect.stringContaining('workerUrl'))
134
+ expect(maplibreGl.setWorkerUrl).toHaveBeenCalled()
135
+ })
136
+
137
+ test('load does not check the worker URL when workerUrl is provided', async () => {
138
+ await createMapLibreProvider({ workerUrl: '/assets/maplibre-gl-worker.mjs' }).load()
139
+
140
+ expect(isUnbundledWorkerUrl).not.toHaveBeenCalled()
141
+ expect(logger.error).not.toHaveBeenCalled()
142
+ })
121
143
  })
@@ -1,25 +1,14 @@
1
1
  /**
2
2
  * Checks whether the browser can run module workers (`new Worker(url, { type: 'module' })`).
3
3
  *
4
- * Browsers that support module workers read the `type` option while converting the options
5
- * object, before the URL is validated, so the getter is called even though construction fails.
4
+ * Module workers can't be detected without creating a worker, which a Content Security Policy can
5
+ * report as a violation, so this checks for a CSS feature that arrived alongside them instead.
6
+ * Firefox added `infinity` in `calc()` in the same release as module workers (114). Chrome, Edge,
7
+ * Opera, Samsung Internet and Safari had both by the versions the modern-syntax check in index.js
8
+ * already requires, so this rules out the same browsers as checking for module workers would.
6
9
  *
7
10
  * @returns {boolean} true if module workers are supported, false otherwise
8
11
  */
9
- export const supportsModuleWorkers = () => {
10
- if (typeof Worker === 'undefined') {
11
- return false
12
- }
13
- let supported = false
14
- const options = {
15
- get type () {
16
- supported = true
17
- return 'module'
18
- }
19
- }
20
- try {
21
- new Worker('blob://', options).terminate()
22
- } catch (_) { // NOSONAR - construction is expected to fail; only the getter call matters
23
- }
24
- return supported
25
- }
12
+ export const supportsModuleWorkers = () => typeof CSS !== 'undefined' &&
13
+ typeof CSS.supports === 'function' &&
14
+ CSS.supports('width', 'calc(infinity * 1px)')
@@ -1,40 +1,36 @@
1
1
  import { supportsModuleWorkers } from './detectModuleWorker.js'
2
2
 
3
3
  describe('supportsModuleWorkers', () => {
4
+ const originalCSS = globalThis.CSS
4
5
  const originalWorker = globalThis.Worker
5
6
 
6
7
  afterEach(() => {
8
+ globalThis.CSS = originalCSS
7
9
  globalThis.Worker = originalWorker
8
10
  })
9
11
 
10
- it('returns false when Worker is not available', () => {
11
- delete globalThis.Worker
12
- expect(supportsModuleWorkers()).toBe(false)
13
- })
14
-
15
- it('returns true when the Worker constructor reads the type option', () => {
16
- globalThis.Worker = function (url, options) {
17
- if (options.type !== 'module') {
18
- throw new Error('unexpected type')
19
- }
20
- throw new TypeError('Invalid URL')
21
- }
12
+ it('returns true when calc(infinity) is supported', () => {
13
+ globalThis.CSS = { supports: jest.fn(() => true) }
22
14
  expect(supportsModuleWorkers()).toBe(true)
15
+ expect(globalThis.CSS.supports).toHaveBeenCalledWith('width', 'calc(infinity * 1px)')
23
16
  })
24
17
 
25
- it('terminates the worker if construction succeeds', () => {
26
- const terminate = jest.fn()
27
- globalThis.Worker = function (url, options) {
28
- return { type: options.type, terminate }
29
- }
30
- expect(supportsModuleWorkers()).toBe(true)
31
- expect(terminate).toHaveBeenCalled()
18
+ it('returns false when calc(infinity) is not supported', () => {
19
+ globalThis.CSS = { supports: jest.fn(() => false) }
20
+ expect(supportsModuleWorkers()).toBe(false)
32
21
  })
33
22
 
34
- it('returns false when the Worker constructor ignores the type option', () => {
35
- globalThis.Worker = function () {
36
- throw new TypeError('Invalid URL')
37
- }
23
+ it('returns false when CSS.supports is not available', () => {
24
+ delete globalThis.CSS
25
+ expect(supportsModuleWorkers()).toBe(false)
26
+ globalThis.CSS = {}
38
27
  expect(supportsModuleWorkers()).toBe(false)
39
28
  })
29
+
30
+ it('does not create a worker', () => {
31
+ globalThis.CSS = { supports: () => true }
32
+ globalThis.Worker = jest.fn()
33
+ supportsModuleWorkers()
34
+ expect(globalThis.Worker).not.toHaveBeenCalled()
35
+ })
40
36
  })
@@ -13,3 +13,15 @@ export const getWorkerUrl = (version) => {
13
13
  url.searchParams.set('v', version)
14
14
  return url.href
15
15
  }
16
+
17
+ // The path getWorkerUrl()'s URL keeps when a bundler hasn't rewritten it (Rollup and esbuild don't)
18
+ const UNBUNDLED_WORKER_PATH = '/maplibre-gl/dist/maplibre-gl-worker.mjs'
19
+
20
+ /**
21
+ * Whether a worker URL from getWorkerUrl() was left as written by the bundler, so points at a file
22
+ * that was never copied into the build.
23
+ *
24
+ * @param {string} url - The worker URL.
25
+ * @returns {boolean} true if the worker wasn't included in the build.
26
+ */
27
+ export const isUnbundledWorkerUrl = (url) => new URL(url).pathname.endsWith(UNBUNDLED_WORKER_PATH)
@@ -1,4 +1,4 @@
1
- import { getWorkerUrl } from './workerUrl.js'
1
+ import { getWorkerUrl, isUnbundledWorkerUrl } from './workerUrl.js'
2
2
 
3
3
  describe('getWorkerUrl', () => {
4
4
  test('resolves the maplibre-gl worker file relative to this module', () => {
@@ -12,3 +12,16 @@ describe('getWorkerUrl', () => {
12
12
  expect(new URL(getWorkerUrl('6.0.0')).searchParams.get('v')).toBe('6.0.0')
13
13
  })
14
14
  })
15
+
16
+ describe('isUnbundledWorkerUrl', () => {
17
+ test('is true for a URL a bundler left as written', () => {
18
+ expect(isUnbundledWorkerUrl('https://example.com/assets/maplibre-gl/dist/maplibre-gl-worker.mjs?v=6.0.0')).toBe(true)
19
+ expect(isUnbundledWorkerUrl(getWorkerUrl('6.0.0'))).toBe(true)
20
+ })
21
+
22
+ test('is false for a worker file a bundler copied into the build', () => {
23
+ expect(isUnbundledWorkerUrl('https://example.com/assets/maplibre-gl-worker-BrB25tGK.mjs')).toBe(false)
24
+ expect(isUnbundledWorkerUrl('https://example.com/dist/113b7bc9b8a3c9226e4e.mjs')).toBe(false)
25
+ expect(isUnbundledWorkerUrl('https://example.com/umd/im-maplibre-worker.76230dd4.js')).toBe(false)
26
+ })
27
+ })
@@ -127,6 +127,7 @@ const getControlledElement = ({ idPrefix, panelId, buttonId, hasMenu, panelRole
127
127
  * @param {boolean} options.isDisabled - Whether the button is disabled
128
128
  * @param {boolean} options.isPressed - Whether the button is in pressed state
129
129
  * @param {boolean} options.isExpanded - Whether content controlled by button is expanded
130
+ * @param {boolean} [options.isBusy] - Whether the action behind the button is in progress (aria-busy)
130
131
  * @param {boolean} options.isPanelOpen - Whether the controlled panel is open
131
132
  * @param {boolean} options.isPopupOpen - Whether the popup menu is open
132
133
  * @param {Object|null} options.controlledElement - The element controlled by this button
@@ -147,6 +148,7 @@ const buildButtonProps = ({
147
148
  isDisabled,
148
149
  isPressed,
149
150
  isExpanded,
151
+ isBusy,
150
152
  isPanelOpen,
151
153
  isPopupOpen,
152
154
  controlledElement,
@@ -174,6 +176,7 @@ const buildButtonProps = ({
174
176
  'aria-disabled': isDisabled || undefined,
175
177
  'aria-expanded': ariaExpanded,
176
178
  'aria-pressed': typeof isPressed === 'boolean' ? isPressed : undefined,
179
+ 'aria-busy': isBusy || undefined,
177
180
  'aria-controls': controlledElement?.id ?? ariaControls,
178
181
  'aria-haspopup': HASPOPUP_ROLES.has(controlledElement?.role) ? controlledElement.role : undefined,
179
182
  ...(href
@@ -196,6 +199,7 @@ const buildButtonProps = ({
196
199
  * @param {boolean} [props.isDisabled=false] - Whether the button is disabled
197
200
  * @param {boolean} [props.isPressed] - Whether the button is in pressed state (aria-pressed)
198
201
  * @param {boolean} [props.isExpanded] - Whether content controlled by the button is expanded
202
+ * @param {boolean} [props.isBusy] - Whether the action behind the button is in progress (aria-busy)
199
203
  * @param {boolean} [props.isHidden=false] - Whether to hide the button (hidden attribute, so it stays mounted)
200
204
  * @param {boolean} [props.isPanelOpen=false] - Whether the controlled panel is open
201
205
  * @param {string} [props.panelRole] - The controlled panel's own ARIA role, used for aria-haspopup
@@ -218,6 +222,7 @@ export const MapButton = ({
218
222
  isDisabled,
219
223
  isPressed,
220
224
  isExpanded,
225
+ isBusy,
221
226
  isHidden,
222
227
  isPanelOpen,
223
228
  panelRole,
@@ -288,6 +293,7 @@ export const MapButton = ({
288
293
  isDisabled,
289
294
  isPressed,
290
295
  isExpanded,
296
+ isBusy,
291
297
  isPanelOpen,
292
298
  isPopupOpen,
293
299
  controlledElement,
@@ -107,6 +107,16 @@ describe('MapButton', () => {
107
107
  else expect(button).not.toHaveAttribute('aria-pressed')
108
108
  })
109
109
 
110
+ it.each([
111
+ [{ isBusy: true }, true],
112
+ [{ isBusy: false }, false],
113
+ [{}, false]
114
+ ])('sets aria-busy only while busy (%j)', (props, expected) => {
115
+ renderButton(props)
116
+ if (expected) expect(getButton()).toHaveAttribute('aria-busy', 'true')
117
+ else expect(getButton()).not.toHaveAttribute('aria-busy')
118
+ })
119
+
110
120
  it('sets aria-expanded when no panelId and isExpanded', () => {
111
121
  renderButton({ isExpanded: true })
112
122
  expect(getButton()).toHaveAttribute('aria-expanded', 'true')
@@ -4,7 +4,6 @@ import { useMarkerCursor } from '../../hooks/useMarkerCursor.js'
4
4
  import { useConfig } from '../../store/configContext.js'
5
5
  import { useMap } from '../../store/mapContext.js'
6
6
  import { useService } from '../../store/serviceContext.js'
7
- import { scaleFactor } from '../../../config/appConfig.js'
8
7
  import { isStandaloneLabel } from '../../../utils/symbolUtils.js'
9
8
  import { DEFAULT_SYMBOL_ANCHOR, DEFAULT_SYMBOL_VIEWBOX } from '../../../config/symbolConfig.js'
10
9
  import { EVENTS } from '../../../config/events.js'
@@ -25,7 +24,7 @@ const markerVariant = (isSelected, isActive) => {
25
24
 
26
25
  // The marker's definition carries the viewBox and anchor for its size (see
27
26
  // symbolRegistry.getMarkerSymbolDef)
28
- const resolveSymbolProps = (marker, defaults, symbolRegistry, mapStyle, mapSize, variant) => {
27
+ const resolveSymbolProps = (marker, defaults, symbolRegistry, mapStyle, scale, variant) => {
29
28
  const symbolDef = symbolRegistry.getMarkerSymbolDef(marker)
30
29
  const styleValues = Object.fromEntries(
31
30
  Object.entries(marker).filter(([k]) => !INTERNAL_KEYS.has(k))
@@ -35,7 +34,6 @@ const resolveSymbolProps = (marker, defaults, symbolRegistry, mapStyle, mapSize,
35
34
  const [,, svgWidth, svgHeight] = viewBox.split(' ').map(Number)
36
35
  const anchor = symbolDef?.anchor ?? DEFAULT_SYMBOL_ANCHOR
37
36
  const shapeId = marker.symbol || defaults.symbol
38
- const scale = scaleFactor[mapSize] ?? 1
39
37
  return { resolvedSvg, viewBox, anchor, shapeId, scaledWidth: svgWidth * scale, scaledHeight: svgHeight * scale }
40
38
  }
41
39
 
@@ -43,7 +41,7 @@ const resolveSymbolProps = (marker, defaults, symbolRegistry, mapStyle, mapSize,
43
41
  // sonarjs/disable-next-line function-name
44
42
  export const Markers = () => {
45
43
  const { id } = useConfig()
46
- const { mapStyle, mapSize } = useMap()
44
+ const { mapStyle, mapSizeScale } = useMap()
47
45
  const { markers, markerRef } = useMarkers()
48
46
  const { symbolRegistry, eventBus } = useService()
49
47
 
@@ -89,7 +87,7 @@ export const Markers = () => {
89
87
  return <LabelMarker key={marker.id} marker={marker} mapId={id} markerRef={markerRef} />
90
88
  }
91
89
 
92
- const symbolProps = resolveSymbolProps(marker, defaults, symbolRegistry, mapStyle, mapSize, markerVariant(isSelected, isActive))
90
+ const symbolProps = resolveSymbolProps(marker, defaults, symbolRegistry, mapStyle, mapSizeScale, markerVariant(isSelected, isActive))
93
91
 
94
92
  if (marker.showLabel && marker.label) {
95
93
  return <SymbolLabelMarker key={marker.id} marker={marker} mapId={id} markerRef={markerRef} isSelected={isSelected} symbolProps={symbolProps} />
@@ -9,7 +9,6 @@ jest.mock('../../hooks/useMarkersAPI.js', () => ({ useMarkers: jest.fn() }))
9
9
  jest.mock('../../store/configContext.js', () => ({ useConfig: jest.fn() }))
10
10
  jest.mock('../../store/mapContext.js', () => ({ useMap: jest.fn() }))
11
11
  jest.mock('../../store/serviceContext.js', () => ({ useService: jest.fn() }))
12
- jest.mock('../../../config/appConfig.js', () => ({ scaleFactor: { small: 1, medium: 1.5, large: 2 } }))
13
12
 
14
13
  const MARKER_ID = 'marker-1'
15
14
  const SEL_CHANGE = 'interact:selectionchange'
@@ -38,12 +37,12 @@ const makeMarker = (overrides = {}) => ({
38
37
  id: MARKER_ID, isVisible: true, symbol: 'pin', ...overrides
39
38
  })
40
39
 
41
- const setup = ({ markers = [], mapSize = 'small', eventBus, symbolRegistry, mapStyle = 'outdoor' } = {}) => {
40
+ const setup = ({ markers = [], mapSizeScale = 1, eventBus, symbolRegistry, mapStyle = 'outdoor' } = {}) => {
42
41
  const eb = eventBus ?? makeEventBus()
43
42
  const sr = symbolRegistry ?? makeSymbolRegistry()
44
43
  const markerRefs = new Map()
45
44
  useConfig.mockReturnValue({ id: 'test-app' })
46
- useMap.mockReturnValue({ mapStyle, mapSize })
45
+ useMap.mockReturnValue({ mapStyle, mapSizeScale })
47
46
  useService.mockReturnValue({ symbolRegistry: sr, eventBus: eb })
48
47
  useMarkers.mockReturnValue({
49
48
  markers: { items: markers, markerRefs },
@@ -130,18 +129,17 @@ describe('Markers — symbol resolution', () => {
130
129
  })
131
130
 
132
131
  it.each([
133
- ['small', '38', '38'],
134
- ['medium', '57', '57'],
135
- ['large', '76', '76'],
136
- ['huge', '38', '38']
137
- ])('scales svg dimensions for mapSize=%s', (mapSize, width, height) => {
138
- const svg = setup({ markers: [makeMarker()], mapSize }).result.container.querySelector(SVG_SEL)
132
+ [1, '38', '38'],
133
+ [1.5, '57', '57'],
134
+ [2, '76', '76']
135
+ ])('scales svg dimensions for mapSizeScale=%s', (mapSizeScale, width, height) => {
136
+ const svg = setup({ markers: [makeMarker()], mapSizeScale }).result.container.querySelector(SVG_SEL)
139
137
  expect(svg.getAttribute('width')).toBe(width)
140
138
  expect(svg.getAttribute('height')).toBe(height)
141
139
  })
142
140
 
143
- it('scales anchor offsets for medium mapSize', () => {
144
- expect(setup({ markers: [makeMarker()], mapSize: 'medium' }).result.container.querySelector(SVG_SEL))
141
+ it('scales anchor offsets for a 1.5 mapSizeScale', () => {
142
+ expect(setup({ markers: [makeMarker()], mapSizeScale: 1.5 }).result.container.querySelector(SVG_SEL))
145
143
  .toHaveStyle({ marginLeft: '-28.5px', marginTop: '-57px' })
146
144
  })
147
145
  })
@@ -3,6 +3,7 @@ import { useConfig } from '../../store/configContext'
3
3
  import { useApp } from '../../store/appContext'
4
4
  import { stringToKebab } from '../../../utils/stringToKebab.js'
5
5
  import { getPanelElementId } from '../../../utils/getPanelElementId.js'
6
+ import { focusAfterPanelClose } from '../../../utils/focusAfterPanelClose.js'
6
7
  import { useModalPanelBehaviour } from '../../hooks/useModalPanelBehaviour.js'
7
8
  import { useIsScrollable } from '../../hooks/useIsScrollable.js'
8
9
  import { classifyPanel, getPanelRole } from '../../../utils/getPanelRole.js'
@@ -121,15 +122,7 @@ export const Panel = ({ panelId, panelConfig, props, focusOnOpen, WrappedChild,
121
122
  const panelRef = rootRef || internalPanelRef
122
123
 
123
124
  const handleClose = () => {
124
- requestAnimationFrame(() => {
125
- // Re-checked here, not at handleClose-call time — the triggering element (a button, a
126
- // Features-list item, ...) may have been removed from the DOM while the panel was open
127
- // (e.g. the map panned and the feature it came from dropped out of the current list).
128
- // document.contains() on a detached node is false, not a throw, so this is a plain check.
129
- const triggeringElement = props?.triggeringElement
130
- const focusTarget = triggeringElement && document.contains(triggeringElement) ? triggeringElement : layoutRefs.viewportRef.current
131
- focusTarget?.focus?.({ preventScroll: interfaceType !== 'keyboard' })
132
- })
125
+ focusAfterPanelClose({ triggeringElement: props?.triggeringElement, viewportRef: layoutRefs.viewportRef, interfaceType })
133
126
  dispatch({ type: 'CLOSE_PANEL', payload: panelId })
134
127
  }
135
128
 
@@ -3,6 +3,9 @@ import { useEffect, useRef } from 'react'
3
3
  import { EVENTS as events } from '../../config/events.js'
4
4
  import { useApp } from '../store/appContext.js'
5
5
  import { useService } from '../store/serviceContext.js'
6
+ import { useConfig } from '../store/configContext.js'
7
+ import { getPanelElementId } from '../../utils/getPanelElementId.js'
8
+ import { focusAfterPanelClose } from '../../utils/focusAfterPanelClose.js'
6
9
 
7
10
  // Handlers for the public interface API events (addButton, showPanel, setApplicationMode, ...), as
8
11
  // [event, handler] pairs. They read dispatch and state through refs, so they're created once and
@@ -53,7 +56,15 @@ const createInterfaceSubscriptions = (dispatchRef, stateRef) => {
53
56
  const handleRemovePanel = (id) => dispatchRef.current({ type: 'REMOVE_PANEL', payload: id })
54
57
  const handleShowPanel = ({ id, focus = true, triggeringElement }) =>
55
58
  dispatchRef.current({ type: 'OPEN_PANEL', payload: { panelId: id, focusOnOpen: focus, props: triggeringElement ? { triggeringElement } : undefined } })
56
- const handleHidePanel = (id) => dispatchRef.current({ type: 'CLOSE_PANEL', payload: id })
59
+ const handleHidePanel = (id) => {
60
+ const { appId, openPanels, layoutRefs, interfaceType } = stateRef.current
61
+ // Checked before closing: once the panel is hidden the browser moves focus to <body>
62
+ const panelEl = document.getElementById(getPanelElementId(appId, id))
63
+ if (panelEl?.contains(document.activeElement)) {
64
+ focusAfterPanelClose({ triggeringElement: openPanels[id]?.props?.triggeringElement, viewportRef: layoutRefs.viewportRef, interfaceType })
65
+ }
66
+ dispatchRef.current({ type: 'CLOSE_PANEL', payload: id })
67
+ }
57
68
  const handleAddControl = ({ id, config }) => dispatchRef.current({ type: 'ADD_CONTROL', payload: { id, config } })
58
69
  const handleSetApplicationMode = ({ id, include, exclude }) =>
59
70
  dispatchRef.current({ type: 'SET_APPLICATION_MODE', payload: { id, include, exclude } })
@@ -75,14 +86,15 @@ const createInterfaceSubscriptions = (dispatchRef, stateRef) => {
75
86
  }
76
87
 
77
88
  export const useInterfaceAPI = () => {
78
- const { dispatch, hiddenButtons, disabledButtons, pressedButtons, expandedButtons } = useApp()
89
+ const { id: appId } = useConfig()
90
+ const { dispatch, hiddenButtons, disabledButtons, pressedButtons, expandedButtons, openPanels, layoutRefs, interfaceType } = useApp()
79
91
  const { eventBus } = useService()
80
92
 
81
93
  // Refs so event handlers always use the latest dispatch/state without re-subscribing
82
94
  const dispatchRef = useRef(dispatch)
83
- const stateRef = useRef({ hiddenButtons, disabledButtons, pressedButtons, expandedButtons })
95
+ const stateRef = useRef(null)
84
96
  dispatchRef.current = dispatch
85
- stateRef.current = { hiddenButtons, disabledButtons, pressedButtons, expandedButtons }
97
+ stateRef.current = { hiddenButtons, disabledButtons, pressedButtons, expandedButtons, appId, openPanels, layoutRefs, interfaceType }
86
98
 
87
99
  useEffect(() => {
88
100
  const subscriptions = createInterfaceSubscriptions(dispatchRef, stateRef)