@mapcomponents/react-maplibre 0.1.62 → 0.1.64

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 (340) hide show
  1. package/.babelrc +21 -2
  2. package/.editorconfig +1 -1
  3. package/.eslintrc.js +11 -1
  4. package/.github/workflows/check-catalogue-metadata-schema.yml +19 -0
  5. package/.storybook/main.js +0 -1
  6. package/.storybook/preview.js +0 -2
  7. package/CHANGELOG.md +43 -0
  8. package/coverage/clover.xml +864 -1037
  9. package/coverage/coverage-final.json +32 -21
  10. package/coverage/lcov-report/favicon.png +0 -0
  11. package/coverage/lcov-report/index.html +170 -95
  12. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  13. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +24 -24
  14. package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
  15. package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +5 -5
  16. package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
  17. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +2 -2
  18. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
  19. package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx.html +148 -0
  20. package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +1 -1
  21. package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +22 -7
  22. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +72 -42
  23. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +15 -15
  24. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
  25. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  26. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +1 -1
  27. package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
  28. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +86 -35
  29. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  30. package/coverage/lcov-report/src/components/{MlSpatialElevationProfile/MlSpatialElevationProfile.js.html → MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js.html} +215 -320
  31. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js.html +649 -0
  32. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.tsx.html +112 -0
  33. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.tsx.html +115 -0
  34. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/index.html +161 -0
  35. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx.html +1 -1
  36. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/index.html +1 -1
  37. package/coverage/lcov-report/src/components/MlGpxViewer/MlGpxViewer.tsx.html +394 -0
  38. package/coverage/lcov-report/src/components/MlGpxViewer/index.html +116 -0
  39. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +63 -285
  40. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +21 -21
  41. package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +1 -1
  42. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  43. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +58 -76
  44. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
  45. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +58 -61
  46. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +11 -11
  47. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
  48. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +30 -21
  49. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  50. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  51. package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +1 -1
  52. package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
  53. package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +1 -1
  54. package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
  55. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
  56. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  57. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +1 -1
  58. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
  59. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
  60. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +1 -1
  61. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  62. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
  63. package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
  64. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
  65. package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
  66. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/ColorPicker.tsx.html +214 -0
  67. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerList.tsx.html +121 -0
  68. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerListItem.tsx.html +412 -0
  69. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx.html +463 -0
  70. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/index.html +161 -0
  71. package/coverage/lcov-report/src/components/{MlGPXViewer/MlGPXViewer.tsx.html → MlSketchTool/MlSketchTool.tsx.html} +271 -589
  72. package/coverage/lcov-report/src/components/{MlGPXViewer → MlSketchTool}/index.html +22 -37
  73. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.tsx.html +514 -0
  74. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +21 -21
  75. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
  76. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
  77. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +20 -206
  78. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
  79. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  80. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  81. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +10 -7
  82. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +5 -5
  83. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
  84. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
  85. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +111 -57
  86. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +19 -19
  87. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +201 -144
  88. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +9 -9
  89. package/coverage/lcov-report/src/contexts/MapContext.tsx.html +23 -23
  90. package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
  91. package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
  92. package/coverage/lcov-report/src/contexts/index.html +1 -1
  93. package/coverage/lcov-report/src/hooks/index.html +50 -50
  94. package/coverage/lcov-report/src/hooks/useCameraFollowPath/index.html +1 -1
  95. package/coverage/lcov-report/src/hooks/useCameraFollowPath/useCameraFollowPath.tsx.html +1 -1
  96. package/coverage/lcov-report/src/hooks/useExportMap/index.html +1 -1
  97. package/coverage/lcov-report/src/hooks/useExportMap/index.ts.html +1 -1
  98. package/coverage/lcov-report/src/hooks/useExportMap/lib.ts.html +1 -1
  99. package/coverage/lcov-report/src/hooks/useGpx/index.html +116 -0
  100. package/coverage/lcov-report/src/hooks/useGpx/useGpx.tsx.html +295 -0
  101. package/coverage/lcov-report/src/hooks/useLayer.ts.html +132 -66
  102. package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +1 -1
  103. package/coverage/lcov-report/src/hooks/useLayerHoverPopup/index.html +116 -0
  104. package/coverage/lcov-report/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx.html +331 -0
  105. package/coverage/lcov-report/src/hooks/useMap.ts.html +47 -47
  106. package/coverage/lcov-report/src/hooks/useMapState.ts.html +54 -54
  107. package/coverage/lcov-report/src/hooks/useSource.ts.html +57 -57
  108. package/coverage/lcov-report/src/hooks/{useWms.js.html → useWms.ts.html} +54 -15
  109. package/coverage/lcov-report/src/index.html +1 -1
  110. package/coverage/lcov-report/src/index.ts.html +6 -6
  111. package/coverage/lcov.info +1724 -1974
  112. package/cypress/support/commands.ts +37 -0
  113. package/cypress/support/component-index.html +12 -0
  114. package/cypress/support/component.ts +46 -0
  115. package/cypress.config.ts +101 -0
  116. package/dist/components/MapLibreMap/MapLibreMap.d.ts +1 -1
  117. package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +53 -27
  118. package/dist/components/MlCenterPosition/MlCenterPosition.d.ts +3 -2
  119. package/dist/components/MlCenterPosition/MlCenterPosition.stories.d.ts +35 -16
  120. package/dist/components/MlComponentTemplate/MlComponentTemplate.d.ts +1 -1
  121. package/dist/components/MlComponentTemplate/MlComponentTemplate.stories.d.ts +12 -9
  122. package/dist/components/MlCreatePdfButton/MlCreatePdfButton.d.ts +1 -1
  123. package/dist/components/MlCreatePdfButton/MlCreatePdfButton.stories.d.ts +12 -9
  124. package/dist/components/MlCreatePdfForm/MlCreatePdfForm.cy.d.ts +1 -0
  125. package/dist/components/MlCreatePdfForm/lib/PdfPreview.d.ts +1 -1
  126. package/dist/components/MlFeatureEditor/MlFeatureEditor.d.ts +10 -4
  127. package/dist/components/MlFeatureEditor/lib/double_click_zoom.d.ts +0 -2
  128. package/dist/components/MlFeatureEditor/lib/theme.d.ts +1 -1
  129. package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +23 -12
  130. package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +12 -11
  131. package/dist/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.d.ts +2 -0
  132. package/dist/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.d.ts +2 -0
  133. package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.d.ts +3 -0
  134. package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.d.ts +3 -0
  135. package/dist/components/MlGpxViewer/MlGpxViewer.d.ts +30 -0
  136. package/dist/components/MlGpxViewer/MlGpxViewer.stories.d.ts +17 -0
  137. package/dist/components/MlGpxViewer/MlGpxViewer.test.d.ts +1 -0
  138. package/dist/components/MlGpxViewer/util/GeoJsonContext.d.ts +10 -0
  139. package/dist/components/MlGpxViewer/util/GeoJsonProvider.d.ts +4 -0
  140. package/dist/components/MlGpxViewer/util/MetadataDrawer.d.ts +7 -0
  141. package/dist/components/MlGpxViewer/util/MlGpxDemoLoader.d.ts +10 -0
  142. package/dist/components/MlGpxViewer/util/MlGpxViewerInstructions.d.ts +3 -0
  143. package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.d.ts +11 -2
  144. package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.d.ts +7 -9
  145. package/dist/components/MlLayerMagnify/MlLayerMagnify.d.ts +8 -2
  146. package/dist/components/MlLayerMagnify/MlLayerMagnify.stories.d.ts +13 -9
  147. package/dist/components/MlLayerSwipe/MlLayerSwipe.d.ts +13 -3
  148. package/dist/components/MlLayerSwipe/MlLayerSwipe.stories.d.ts +12 -10
  149. package/dist/components/MlSketchTool/LayerList/ColorPicker.d.ts +9 -0
  150. package/dist/components/MlSketchTool/LayerList/LayerList.d.ts +5 -0
  151. package/dist/components/MlSketchTool/LayerList/LayerListItem.d.ts +11 -0
  152. package/dist/components/MlSketchTool/LayerList/LayerPropertyForm.d.ts +9 -0
  153. package/dist/components/MlSketchTool/MlSketchTool.d.ts +29 -0
  154. package/dist/components/MlSketchTool/MlSketchTool.stories.d.ts +10 -0
  155. package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.d.ts +33 -14
  156. package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.d.ts +18 -15
  157. package/dist/components/MlSpatialElevationProfile/util/getElevationData.d.ts +14 -0
  158. package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +3 -67
  159. package/dist/components/MlWmsLayer/MlWmsLayer.d.ts +7 -4
  160. package/dist/components/MlWmsLoader/MlWmsLoader.d.ts +17 -10
  161. package/dist/components/MlWmsLoader/MlWmsLoader.stories.d.ts +23 -12
  162. package/dist/components/MlWmsLoader/utils/MlWmsLoaderInstructions.d.ts +3 -0
  163. package/dist/components/MlWmsLoader/utils/WMSLinks.d.ts +6 -0
  164. package/dist/contexts/SimpleDataProvider.d.ts +1 -1
  165. package/dist/custom.d.d.ts +1 -1
  166. package/dist/decorators/ThemeWrapper.d.ts +3 -1
  167. package/dist/hooks/useGpx/lib/gpxConverter.d.ts +11 -0
  168. package/dist/hooks/useGpx/useGpx.d.ts +26 -0
  169. package/dist/hooks/useGpx/useGpx.stories.d.ts +10 -0
  170. package/dist/hooks/useLayer.d.ts +14 -8
  171. package/dist/hooks/useLayerHoverPopup/useLayerHoverPopup.d.ts +23 -0
  172. package/dist/hooks/useLayerHoverPopup/useLayerHoverPopup.stories.d.ts +10 -0
  173. package/dist/hooks/useMap.d.ts +2 -2
  174. package/dist/hooks/useMap.test.d.ts +1 -0
  175. package/dist/hooks/useMapState.d.ts +3 -3
  176. package/dist/hooks/useSource.d.ts +3 -3
  177. package/dist/hooks/useWms.d.ts +24 -16
  178. package/dist/index.d.ts +5 -5
  179. package/dist/index.esm.css +1 -1
  180. package/dist/index.esm.js +9327 -14844
  181. package/dist/index.esm.js.map +1 -1
  182. package/dist/setupTests.d.ts +6 -5
  183. package/dist/ui_components/Dropzone.d.ts +5 -0
  184. package/dist/ui_components/ImageLoader.d.ts +8 -1
  185. package/dist/ui_components/LoadingOverlayContext.d.ts +11 -11
  186. package/dist/ui_components/Sidebar.d.ts +10 -1
  187. package/dist/ui_components/Tooltip.d.ts +1 -1
  188. package/dist/ui_components/TopToolbar.d.ts +7 -1
  189. package/dist/ui_components/UploadButton.d.ts +6 -0
  190. package/dist/util/BubbleForInstructions.d.ts +2 -0
  191. package/dist/util/Instructions.d.ts +13 -0
  192. package/package.json +195 -185
  193. package/public/assets/sample1.gpx +3003 -0
  194. package/public/assets/sample2.gpx +1264 -0
  195. package/public/assets/sample3.gpx +912 -0
  196. package/{src/components/MlImageMarkerLayer → public}/assets/wg-marker.png +0 -0
  197. package/public/index.html +0 -4
  198. package/public/thumbnails/MlSketchTool.png +0 -0
  199. package/public/thumbnails/useCameraFollowPath.png +0 -0
  200. package/scripts/build-catalogue-meta.js +35 -11
  201. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +230 -188
  202. package/src/components/MlCenterPosition/MlCenterPosition.meta_.json +1 -2
  203. package/src/components/MlCenterPosition/MlCenterPosition.stories.tsx +20 -0
  204. package/src/components/MlCenterPosition/MlCenterPosition.tsx +4 -4
  205. package/src/components/MlComponentTemplate/MlComponentTemplate.meta_.json +1 -2
  206. package/src/components/MlComponentTemplate/{MlComponentTemplate.stories.js → MlComponentTemplate.stories.tsx} +2 -2
  207. package/src/components/MlComponentTemplate/MlComponentTemplate.tsx +1 -1
  208. package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta_.json +1 -2
  209. package/src/components/MlCreatePdfButton/{MlCreatePdfButton.stories.js → MlCreatePdfButton.stories.tsx} +1 -1
  210. package/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx +1 -1
  211. package/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx +21 -0
  212. package/src/components/MlCreatePdfForm/MlCreatePdfForm.meta.json +1 -2
  213. package/src/components/MlCreatePdfForm/MlCreatePdfForm.stories.tsx +1 -3
  214. package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +25 -2
  215. package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -3
  216. package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +39 -29
  217. package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.meta.json +1 -2
  218. package/src/components/MlFollowGps/MlFollowGps.meta.json +1 -2
  219. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -2
  220. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.tsx +191 -0
  221. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +47 -30
  222. package/src/components/MlGeoJsonLayer/assets/earthquake.json +109937 -0
  223. package/src/components/MlGeoJsonLayer/assets/sample_1.json +138 -24
  224. package/src/components/MlGeoJsonLayer/assets/sample_2.json +140 -20
  225. package/src/components/MlGeoJsonLayer/assets/wg_locations.json +65 -0
  226. package/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js +189 -0
  227. package/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js +188 -0
  228. package/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.tsx +9 -0
  229. package/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.tsx +10 -0
  230. package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.meta_.json +1 -2
  231. package/src/components/{MlGPXViewer/MlGPXViewer.doc.de.md → MlGpxViewer/MlGpxViewer.doc.de.md} +0 -0
  232. package/src/components/{MlGPXViewer/MlGPXViewer.doc.en.md → MlGpxViewer/MlGpxViewer.doc.en.md} +0 -0
  233. package/src/components/{MlGPXViewer/MlGPXViewer.meta.json → MlGpxViewer/MlGpxViewer.meta.json} +2 -3
  234. package/src/components/MlGpxViewer/MlGpxViewer.stories.tsx +109 -0
  235. package/src/components/MlGpxViewer/MlGpxViewer.test.js +53 -0
  236. package/src/components/MlGpxViewer/MlGpxViewer.tsx +103 -0
  237. package/src/components/{MlGPXViewer → MlGpxViewer}/util/GeoJsonContext.ts +0 -0
  238. package/src/components/{MlGPXViewer → MlGpxViewer}/util/GeoJsonProvider.tsx +0 -0
  239. package/src/components/MlGpxViewer/util/MetadataDrawer.tsx +38 -0
  240. package/src/components/MlGpxViewer/util/MlGpxDemoLoader.tsx +128 -0
  241. package/src/components/MlGpxViewer/util/MlGpxViewerInstructions.tsx +68 -0
  242. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.meta_.json +1 -2
  243. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.tsx +41 -0
  244. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +27 -8
  245. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx +41 -115
  246. package/src/components/MlLayer/MlLayer.meta_.json +1 -2
  247. package/src/components/MlLayerMagnify/MlLayerMagnify.meta.json +1 -2
  248. package/src/components/MlLayerMagnify/MlLayerMagnify.stories.tsx +44 -0
  249. package/src/components/MlLayerMagnify/{MlLayerMagnify.test.js → MlLayerMagnify.test.tsx} +15 -18
  250. package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +55 -61
  251. package/src/components/MlLayerSwipe/MlLayerSwipe.meta.json +1 -2
  252. package/src/components/MlLayerSwipe/{MlLayerSwipe.stories.js → MlLayerSwipe.stories.tsx} +9 -11
  253. package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +47 -48
  254. package/src/components/MlLayerSwitcher/MlLayerSwitcher.meta_.json +1 -2
  255. package/src/components/MlLayerSwitcher/components/LayerBox.js +22 -19
  256. package/src/components/MlMarker/MlMarker.meta_.json +1 -2
  257. package/src/components/MlMeasureTool/MlMeasureTool.meta.json +1 -2
  258. package/src/components/MlNavigationCompass/MlNavigationCompass.meta.json +1 -2
  259. package/src/components/MlNavigationTools/MlNavigationTools.meta.json +1 -2
  260. package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -2
  261. package/src/components/MlShareMapState/MlShareMapState.meta_.json +1 -2
  262. package/src/components/MlSketchTool/LayerList/ColorPicker.tsx +43 -0
  263. package/src/components/MlSketchTool/LayerList/LayerList.tsx +12 -0
  264. package/src/components/MlSketchTool/LayerList/LayerListItem.tsx +109 -0
  265. package/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx +126 -0
  266. package/src/components/MlSketchTool/MlSketchTool.doc.de.md +3 -0
  267. package/src/components/MlSketchTool/MlSketchTool.meta.json +14 -0
  268. package/src/components/MlSketchTool/MlSketchTool.stories.js +26 -0
  269. package/src/components/MlSketchTool/MlSketchTool.tsx +271 -0
  270. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.meta.json +1 -2
  271. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.tsx +121 -0
  272. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.test.js +30 -1
  273. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.tsx +143 -0
  274. package/src/components/MlSpatialElevationProfile/util/getElevationData.tsx +103 -0
  275. package/src/components/MlThreeJsLayer/MlThreeJsLayer.meta.json +1 -2
  276. package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.meta.json +3 -4
  277. package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.stories.js +2 -3
  278. package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx +17 -79
  279. package/src/components/MlUseMapDebugger/MlUseMapDebugger.meta_.json +1 -2
  280. package/src/components/MlVectorTileLayer/MlVectorTileLayer.meta.json +1 -2
  281. package/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx +3 -2
  282. package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.meta_.json +1 -2
  283. package/src/components/MlWmsLayer/MlWmsLayer.tsx +59 -41
  284. package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -2
  285. package/src/components/MlWmsLoader/MlWmsLoader.stories.tsx +89 -0
  286. package/src/components/MlWmsLoader/MlWmsLoader.tsx +141 -122
  287. package/src/components/MlWmsLoader/utils/MlWmsLoaderInstructions.tsx +50 -0
  288. package/src/components/MlWmsLoader/utils/WMSLinks.tsx +128 -0
  289. package/src/decorators/MapContextDecorator.js +1 -1
  290. package/src/decorators/MapContextDecoratorHooks.js +1 -1
  291. package/src/decorators/ThemeWrapper.tsx +9 -0
  292. package/src/hooks/useCameraFollowPath/useCameraFollowPath.meta.json +1 -2
  293. package/src/{components/MlGPXViewer → hooks/useGpx/lib}/gpxConverter.js +1 -0
  294. package/src/hooks/useGpx/useGpx.doc.de.md +3 -0
  295. package/src/hooks/useGpx/useGpx.meta_.json +15 -0
  296. package/src/{components/MlCenterPosition/MlCenterPosition.stories.js → hooks/useGpx/useGpx.stories.js} +4 -5
  297. package/src/hooks/useGpx/useGpx.tsx +70 -0
  298. package/src/hooks/useLayer.ts +32 -10
  299. package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.doc.de.md +3 -0
  300. package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.meta_.json +15 -0
  301. package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.stories.js +20 -0
  302. package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx +82 -0
  303. package/src/hooks/useMap.test.tsx +48 -0
  304. package/src/hooks/useMap.ts +8 -8
  305. package/src/hooks/useSource.ts +4 -4
  306. package/src/hooks/{useWms.js → useWms.ts} +24 -11
  307. package/src/index.ts +5 -5
  308. package/src/setupTests.js +18 -15
  309. package/src/ui_components/Dropzone.tsx +104 -0
  310. package/src/ui_components/{ImageLoader.js → ImageLoader.tsx} +30 -25
  311. package/src/ui_components/{LoadingOverlayContext.js → LoadingOverlayContext.tsx} +12 -15
  312. package/src/ui_components/Sidebar.tsx +82 -0
  313. package/src/ui_components/Tooltip.tsx +17 -0
  314. package/src/ui_components/TopToolbar.tsx +26 -0
  315. package/src/ui_components/UploadButton.tsx +57 -0
  316. package/src/util/BubbleForInstructions.js +46 -0
  317. package/src/util/Instructions.tsx +60 -0
  318. package/tsconfig.json +39 -58
  319. package/config/getHttpsConfig.js +0 -66
  320. package/config/modules.js +0 -134
  321. package/config/pnpTs.js +0 -35
  322. package/config/webpack.config.js +0 -757
  323. package/config/webpackDevServer.config.js +0 -130
  324. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +0 -1645
  325. package/scripts/start.js +0 -166
  326. package/src/components/MlGPXViewer/MlGPXViewer.stories.js +0 -31
  327. package/src/components/MlGPXViewer/MlGPXViewer.test.js +0 -28
  328. package/src/components/MlGPXViewer/MlGPXViewer.tsx +0 -377
  329. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +0 -66
  330. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.js +0 -45
  331. package/src/components/MlLayerMagnify/MlLayerMagnify.stories.js +0 -41
  332. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js +0 -224
  333. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +0 -57
  334. package/src/components/MlWmsLoader/MlWmsLoader.stories.js +0 -47
  335. package/src/decorators/ThemeWrapper.jsx +0 -9
  336. package/src/ui_components/Legend.js +0 -44
  337. package/src/ui_components/LoadingOverlay.js +0 -41
  338. package/src/ui_components/Sidebar.js +0 -100
  339. package/src/ui_components/Tooltip.js +0 -21
  340. package/src/ui_components/TopToolbar.js +0 -29
@@ -1,757 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const webpack = require('webpack');
6
- const resolve = require('resolve');
7
- const PnpWebpackPlugin = require('pnp-webpack-plugin');
8
- const HtmlWebpackPlugin = require('html-webpack-plugin');
9
- const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
10
- const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
11
- const TerserPlugin = require('terser-webpack-plugin');
12
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
13
- const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
14
- const safePostCssParser = require('postcss-safe-parser');
15
- const ManifestPlugin = require('webpack-manifest-plugin');
16
- const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
17
- const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
18
- const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
19
- const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
20
- const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
21
- const ESLintPlugin = require('eslint-webpack-plugin');
22
- const paths = require('./paths');
23
- const modules = require('./modules');
24
- const getClientEnvironment = require('./env');
25
- const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
26
- const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin');
27
- const typescriptFormatter = require('react-dev-utils/typescriptFormatter');
28
- const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
29
-
30
- const postcssNormalize = require('postcss-normalize');
31
-
32
- const appPackageJson = require(paths.appPackageJson);
33
-
34
- // Source maps are resource heavy and can cause out of memory issue for large source files.
35
- const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
36
-
37
- const webpackDevClientEntry = require.resolve(
38
- 'react-dev-utils/webpackHotDevClient'
39
- );
40
- const reactRefreshOverlayEntry = require.resolve(
41
- 'react-dev-utils/refreshOverlayInterop'
42
- );
43
-
44
- // Some apps do not need the benefits of saving a web request, so not inlining the chunk
45
- // makes for a smoother build process.
46
- const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
47
-
48
- const emitErrorsAsWarnings = process.env.ESLINT_NO_DEV_ERRORS === 'true';
49
- const disableESLintPlugin = process.env.DISABLE_ESLINT_PLUGIN === 'true';
50
-
51
- const imageInlineSizeLimit = parseInt(
52
- process.env.IMAGE_INLINE_SIZE_LIMIT || '10000'
53
- );
54
-
55
- // Check if TypeScript is setup
56
- const useTypeScript = fs.existsSync(paths.appTsConfig);
57
-
58
- // Get the path to the uncompiled service worker (if it exists).
59
- const swSrc = paths.swSrc;
60
-
61
- // style files regexes
62
- const cssRegex = /\.css$/;
63
- const cssModuleRegex = /\.module\.css$/;
64
- const sassRegex = /\.(scss|sass)$/;
65
- const sassModuleRegex = /\.module\.(scss|sass)$/;
66
-
67
- const hasJsxRuntime = (() => {
68
- if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
69
- return false;
70
- }
71
-
72
- try {
73
- require.resolve('react/jsx-runtime');
74
- return true;
75
- } catch (e) {
76
- return false;
77
- }
78
- })();
79
-
80
- // This is the production and development configuration.
81
- // It is focused on developer experience, fast rebuilds, and a minimal bundle.
82
- module.exports = function (webpackEnv) {
83
- const isEnvDevelopment = webpackEnv === 'development';
84
- const isEnvProduction = webpackEnv === 'production';
85
-
86
- // Variable used for enabling profiling in Production
87
- // passed into alias object. Uses a flag if passed into the build command
88
- const isEnvProductionProfile =
89
- isEnvProduction && process.argv.includes('--profile');
90
-
91
- // We will provide `paths.publicUrlOrPath` to our app
92
- // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
93
- // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
94
- // Get environment variables to inject into our app.
95
- const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1));
96
-
97
- const shouldUseReactRefresh = env.raw.FAST_REFRESH;
98
-
99
- // common function to get style loaders
100
- const getStyleLoaders = (cssOptions, preProcessor) => {
101
- const loaders = [
102
- isEnvDevelopment && require.resolve('style-loader'),
103
- isEnvProduction && {
104
- loader: MiniCssExtractPlugin.loader,
105
- // css is located in `static/css`, use '../../' to locate index.html folder
106
- // in production `paths.publicUrlOrPath` can be a relative path
107
- options: paths.publicUrlOrPath.startsWith('.')
108
- ? { publicPath: '../../' }
109
- : {},
110
- },
111
- {
112
- loader: require.resolve('css-loader'),
113
- options: cssOptions,
114
- },
115
- {
116
- // Options for PostCSS as we reference these options twice
117
- // Adds vendor prefixing based on your specified browser support in
118
- // package.json
119
- loader: require.resolve('postcss-loader'),
120
- options: {
121
- // Necessary for external CSS imports to work
122
- // https://github.com/facebook/create-react-app/issues/2677
123
- ident: 'postcss',
124
- plugins: () => [
125
- require('postcss-flexbugs-fixes'),
126
- require('postcss-preset-env')({
127
- autoprefixer: {
128
- flexbox: 'no-2009',
129
- },
130
- stage: 3,
131
- }),
132
- // Adds PostCSS Normalize as the reset css with default options,
133
- // so that it honors browserslist config in package.json
134
- // which in turn let's users customize the target behavior as per their needs.
135
- postcssNormalize(),
136
- ],
137
- sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
138
- },
139
- },
140
- ].filter(Boolean);
141
- if (preProcessor) {
142
- loaders.push(
143
- {
144
- loader: require.resolve('resolve-url-loader'),
145
- options: {
146
- sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
147
- root: paths.appSrc,
148
- },
149
- },
150
- {
151
- loader: require.resolve(preProcessor),
152
- options: {
153
- sourceMap: true,
154
- },
155
- }
156
- );
157
- }
158
- return loaders;
159
- };
160
-
161
- return {
162
- mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
163
- // Stop compilation early in production
164
- bail: isEnvProduction,
165
- devtool: isEnvProduction
166
- ? shouldUseSourceMap
167
- ? 'source-map'
168
- : false
169
- : isEnvDevelopment && 'cheap-module-source-map',
170
- // These are the "entry points" to our application.
171
- // This means they will be the "root" imports that are included in JS bundle.
172
- entry:
173
- isEnvDevelopment && !shouldUseReactRefresh
174
- ? [
175
- // Include an alternative client for WebpackDevServer. A client's job is to
176
- // connect to WebpackDevServer by a socket and get notified about changes.
177
- // When you save a file, the client will either apply hot updates (in case
178
- // of CSS changes), or refresh the page (in case of JS changes). When you
179
- // make a syntax error, this client will display a syntax error overlay.
180
- // Note: instead of the default WebpackDevServer client, we use a custom one
181
- // to bring better experience for Create React App users. You can replace
182
- // the line below with these two lines if you prefer the stock client:
183
- //
184
- // require.resolve('webpack-dev-server/client') + '?/',
185
- // require.resolve('webpack/hot/dev-server'),
186
- //
187
- // When using the experimental react-refresh integration,
188
- // the webpack plugin takes care of injecting the dev client for us.
189
- webpackDevClientEntry,
190
- // Finally, this is your app's code:
191
- paths.appIndexJs,
192
- // We include the app code last so that if there is a runtime error during
193
- // initialization, it doesn't blow up the WebpackDevServer client, and
194
- // changing JS code would still trigger a refresh.
195
- ]
196
- : paths.appIndexJs,
197
- output: {
198
- // The build folder.
199
- path: isEnvProduction ? paths.appBuild : undefined,
200
- // Add /* filename */ comments to generated require()s in the output.
201
- pathinfo: isEnvDevelopment,
202
- // There will be one main bundle, and one file per asynchronous chunk.
203
- // In development, it does not produce real files.
204
- filename: isEnvProduction
205
- ? 'static/js/[name].[contenthash:8].js'
206
- : isEnvDevelopment && 'static/js/bundle.js',
207
- // TODO: remove this when upgrading to webpack 5
208
- futureEmitAssets: true,
209
- // There are also additional JS chunk files if you use code splitting.
210
- chunkFilename: isEnvProduction
211
- ? 'static/js/[name].[contenthash:8].chunk.js'
212
- : isEnvDevelopment && 'static/js/[name].chunk.js',
213
- // webpack uses `publicPath` to determine where the app is being served from.
214
- // It requires a trailing slash, or the file assets will get an incorrect path.
215
- // We inferred the "public path" (such as / or /my-project) from homepage.
216
- publicPath: paths.publicUrlOrPath,
217
- // Point sourcemap entries to original disk location (format as URL on Windows)
218
- devtoolModuleFilenameTemplate: isEnvProduction
219
- ? info =>
220
- path
221
- .relative(paths.appSrc, info.absoluteResourcePath)
222
- .replace(/\\/g, '/')
223
- : isEnvDevelopment &&
224
- (info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
225
- // Prevents conflicts when multiple webpack runtimes (from different apps)
226
- // are used on the same page.
227
- jsonpFunction: `webpackJsonp${appPackageJson.name}`,
228
- // this defaults to 'window', but by setting it to 'this' then
229
- // module chunks which are built will work in web workers as well.
230
- globalObject: 'this',
231
- },
232
- optimization: {
233
- minimize: isEnvProduction,
234
- minimizer: [
235
- // This is only used in production mode
236
- new TerserPlugin({
237
- terserOptions: {
238
- parse: {
239
- // We want terser to parse ecma 8 code. However, we don't want it
240
- // to apply any minification steps that turns valid ecma 5 code
241
- // into invalid ecma 5 code. This is why the 'compress' and 'output'
242
- // sections only apply transformations that are ecma 5 safe
243
- // https://github.com/facebook/create-react-app/pull/4234
244
- ecma: 8,
245
- },
246
- compress: {
247
- ecma: 5,
248
- warnings: false,
249
- // Disabled because of an issue with Uglify breaking seemingly valid code:
250
- // https://github.com/facebook/create-react-app/issues/2376
251
- // Pending further investigation:
252
- // https://github.com/mishoo/UglifyJS2/issues/2011
253
- comparisons: false,
254
- // Disabled because of an issue with Terser breaking valid code:
255
- // https://github.com/facebook/create-react-app/issues/5250
256
- // Pending further investigation:
257
- // https://github.com/terser-js/terser/issues/120
258
- inline: 2,
259
- },
260
- mangle: {
261
- safari10: true,
262
- },
263
- // Added for profiling in devtools
264
- keep_classnames: isEnvProductionProfile,
265
- keep_fnames: isEnvProductionProfile,
266
- output: {
267
- ecma: 5,
268
- comments: false,
269
- // Turned on because emoji and regex is not minified properly using default
270
- // https://github.com/facebook/create-react-app/issues/2488
271
- ascii_only: true,
272
- },
273
- },
274
- sourceMap: shouldUseSourceMap,
275
- }),
276
- // This is only used in production mode
277
- new OptimizeCSSAssetsPlugin({
278
- cssProcessorOptions: {
279
- parser: safePostCssParser,
280
- map: shouldUseSourceMap
281
- ? {
282
- // `inline: false` forces the sourcemap to be output into a
283
- // separate file
284
- inline: false,
285
- // `annotation: true` appends the sourceMappingURL to the end of
286
- // the css file, helping the browser find the sourcemap
287
- annotation: true,
288
- }
289
- : false,
290
- },
291
- cssProcessorPluginOptions: {
292
- preset: ['default', { minifyFontValues: { removeQuotes: false } }],
293
- },
294
- }),
295
- ],
296
- // Automatically split vendor and commons
297
- // https://twitter.com/wSokra/status/969633336732905474
298
- // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
299
- splitChunks: {
300
- chunks: 'all',
301
- name: isEnvDevelopment,
302
- },
303
- // Keep the runtime chunk separated to enable long term caching
304
- // https://twitter.com/wSokra/status/969679223278505985
305
- // https://github.com/facebook/create-react-app/issues/5358
306
- runtimeChunk: {
307
- name: entrypoint => `runtime-${entrypoint.name}`,
308
- },
309
- },
310
- resolve: {
311
- // This allows you to set a fallback for where webpack should look for modules.
312
- // We placed these paths second because we want `node_modules` to "win"
313
- // if there are any conflicts. This matches Node resolution mechanism.
314
- // https://github.com/facebook/create-react-app/issues/253
315
- modules: ['node_modules', paths.appNodeModules].concat(
316
- modules.additionalModulePaths || []
317
- ),
318
- // These are the reasonable defaults supported by the Node ecosystem.
319
- // We also include JSX as a common component filename extension to support
320
- // some tools, although we do not recommend using it, see:
321
- // https://github.com/facebook/create-react-app/issues/290
322
- // `web` extension prefixes have been added for better support
323
- // for React Native Web.
324
- extensions: paths.moduleFileExtensions
325
- .map(ext => `.${ext}`)
326
- .filter(ext => useTypeScript || !ext.includes('ts')),
327
- alias: {
328
- // Support React Native Web
329
- // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
330
- 'react-native': 'react-native-web',
331
- // Allows for better profiling with ReactDevTools
332
- ...(isEnvProductionProfile && {
333
- 'react-dom$': 'react-dom/profiling',
334
- 'scheduler/tracing': 'scheduler/tracing-profiling',
335
- }),
336
- ...(modules.webpackAliases || {}),
337
- },
338
- plugins: [
339
- // Adds support for installing with Plug'n'Play, leading to faster installs and adding
340
- // guards against forgotten dependencies and such.
341
- PnpWebpackPlugin,
342
- // Prevents users from importing files from outside of src/ (or node_modules/).
343
- // This often causes confusion because we only process files within src/ with babel.
344
- // To fix this, we prevent you from importing files out of src/ -- if you'd like to,
345
- // please link the files into your node_modules/ and let module-resolution kick in.
346
- // Make sure your source files are compiled, as they will not be processed in any way.
347
- new ModuleScopePlugin(paths.appSrc, [
348
- paths.appPackageJson,
349
- reactRefreshOverlayEntry,
350
- ]),
351
- ],
352
- },
353
- resolveLoader: {
354
- plugins: [
355
- // Also related to Plug'n'Play, but this time it tells webpack to load its loaders
356
- // from the current package.
357
- PnpWebpackPlugin.moduleLoader(module),
358
- ],
359
- },
360
- module: {
361
- strictExportPresence: true,
362
- rules: [
363
- // Disable require.ensure as it's not a standard language feature.
364
- { parser: { requireEnsure: false } },
365
- {
366
- // "oneOf" will traverse all following loaders until one will
367
- // match the requirements. When no loader matches it will fall
368
- // back to the "file" loader at the end of the loader list.
369
- oneOf: [
370
- // TODO: Merge this config once `image/avif` is in the mime-db
371
- // https://github.com/jshttp/mime-db
372
- {
373
- test: [/\.avif$/],
374
- loader: require.resolve('url-loader'),
375
- options: {
376
- limit: imageInlineSizeLimit,
377
- mimetype: 'image/avif',
378
- name: 'static/media/[name].[hash:8].[ext]',
379
- },
380
- },
381
- // "url" loader works like "file" loader except that it embeds assets
382
- // smaller than specified limit in bytes as data URLs to avoid requests.
383
- // A missing `test` is equivalent to a match.
384
- {
385
- test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
386
- loader: require.resolve('url-loader'),
387
- options: {
388
- limit: imageInlineSizeLimit,
389
- name: 'static/media/[name].[hash:8].[ext]',
390
- },
391
- },
392
- // Process application JS with Babel.
393
- // The preset includes JSX, Flow, TypeScript, and some ESnext features.
394
- {
395
- test: /\.(js|mjs|jsx|ts|tsx)$/,
396
- include: paths.appSrc,
397
- loader: require.resolve('babel-loader'),
398
- options: {
399
- customize: require.resolve(
400
- 'babel-preset-react-app/webpack-overrides'
401
- ),
402
- presets: [
403
- [
404
- require.resolve('babel-preset-react-app'),
405
- {
406
- runtime: hasJsxRuntime ? 'automatic' : 'classic',
407
- },
408
- ],
409
- ],
410
-
411
- plugins: [
412
- [
413
- require.resolve('babel-plugin-named-asset-import'),
414
- {
415
- loaderMap: {
416
- svg: {
417
- ReactComponent:
418
- '@svgr/webpack?-svgo,+titleProp,+ref![path]',
419
- },
420
- },
421
- },
422
- ],
423
- isEnvDevelopment &&
424
- shouldUseReactRefresh &&
425
- require.resolve('react-refresh/babel'),
426
- ].filter(Boolean),
427
- // This is a feature of `babel-loader` for webpack (not Babel itself).
428
- // It enables caching results in ./node_modules/.cache/babel-loader/
429
- // directory for faster rebuilds.
430
- cacheDirectory: true,
431
- // See #6846 for context on why cacheCompression is disabled
432
- cacheCompression: false,
433
- compact: isEnvProduction,
434
- },
435
- },
436
- // Process any JS outside of the app with Babel.
437
- // Unlike the application JS, we only compile the standard ES features.
438
- {
439
- test: /\.(js|mjs)$/,
440
- exclude: /@babel(?:\/|\\{1,2})runtime/,
441
- loader: require.resolve('babel-loader'),
442
- options: {
443
- babelrc: false,
444
- configFile: false,
445
- compact: false,
446
- presets: [
447
- [
448
- require.resolve('babel-preset-react-app/dependencies'),
449
- { helpers: true },
450
- ],
451
- ],
452
- cacheDirectory: true,
453
- // See #6846 for context on why cacheCompression is disabled
454
- cacheCompression: false,
455
-
456
- // Babel sourcemaps are needed for debugging into node_modules
457
- // code. Without the options below, debuggers like VSCode
458
- // show incorrect code and set breakpoints on the wrong lines.
459
- sourceMaps: shouldUseSourceMap,
460
- inputSourceMap: shouldUseSourceMap,
461
- },
462
- },
463
- // "postcss" loader applies autoprefixer to our CSS.
464
- // "css" loader resolves paths in CSS and adds assets as dependencies.
465
- // "style" loader turns CSS into JS modules that inject <style> tags.
466
- // In production, we use MiniCSSExtractPlugin to extract that CSS
467
- // to a file, but in development "style" loader enables hot editing
468
- // of CSS.
469
- // By default we support CSS Modules with the extension .module.css
470
- {
471
- test: cssRegex,
472
- exclude: cssModuleRegex,
473
- use: getStyleLoaders({
474
- importLoaders: 1,
475
- sourceMap: isEnvProduction
476
- ? shouldUseSourceMap
477
- : isEnvDevelopment,
478
- }),
479
- // Don't consider CSS imports dead code even if the
480
- // containing package claims to have no side effects.
481
- // Remove this when webpack adds a warning or an error for this.
482
- // See https://github.com/webpack/webpack/issues/6571
483
- sideEffects: true,
484
- },
485
- // Adds support for CSS Modules (https://github.com/css-modules/css-modules)
486
- // using the extension .module.css
487
- {
488
- test: cssModuleRegex,
489
- use: getStyleLoaders({
490
- importLoaders: 1,
491
- sourceMap: isEnvProduction
492
- ? shouldUseSourceMap
493
- : isEnvDevelopment,
494
- modules: {
495
- getLocalIdent: getCSSModuleLocalIdent,
496
- },
497
- }),
498
- },
499
- // Opt-in support for SASS (using .scss or .sass extensions).
500
- // By default we support SASS Modules with the
501
- // extensions .module.scss or .module.sass
502
- {
503
- test: sassRegex,
504
- exclude: sassModuleRegex,
505
- use: getStyleLoaders(
506
- {
507
- importLoaders: 3,
508
- sourceMap: isEnvProduction
509
- ? shouldUseSourceMap
510
- : isEnvDevelopment,
511
- },
512
- 'sass-loader'
513
- ),
514
- // Don't consider CSS imports dead code even if the
515
- // containing package claims to have no side effects.
516
- // Remove this when webpack adds a warning or an error for this.
517
- // See https://github.com/webpack/webpack/issues/6571
518
- sideEffects: true,
519
- },
520
- // Adds support for CSS Modules, but using SASS
521
- // using the extension .module.scss or .module.sass
522
- {
523
- test: sassModuleRegex,
524
- use: getStyleLoaders(
525
- {
526
- importLoaders: 3,
527
- sourceMap: isEnvProduction
528
- ? shouldUseSourceMap
529
- : isEnvDevelopment,
530
- modules: {
531
- getLocalIdent: getCSSModuleLocalIdent,
532
- },
533
- },
534
- 'sass-loader'
535
- ),
536
- },
537
- // "file" loader makes sure those assets get served by WebpackDevServer.
538
- // When you `import` an asset, you get its (virtual) filename.
539
- // In production, they would get copied to the `build` folder.
540
- // This loader doesn't use a "test" so it will catch all modules
541
- // that fall through the other loaders.
542
- {
543
- loader: require.resolve('file-loader'),
544
- // Exclude `js` files to keep "css" loader working as it injects
545
- // its runtime that would otherwise be processed through "file" loader.
546
- // Also exclude `html` and `json` extensions so they get processed
547
- // by webpacks internal loaders.
548
- exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
549
- options: {
550
- name: 'static/media/[name].[hash:8].[ext]',
551
- },
552
- },
553
- // ** STOP ** Are you adding a new loader?
554
- // Make sure to add the new loader(s) before the "file" loader.
555
- ],
556
- },
557
- ],
558
- },
559
- plugins: [
560
- // Generates an `index.html` file with the <script> injected.
561
- new HtmlWebpackPlugin(
562
- Object.assign(
563
- {},
564
- {
565
- inject: true,
566
- template: paths.appHtml,
567
- },
568
- isEnvProduction
569
- ? {
570
- minify: {
571
- removeComments: true,
572
- collapseWhitespace: true,
573
- removeRedundantAttributes: true,
574
- useShortDoctype: true,
575
- removeEmptyAttributes: true,
576
- removeStyleLinkTypeAttributes: true,
577
- keepClosingSlash: true,
578
- minifyJS: true,
579
- minifyCSS: true,
580
- minifyURLs: true,
581
- },
582
- }
583
- : undefined
584
- )
585
- ),
586
- // Inlines the webpack runtime script. This script is too small to warrant
587
- // a network request.
588
- // https://github.com/facebook/create-react-app/issues/5358
589
- isEnvProduction &&
590
- shouldInlineRuntimeChunk &&
591
- new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime-.+[.]js/]),
592
- // Makes some environment variables available in index.html.
593
- // The public URL is available as %PUBLIC_URL% in index.html, e.g.:
594
- // <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
595
- // It will be an empty string unless you specify "homepage"
596
- // in `package.json`, in which case it will be the pathname of that URL.
597
- new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
598
- // This gives some necessary context to module not found errors, such as
599
- // the requesting resource.
600
- new ModuleNotFoundPlugin(paths.appPath),
601
- // Makes some environment variables available to the JS code, for example:
602
- // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
603
- // It is absolutely essential that NODE_ENV is set to production
604
- // during a production build.
605
- // Otherwise React will be compiled in the very slow development mode.
606
- new webpack.DefinePlugin(env.stringified),
607
- // This is necessary to emit hot updates (CSS and Fast Refresh):
608
- isEnvDevelopment && new webpack.HotModuleReplacementPlugin(),
609
- // Experimental hot reloading for React .
610
- // https://github.com/facebook/react/tree/master/packages/react-refresh
611
- isEnvDevelopment &&
612
- shouldUseReactRefresh &&
613
- new ReactRefreshWebpackPlugin({
614
- overlay: {
615
- entry: webpackDevClientEntry,
616
- // The expected exports are slightly different from what the overlay exports,
617
- // so an interop is included here to enable feedback on module-level errors.
618
- module: reactRefreshOverlayEntry,
619
- // Since we ship a custom dev client and overlay integration,
620
- // the bundled socket handling logic can be eliminated.
621
- sockIntegration: false,
622
- },
623
- }),
624
- // Watcher doesn't work well if you mistype casing in a path so we use
625
- // a plugin that prints an error when you attempt to do this.
626
- // See https://github.com/facebook/create-react-app/issues/240
627
- isEnvDevelopment && new CaseSensitivePathsPlugin(),
628
- // If you require a missing module and then `npm install` it, you still have
629
- // to restart the development server for webpack to discover it. This plugin
630
- // makes the discovery automatic so you don't have to restart.
631
- // See https://github.com/facebook/create-react-app/issues/186
632
- isEnvDevelopment &&
633
- new WatchMissingNodeModulesPlugin(paths.appNodeModules),
634
- isEnvProduction &&
635
- new MiniCssExtractPlugin({
636
- // Options similar to the same options in webpackOptions.output
637
- // both options are optional
638
- filename: 'static/css/[name].[contenthash:8].css',
639
- chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
640
- }),
641
- // Generate an asset manifest file with the following content:
642
- // - "files" key: Mapping of all asset filenames to their corresponding
643
- // output file so that tools can pick it up without having to parse
644
- // `index.html`
645
- // - "entrypoints" key: Array of files which are included in `index.html`,
646
- // can be used to reconstruct the HTML if necessary
647
- new ManifestPlugin({
648
- fileName: 'asset-manifest.json',
649
- publicPath: paths.publicUrlOrPath,
650
- generate: (seed, files, entrypoints) => {
651
- const manifestFiles = files.reduce((manifest, file) => {
652
- manifest[file.name] = file.path;
653
- return manifest;
654
- }, seed);
655
- const entrypointFiles = entrypoints.main.filter(
656
- fileName => !fileName.endsWith('.map')
657
- );
658
-
659
- return {
660
- files: manifestFiles,
661
- entrypoints: entrypointFiles,
662
- };
663
- },
664
- }),
665
- // Moment.js is an extremely popular library that bundles large locale files
666
- // by default due to how webpack interprets its code. This is a practical
667
- // solution that requires the user to opt into importing specific locales.
668
- // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
669
- // You can remove this if you don't use Moment.js:
670
- new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
671
- // Generate a service worker script that will precache, and keep up to date,
672
- // the HTML & assets that are part of the webpack build.
673
- isEnvProduction &&
674
- fs.existsSync(swSrc) &&
675
- new WorkboxWebpackPlugin.InjectManifest({
676
- swSrc,
677
- dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
678
- exclude: [/\.map$/, /asset-manifest\.json$/, /LICENSE/],
679
- // Bump up the default maximum size (2mb) that's precached,
680
- // to make lazy-loading failure scenarios less likely.
681
- // See https://github.com/cra-template/pwa/issues/13#issuecomment-722667270
682
- maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
683
- }),
684
- // TypeScript type checking
685
- useTypeScript &&
686
- new ForkTsCheckerWebpackPlugin({
687
- typescript: resolve.sync('typescript', {
688
- basedir: paths.appNodeModules,
689
- }),
690
- async: isEnvDevelopment,
691
- checkSyntacticErrors: true,
692
- resolveModuleNameModule: process.versions.pnp
693
- ? `${__dirname}/pnpTs.js`
694
- : undefined,
695
- resolveTypeReferenceDirectiveModule: process.versions.pnp
696
- ? `${__dirname}/pnpTs.js`
697
- : undefined,
698
- tsconfig: paths.appTsConfig,
699
- reportFiles: [
700
- // This one is specifically to match during CI tests,
701
- // as micromatch doesn't match
702
- // '../cra-template-typescript/template/src/App.tsx'
703
- // otherwise.
704
- '../**/src/**/*.{ts,tsx}',
705
- '**/src/**/*.{ts,tsx}',
706
- '!**/src/**/__tests__/**',
707
- '!**/src/**/?(*.)(spec|test).*',
708
- '!**/src/setupProxy.*',
709
- '!**/src/setupTests.*',
710
- ],
711
- silent: true,
712
- // The formatter is invoked directly in WebpackDevServerUtils during development
713
- formatter: isEnvProduction ? typescriptFormatter : undefined,
714
- }),
715
- !disableESLintPlugin &&
716
- new ESLintPlugin({
717
- // Plugin options
718
- extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
719
- formatter: require.resolve('react-dev-utils/eslintFormatter'),
720
- eslintPath: require.resolve('eslint'),
721
- failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
722
- context: paths.appSrc,
723
- cache: true,
724
- cacheLocation: path.resolve(
725
- paths.appNodeModules,
726
- '.cache/.eslintcache'
727
- ),
728
- // ESLint class options
729
- cwd: paths.appPath,
730
- resolvePluginsRelativeTo: __dirname,
731
- baseConfig: {
732
- extends: [require.resolve('eslint-config-react-app/base')],
733
- rules: {
734
- ...(!hasJsxRuntime && {
735
- 'react/react-in-jsx-scope': 'error',
736
- }),
737
- },
738
- },
739
- }),
740
- ].filter(Boolean),
741
- // Some libraries import Node modules but don't use them in the browser.
742
- // Tell webpack to provide empty mocks for them so importing them works.
743
- node: {
744
- module: 'empty',
745
- dgram: 'empty',
746
- dns: 'mock',
747
- fs: 'empty',
748
- http2: 'empty',
749
- net: 'empty',
750
- tls: 'empty',
751
- child_process: 'empty',
752
- },
753
- // Turn off performance processing because we utilize
754
- // our own hints via the FileSizeReporter
755
- performance: false,
756
- };
757
- };