@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.
- package/assets/templates/style-switcher.njk +2 -2
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/button-definition.md +11 -0
- package/docs/api/context.md +4 -0
- package/docs/api.md +20 -2
- package/docs/architecture/interactive-map.likec4 +4 -4
- package/docs/plugins/datasets.md +11 -0
- package/docs/plugins/draw.md +197 -35
- package/docs/plugins/interact.md +24 -1
- package/docs/plugins/search.md +2 -2
- package/docusaurus.config.cjs +25 -3
- package/govuk-prototype-kit.config.json +6 -7
- package/package.json +20 -23
- package/plugins/datasets/dist/esm/im-datasets-esri-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/esm/index.js +1 -1
- package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/index.js +1 -1
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +18 -16
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.test.js +2 -2
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.js +2 -3
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/loadLayerAdapter.js +2 -20
- package/plugins/datasets/src/adapters/loadLayerAdapter.test.js +9 -9
- package/plugins/datasets/src/adapters/mapboxStyleLayerAdapter.js +7 -7
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +19 -19
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +1 -1
- package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +2 -2
- package/plugins/datasets/src/adapters/openlayers/layerBuilders.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.js +21 -21
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +5 -5
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +2 -3
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +2 -2
- package/plugins/datasets/src/api/getOpacity.js +1 -2
- package/plugins/datasets/src/api/getOpacity.test.js +9 -12
- package/plugins/datasets/src/api/getStyle.js +1 -2
- package/plugins/datasets/src/api/getStyle.test.js +5 -8
- package/plugins/datasets/src/api/removeDataset.js +2 -4
- package/plugins/datasets/src/api/removeDataset.test.js +5 -10
- package/plugins/datasets/src/api/setData.js +2 -4
- package/plugins/datasets/src/api/setData.test.js +6 -14
- package/plugins/datasets/src/api/setFeatureVisibility.js +1 -2
- package/plugins/datasets/src/api/setFeatureVisibility.test.js +8 -11
- package/plugins/datasets/src/components/LayersMenu/LayersMenu.jsx +1 -0
- package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.jsx +1 -3
- package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.test.jsx +13 -18
- package/plugins/datasets/src/index.js +2 -2
- package/plugins/datasets/src/index.test.js +8 -1
- package/plugins/datasets/src/initialise/DatasetsInit.jsx +37 -26
- package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +120 -89
- package/plugins/datasets/src/initialise/initialiseDatasets.js +2 -3
- package/plugins/datasets/src/initialise/initialiseDatasets.test.js +23 -10
- package/plugins/datasets/src/manifest.js +53 -44
- package/plugins/datasets/src/manifest.test.js +36 -4
- package/plugins/datasets/src/reducers/pluginState.js +5 -5
- package/plugins/datasets/src/reducers/pluginState.test.js +21 -20
- package/plugins/datasets/src/registry/__mocks__/datasetRegistry.js +7 -6
- package/plugins/datasets/src/registry/createDataset.js +2 -2
- package/plugins/datasets/src/registry/dataset.js +9 -10
- package/plugins/datasets/src/registry/dataset.test.js +63 -64
- package/plugins/datasets/src/registry/datasetRegistry.js +39 -10
- package/plugins/datasets/src/registry/datasetRegistry.test.js +83 -1
- package/plugins/datasets/src/registry/globalDataset.js +9 -17
- package/plugins/datasets/src/registry/isVisibleWhen.js +9 -17
- package/plugins/datasets/src/registry/isVisibleWhen.test.js +27 -20
- package/plugins/datasets/src/registry/mapboxStyleDataset.test.js +26 -27
- package/plugins/datasets/src/utils/hasLayersMenu.js +13 -0
- package/plugins/datasets/src/utils/hasLayersMenu.test.js +25 -0
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/esm/index.js +1 -1
- package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/umd/index.js +1 -1
- package/plugins/draw/src/DrawInit.jsx +53 -29
- package/plugins/draw/src/DrawInit.test.jsx +105 -2
- package/plugins/draw/src/adapterEvents.js +78 -44
- package/plugins/draw/src/adapters/adapterContract.test.js +3 -3
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +18 -10
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +31 -22
- package/plugins/draw/src/adapters/maplibre/drawEvents.js +2 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +13 -12
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +5 -5
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +6 -9
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +4 -4
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +6 -9
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.js +8 -14
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.test.js +37 -8
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +11 -1
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +14 -19
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +41 -4
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +12 -1
- package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +3 -1
- package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.js +9 -10
- package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.test.js +5 -24
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +10 -7
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +12 -7
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +5 -0
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +7 -3
- package/plugins/draw/src/adapters/openlayers/core/styles.test.js +1 -1
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +11 -11
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +15 -15
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +21 -28
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +26 -5
- package/plugins/draw/src/adapters/openlayers/edit/selectionState.js +5 -6
- package/plugins/draw/src/adapters/openlayers/edit/selectionState.test.js +2 -12
- package/plugins/draw/src/adapters/openlayers/edit/undoOps.js +9 -0
- package/plugins/draw/src/adapters/openlayers/edit/undoOps.test.js +7 -0
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +6 -9
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +3 -3
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +18 -9
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +29 -4
- package/plugins/draw/src/adapters/openlayers/point/pointOps.js +3 -2
- package/plugins/draw/src/adapters/openlayers/point/pointOps.test.js +6 -0
- package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.js +3 -4
- package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.test.js +2 -12
- package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +1 -1
- package/plugins/draw/src/api/createNewShape.js +4 -4
- package/plugins/draw/src/api/createNewShape.test.js +1 -1
- package/plugins/draw/src/api/editFeature.js +8 -11
- package/plugins/draw/src/api/editFeature.test.js +33 -22
- package/plugins/draw/src/api/newLine.test.js +3 -3
- package/plugins/draw/src/api/newPoint.js +4 -5
- package/plugins/draw/src/api/newPoint.test.js +3 -3
- package/plugins/draw/src/api/newPolygon.test.js +3 -3
- package/plugins/draw/src/api/recheckGeometry.js +32 -0
- package/plugins/draw/src/api/recheckGeometry.test.js +55 -0
- package/plugins/draw/src/api/setGeometry.js +33 -0
- package/plugins/draw/src/api/setGeometry.test.js +48 -0
- package/plugins/draw/src/api/split.js +23 -22
- package/plugins/draw/src/api/split.test.js +33 -18
- package/plugins/draw/src/events.js +265 -77
- package/plugins/draw/src/events.test.js +708 -34
- package/plugins/draw/src/hooks/useSpatialList.js +10 -11
- package/plugins/draw/src/hooks/useSpatialList.test.js +3 -3
- package/plugins/draw/src/manifest.js +33 -17
- package/plugins/draw/src/manifest.test.js +104 -10
- package/plugins/draw/src/reducer.js +31 -9
- package/plugins/draw/src/reducer.test.js +35 -3
- package/plugins/draw/src/utils/drawModes.js +27 -0
- package/plugins/draw/src/utils/drawModes.test.js +27 -0
- package/plugins/draw/src/utils/needsDrawTarget.js +18 -0
- package/plugins/draw/src/utils/needsDrawTarget.test.js +32 -0
- package/plugins/draw/src/utils/touchTarget.js +34 -26
- package/plugins/draw/src/utils/touchTarget.test.js +32 -20
- package/plugins/draw/src/validation/commitChecks.js +185 -0
- package/plugins/draw/src/validation/commitChecks.test.js +205 -0
- package/plugins/draw/src/validation/liveDrawChecks.js +11 -11
- package/plugins/draw/src/validation/liveDrawChecks.test.js +37 -37
- package/plugins/draw/src/validation/liveStroke.js +6 -6
- package/plugins/draw/src/validation/liveStroke.test.js +27 -27
- package/plugins/draw/src/validation/rules.js +16 -14
- package/plugins/draw/src/validation/rules.test.js +5 -5
- package/plugins/draw/src/validation/validateGeometry.js +58 -31
- package/plugins/draw/src/validation/validateGeometry.test.js +68 -44
- package/plugins/draw-es/dist/esm/index.js +1 -0
- package/plugins/{beta/draw-es → draw-es}/src/DrawInit.jsx +1 -1
- package/plugins/{beta/draw-es → draw-es}/src/events.test.js +1 -1
- package/plugins/{beta/draw-es → draw-es}/src/graphic.js +1 -1
- package/plugins/frame/dist/esm/index.js +1 -0
- package/plugins/{beta/frame → frame}/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/{beta/frame → frame}/dist/umd/index.js +1 -1
- package/plugins/{beta/frame → frame}/package.json +2 -2
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/esm/index.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +3 -3
- package/plugins/interact/src/api/enable.test.js +13 -0
- package/plugins/interact/src/defaults.js +1 -0
- package/plugins/interact/src/hooks/useCrossHairVisibility.js +27 -17
- package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +72 -7
- package/plugins/interact/src/hooks/useInteractionHandlers.js +3 -5
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +4 -3
- package/plugins/interact/src/hooks/useSpatialList.js +16 -17
- package/plugins/interact/src/hooks/useSpatialList.test.js +9 -9
- package/plugins/interact/src/manifest.js +4 -4
- package/plugins/interact/src/manifest.test.js +29 -0
- package/plugins/interact/src/reducer.js +7 -2
- package/plugins/interact/src/reducer.test.js +12 -2
- package/plugins/interact/src/utils/needsTarget.js +20 -0
- package/plugins/interact/src/utils/needsTarget.test.js +36 -0
- package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/esm/index.js +1 -1
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/index.js +1 -1
- package/plugins/map-key/src/components/Key/KeySvgSymbol.jsx +4 -0
- package/plugins/map-key/src/components/Key/MapKey.jsx +15 -15
- package/plugins/map-key/src/components/Key/MapKey.test.jsx +29 -15
- package/plugins/map-key/src/initialise/MapKeyInit.jsx +5 -8
- package/plugins/map-key/src/initialise/MapKeyInit.test.jsx +9 -7
- package/plugins/map-key/src/manifest.test.js +0 -1
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.js +14 -33
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +34 -50
- package/plugins/map-key/src/reducers/pluginState.js +6 -1
- package/plugins/map-key/src/reducers/pluginState.test.js +13 -4
- package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +1 -0
- package/plugins/map-styles/dist/esm/index.js +1 -0
- package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -0
- package/plugins/{beta/map-styles → map-styles}/dist/umd/index.js +1 -1
- package/plugins/{beta/map-styles → map-styles}/src/MapStyles.jsx +3 -3
- package/plugins/{beta/map-styles → map-styles}/src/MapStylesInit.jsx +1 -1
- package/plugins/menu/dist/esm/index.js +1 -1
- package/plugins/scale-bar/dist/esm/index.js +1 -0
- package/plugins/{beta/scale-bar → scale-bar}/dist/umd/im-scale-bar-plugin.js +1 -1
- package/plugins/{beta/scale-bar → scale-bar}/dist/umd/index.js +1 -1
- package/plugins/{beta/scale-bar → scale-bar}/package.json +2 -2
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +3 -1
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +11 -0
- package/plugins/search/src/utils/markedToElements.jsx +25 -0
- package/plugins/search/src/utils/markedToElements.test.jsx +49 -0
- package/plugins/search/src/utils/parseOsNamesResults.js +6 -4
- package/plugins/search/src/utils/parseOsNamesResults.test.js +18 -0
- package/plugins/use-location/dist/esm/index.js +1 -0
- package/plugins/{beta/use-location → use-location}/dist/umd/im-use-location-plugin.js +1 -1
- package/plugins/{beta/use-location → use-location}/dist/umd/index.js +1 -1
- package/providers/esri/dist/esm/index.js +1 -0
- package/providers/{beta/esri → esri}/src/esriProvider.js +1 -1
- package/providers/{beta/esri → esri}/src/mapEvents.js +2 -2
- package/providers/maplibre/dist/esm/index.js +1 -1
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/index.js +11 -2
- package/providers/maplibre/src/index.test.js +23 -1
- package/providers/maplibre/src/utils/detectModuleWorker.js +8 -19
- package/providers/maplibre/src/utils/detectModuleWorker.test.js +19 -23
- package/providers/maplibre/src/utils/workerUrl.js +12 -0
- package/providers/maplibre/src/utils/workerUrl.test.js +14 -1
- package/providers/open-names/dist/esm/index.js +1 -0
- package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js +1 -1
- package/providers/{beta/open-names → open-names}/dist/umd/index.js +1 -1
- package/providers/openlayers/dist/esm/index.js +1 -0
- package/providers/openlayers/dist/umd/im-openlayers-provider.js +2 -0
- package/providers/{beta/openlayers → openlayers}/dist/umd/index.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/index.js +4 -4
- package/providers/{beta/openlayers → openlayers}/src/mapEvents.js +2 -2
- package/providers/{beta/openlayers → openlayers}/src/mapEvents.test.js +2 -2
- package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.js +3 -3
- package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.js +1 -1
- package/rollup.esm.mjs +43 -47
- package/sonar-project.properties +1 -1
- package/src/App/App.jsx +4 -1
- package/src/App/App.test.jsx +6 -0
- package/src/App/components/MapButton/MapButton.jsx +6 -0
- package/src/App/components/MapButton/MapButton.test.jsx +10 -0
- package/src/App/components/Markers/Markers.jsx +3 -5
- package/src/App/components/Markers/Markers.test.jsx +9 -11
- package/src/App/components/Panel/Panel.jsx +2 -9
- package/src/App/hooks/useInterfaceAPI.js +16 -4
- package/src/App/hooks/useInterfaceAPI.test.js +66 -1
- package/src/App/renderer/PluginInits.jsx +8 -7
- package/src/App/renderer/PluginInits.test.jsx +20 -5
- package/src/App/renderer/SlotItemsProvider.jsx +33 -0
- package/src/App/renderer/SlotItemsProvider.test.jsx +59 -0
- package/src/App/renderer/SlotRenderer.jsx +3 -14
- package/src/App/renderer/SlotRenderer.test.jsx +11 -44
- package/src/App/renderer/mapButtons.js +24 -12
- package/src/App/renderer/mapButtons.test.js +32 -1
- package/src/App/renderer/mapControls.js +6 -8
- package/src/App/renderer/mapControls.test.js +10 -0
- package/src/App/renderer/mapPanels.js +16 -19
- package/src/App/renderer/mapPanels.test.js +37 -9
- package/src/App/renderer/pluginWrapper.js +10 -8
- package/src/App/renderer/pluginWrapper.test.js +23 -9
- package/src/App/renderer/slotAggregator.js +18 -5
- package/src/App/renderer/slotAggregator.test.js +68 -25
- package/src/App/renderer/slotHelpers.js +13 -0
- package/src/App/renderer/slotHelpers.test.js +16 -1
- package/src/App/store/AppProvider.jsx +19 -1
- package/src/App/store/AppProvider.test.jsx +41 -0
- package/src/App/store/MapProvider.jsx +3 -0
- package/src/App/store/MapProvider.test.jsx +24 -0
- package/src/App/store/appActionsMap.js +10 -1
- package/src/App/store/appActionsMap.test.js +21 -0
- package/src/App/store/appDispatchMiddleware.js +29 -17
- package/src/App/store/appDispatchMiddleware.test.js +31 -0
- package/src/InteractiveMap/parseDataProperties.js +4 -4
- package/src/InteractiveMap/parseDataProperties.test.js +62 -6
- package/src/config/events.js +4 -2
- package/src/config/mapSizeScales.js +3 -0
- package/src/scss/tools/_govuk-content.scss +4 -3
- package/src/types.js +4 -0
- package/src/utils/focusAfterPanelClose.js +9 -0
- package/src/utils/focusAfterPanelClose.test.js +40 -0
- package/webpack.dev.mjs +9 -3
- package/webpack.prod.mjs +11 -4
- package/webpack.umd.mjs +6 -7
- package/plugins/beta/draw-es/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +0 -1
- package/plugins/beta/draw-ml/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +0 -1
- package/plugins/beta/draw-ml/dist/umd/index.js +0 -2
- package/plugins/beta/draw-ml/src/DrawInit.jsx +0 -85
- package/plugins/beta/draw-ml/src/api/addFeature.js +0 -27
- package/plugins/beta/draw-ml/src/api/deleteFeature.js +0 -13
- package/plugins/beta/draw-ml/src/api/editFeature.js +0 -75
- package/plugins/beta/draw-ml/src/api/merge.js +0 -9
- package/plugins/beta/draw-ml/src/api/newLine.js +0 -68
- package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -68
- package/plugins/beta/draw-ml/src/api/split.js +0 -81
- package/plugins/beta/draw-ml/src/defaults.js +0 -17
- package/plugins/beta/draw-ml/src/draw.scss +0 -26
- package/plugins/beta/draw-ml/src/events.js +0 -185
- package/plugins/beta/draw-ml/src/index.js +0 -13
- package/plugins/beta/draw-ml/src/manifest.js +0 -110
- package/plugins/beta/draw-ml/src/mapboxDraw.js +0 -143
- package/plugins/beta/draw-ml/src/mapboxSnap.js +0 -321
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +0 -552
- package/plugins/beta/draw-ml/src/modes/disabledMode.js +0 -23
- package/plugins/beta/draw-ml/src/modes/drawLineMode.js +0 -18
- package/plugins/beta/draw-ml/src/modes/drawPolygonMode.js +0 -16
- package/plugins/beta/draw-ml/src/modes/editVertex/geometryHelpers.js +0 -135
- package/plugins/beta/draw-ml/src/modes/editVertex/helpers.js +0 -2
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +0 -142
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +0 -133
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +0 -142
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +0 -121
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +0 -495
- package/plugins/beta/draw-ml/src/reducer.js +0 -90
- package/plugins/beta/draw-ml/src/styles.js +0 -190
- package/plugins/beta/draw-ml/src/undoStack.js +0 -50
- package/plugins/beta/draw-ml/src/utils/debounce.js +0 -16
- package/plugins/beta/draw-ml/src/utils/flattenStyleProperties.js +0 -49
- package/plugins/beta/draw-ml/src/utils/snapHelpers.js +0 -200
- package/plugins/beta/draw-ml/src/utils/spatial.js +0 -258
- package/plugins/beta/draw-ol/dist/css/index.css +0 -1
- package/plugins/beta/draw-ol/dist/esm/DrawMode.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/EditMode.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ol/src/DrawInit.jsx +0 -65
- package/plugins/beta/draw-ol/src/api/addFeature.js +0 -29
- package/plugins/beta/draw-ol/src/api/deleteFeature.js +0 -11
- package/plugins/beta/draw-ol/src/api/editFeature.js +0 -50
- package/plugins/beta/draw-ol/src/api/newLine.js +0 -44
- package/plugins/beta/draw-ol/src/api/newPolygon.js +0 -44
- package/plugins/beta/draw-ol/src/core/OLDrawManager.js +0 -153
- package/plugins/beta/draw-ol/src/core/featureStore.js +0 -65
- package/plugins/beta/draw-ol/src/core/styles.js +0 -98
- package/plugins/beta/draw-ol/src/core/undoStack.js +0 -31
- package/plugins/beta/draw-ol/src/defaults.js +0 -16
- package/plugins/beta/draw-ol/src/draw/DrawMode.js +0 -121
- package/plugins/beta/draw-ol/src/draw/drawInput.js +0 -243
- package/plugins/beta/draw-ol/src/draw.scss +0 -17
- package/plugins/beta/draw-ol/src/edit/EditMode.js +0 -424
- package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +0 -229
- package/plugins/beta/draw-ol/src/edit/midpointLayer.js +0 -57
- package/plugins/beta/draw-ol/src/edit/touchHandler.js +0 -171
- package/plugins/beta/draw-ol/src/edit/undoOps.js +0 -95
- package/plugins/beta/draw-ol/src/edit/vertexHitTest.js +0 -72
- package/plugins/beta/draw-ol/src/edit/vertexLayer.js +0 -49
- package/plugins/beta/draw-ol/src/edit/vertexOps.js +0 -99
- package/plugins/beta/draw-ol/src/events.js +0 -114
- package/plugins/beta/draw-ol/src/index.js +0 -12
- package/plugins/beta/draw-ol/src/manifest.js +0 -125
- package/plugins/beta/draw-ol/src/olDraw.js +0 -38
- package/plugins/beta/draw-ol/src/reducer.js +0 -41
- package/plugins/beta/draw-ol/src/snap/snapEngine.js +0 -153
- package/plugins/beta/draw-ol/src/snap/snapGeometry.js +0 -177
- package/plugins/beta/draw-ol/src/snap/snapIndicator.js +0 -81
- package/plugins/beta/draw-ol/src/snap/snapInteraction.js +0 -57
- package/plugins/beta/draw-ol/src/snap/snapManager.js +0 -99
- package/plugins/beta/draw-ol/src/utils/flattenStyleProperties.js +0 -47
- package/plugins/beta/draw-ol/src/utils/geometryHelpers.js +0 -103
- package/plugins/beta/draw-ol/src/utils/olCoords.js +0 -35
- package/plugins/beta/draw-ol/src/utils/resolveColors.js +0 -39
- package/plugins/beta/draw-ol/src/utils/spatial.js +0 -24
- package/plugins/beta/draw-ol/src/utils/touchTarget.js +0 -61
- package/plugins/beta/frame/dist/esm/index.js +0 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +0 -1
- package/plugins/beta/map-styles/dist/esm/index.js +0 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +0 -1
- package/plugins/beta/scale-bar/dist/esm/index.js +0 -1
- package/plugins/beta/use-location/dist/esm/index.js +0 -1
- package/plugins/map-key/src/registry/getDatasetRegistry.js +0 -6
- package/plugins/map-key/src/registry/getDatasetRegistry.test.js +0 -23
- package/plugins/map-key/src/registry/index.js +0 -1
- package/plugins/map-key/src/registry/index.test.js +0 -7
- package/providers/beta/esri/dist/esm/index.js +0 -1
- package/providers/beta/open-names/dist/esm/index.js +0 -1
- package/providers/beta/openlayers/dist/esm/index.js +0 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +0 -2
- package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +0 -1
- /package/plugins/{beta/draw-es → draw-es}/dist/esm/im-draw-es-plugin.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/addFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/deleteFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/editFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/newPolygon.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/removeSafeZone.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/events.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/index.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/manifest.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/reducer.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/sketchViewModel.js +0 -0
- /package/plugins/{beta/frame → frame}/dist/css/index.css +0 -0
- /package/plugins/{beta/frame → frame}/dist/esm/im-frame-plugin.js +0 -0
- /package/plugins/{beta/draw-ml → frame}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/frame → frame}/src/Frame.jsx +0 -0
- /package/plugins/{beta/frame → frame}/src/FrameInit.jsx +0 -0
- /package/plugins/{beta/frame → frame}/src/api/addFrame.js +0 -0
- /package/plugins/{beta/frame → frame}/src/api/editFeature.js +0 -0
- /package/plugins/{beta/frame → frame}/src/config.js +0 -0
- /package/plugins/{beta/frame → frame}/src/frame.scss +0 -0
- /package/plugins/{beta/frame → frame}/src/index.js +0 -0
- /package/plugins/{beta/frame → frame}/src/manifest.js +0 -0
- /package/plugins/{beta/frame → frame}/src/reducer.js +0 -0
- /package/plugins/{beta/frame → frame}/src/utils.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/dist/css/index.css +0 -0
- /package/plugins/{beta/frame → map-styles}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/config.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/index.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/manifest.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/mapStyles.scss +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/dist/css/index.css +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/dist/esm/im-scale-bar-plugin.js +0 -0
- /package/plugins/{beta/map-styles → scale-bar}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.jsx +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.test.jsx +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/index.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/index.test.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/manifest.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/scaleBar.scss +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/utils.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/utils.test.js +0 -0
- /package/plugins/{beta/use-location → use-location}/dist/esm/im-use-location-plugin.js +0 -0
- /package/plugins/{beta/scale-bar → use-location}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/use-location → use-location}/src/UseLocation.jsx +0 -0
- /package/plugins/{beta/use-location → use-location}/src/UseLocationInit.jsx +0 -0
- /package/plugins/{beta/use-location → use-location}/src/defaults.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/events.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/index.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/manifest.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/reducer.js +0 -0
- /package/providers/{beta/esri → esri}/dist/css/index.css +0 -0
- /package/providers/{beta/esri → esri}/dist/esm/im-esri-provider.js +0 -0
- /package/providers/{beta/esri → esri}/src/appEvents.js +0 -0
- /package/providers/{beta/esri → esri}/src/defaults.js +0 -0
- /package/providers/{beta/esri → esri}/src/esriProvider.scss +0 -0
- /package/providers/{beta/esri → esri}/src/index.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/coords.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/coords.test.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/detectWebGL.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/esriFixes.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/query.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/spatial.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/spatial.test.js +0 -0
- /package/providers/{beta/open-names → open-names}/dist/esm/im-reverse-geocode.js +0 -0
- /package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js.LICENSE.txt +0 -0
- /package/{plugins/beta/use-location → providers/open-names}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/providers/{beta/open-names → open-names}/src/index.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/reverseGeocode.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/dist/esm/im-openlayers-provider.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/dist/umd/im-openlayers-provider.js.LICENSE.txt +0 -0
- /package/providers/{beta/open-names → openlayers}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/appEvents.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/appEvents.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/defaults.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/index.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/bngProjection.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.js +0 -0
- /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,
|
|
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
|
-
//
|
|
10
|
-
|
|
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
|
|
26
|
+
if (!mapState.isMapReady || isLoadStartedRef.current) {
|
|
27
|
+
return
|
|
15
28
|
}
|
|
29
|
+
isLoadStartedRef.current = true
|
|
16
30
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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 (!
|
|
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('
|
|
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)
|
|
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
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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'
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* 'place'
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* 'create'
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* '
|
|
23
|
-
*
|
|
24
|
-
* '
|
|
25
|
-
*
|
|
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
|
|
30
|
-
*
|
|
31
|
-
*
|
|
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
|
|
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
|
|
39
|
-
*
|
|
40
|
-
*
|
|
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 -
|
|
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
|
|
57
|
-
* absent on 'preview', 'create',
|
|
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
|
|
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
|
|
93
|
-
*
|
|
94
|
-
*
|
|
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 (
|
|
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
|
-
'
|
|
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
|
|
44
|
-
const descriptor = Object.getOwnPropertyDescriptor(Adapter.prototype, '
|
|
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 },
|
|
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 },
|
|
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
|
-
//
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
this._map.
|
|
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
|
-
//
|
|
292
|
-
//
|
|
293
|
-
|
|
294
|
-
|
|
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.
|