@defra/interactive-map 0.0.52-alpha → 0.0.53-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/esm/im-core.js +1 -1
  2. package/dist/umd/im-core.js +1 -1
  3. package/dist/umd/index.js +1 -1
  4. package/docs/api/context.md +18 -12
  5. package/docs/api/marker-config.md +16 -8
  6. package/docs/api/symbol-config.md +24 -9
  7. package/docs/api/symbol-registry.md +49 -14
  8. package/docs/plugins/datasets.md +4 -10
  9. package/docs/plugins/draw.md +2 -1
  10. package/docs/plugins/map-key.md +6 -4
  11. package/package.json +1 -1
  12. package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
  13. package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
  14. package/plugins/beta/map-styles/dist/umd/index.js +1 -1
  15. package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
  16. package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
  17. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  18. package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
  19. package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
  20. package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
  21. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  22. package/plugins/datasets/src/adapters/maplibre/layerBuilders.js +9 -9
  23. package/plugins/datasets/src/adapters/maplibre/layerBuilders.test.js +19 -3
  24. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +9 -3
  25. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +18 -3
  26. package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.js +3 -3
  27. package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +19 -26
  28. package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.js +15 -67
  29. package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +32 -105
  30. package/plugins/datasets/src/adapters/openlayers/layerBuilders.js +11 -13
  31. package/plugins/datasets/src/adapters/openlayers/layerBuilders.test.js +11 -3
  32. package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.js +48 -19
  33. package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +99 -11
  34. package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +26 -26
  35. package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +48 -29
  36. package/plugins/datasets/src/initialise/defaults.js +4 -3
  37. package/plugins/datasets/src/reducers/__data__/demoDatasets.js +1 -3
  38. package/plugins/datasets/src/registry/dataset.js +2 -1
  39. package/plugins/datasets/src/registry/dataset.test.js +13 -0
  40. package/plugins/datasets/src/registry/mapboxStyleDataset.js +1 -1
  41. package/plugins/datasets/src/registry/mapboxStyleDataset.test.js +1 -1
  42. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  43. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  44. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  45. package/plugins/draw/dist/esm/index.js +1 -1
  46. package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
  47. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
  48. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  49. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  50. package/plugins/draw/dist/umd/index.js +1 -1
  51. package/plugins/draw/src/DrawInit.jsx +7 -5
  52. package/plugins/draw/src/DrawInit.test.jsx +18 -2
  53. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +11 -5
  54. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +27 -11
  55. package/plugins/draw/src/adapters/maplibre/mapboxDraw.js +12 -9
  56. package/plugins/draw/src/adapters/maplibre/mapboxDraw.test.js +18 -0
  57. package/plugins/draw/src/adapters/maplibre/pointSymbolImages.js +81 -56
  58. package/plugins/draw/src/adapters/maplibre/pointSymbolImages.test.js +149 -80
  59. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +7 -6
  60. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +22 -25
  61. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +26 -8
  62. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +58 -16
  63. package/plugins/draw/src/adapters/openlayers/core/styles.js +33 -20
  64. package/plugins/draw/src/adapters/openlayers/core/styles.test.js +47 -21
  65. package/plugins/draw/src/adapters/openlayers/olDraw.js +16 -12
  66. package/plugins/draw/src/adapters/openlayers/olDraw.test.js +27 -32
  67. package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.js +44 -49
  68. package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +100 -119
  69. package/plugins/draw/src/defaults.js +2 -6
  70. package/plugins/draw/src/utils/stripInternalProperties.test.js +2 -1
  71. package/plugins/draw/src/utils/symbolKeys.js +3 -4
  72. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  73. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  74. package/plugins/interact/dist/umd/index.js +1 -1
  75. package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
  76. package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -2
  77. package/plugins/map-key/dist/umd/index.js +1 -1
  78. package/plugins/map-key/src/components/Key/Key.jsx +8 -4
  79. package/plugins/map-key/src/components/Key/KeyGroupItem.jsx +3 -1
  80. package/plugins/map-key/src/components/Key/KeyItem.jsx +2 -2
  81. package/plugins/map-key/src/components/Key/KeySvg.jsx +15 -14
  82. package/plugins/map-key/src/components/Key/KeySvg.test.jsx +21 -14
  83. package/plugins/map-key/src/components/Key/KeySvgPattern.jsx +1 -2
  84. package/plugins/map-key/src/components/Key/KeySvgPattern.test.jsx +3 -1
  85. package/plugins/map-key/src/components/Key/KeySvgSymbol.jsx +26 -12
  86. package/plugins/map-key/src/components/Key/KeySvgSymbol.test.jsx +24 -74
  87. package/plugins/map-key/src/components/Key/MapKey.jsx +3 -1
  88. package/plugins/map-key/src/components/Key/svgProperties.js +8 -2
  89. package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +15 -0
  90. package/plugins/map-key/src/registry/index.js +0 -2
  91. package/plugins/map-key/src/registry/index.test.js +1 -9
  92. package/plugins/menu/src/registry/index.js +0 -2
  93. package/plugins/menu/src/registry/index.test.js +1 -9
  94. package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
  95. package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
  96. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
  97. package/providers/beta/openlayers/dist/umd/index.js +1 -1
  98. package/providers/beta/openlayers/src/openlayersProvider.js +102 -2
  99. package/providers/beta/openlayers/src/openlayersProvider.test.js +95 -0
  100. package/providers/beta/openlayers/src/utils/highlightFeatures.js +20 -25
  101. package/providers/beta/openlayers/src/utils/highlightFeatures.test.js +73 -38
  102. package/providers/beta/openlayers/src/utils/patternImages.js +61 -0
  103. package/providers/beta/openlayers/src/utils/patternImages.test.js +74 -0
  104. package/providers/beta/openlayers/src/utils/symbolImages.js +103 -95
  105. package/providers/beta/openlayers/src/utils/symbolImages.test.js +136 -85
  106. package/providers/mapProvider.js +53 -1
  107. package/providers/mapProvider.test.js +6 -0
  108. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  109. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  110. package/providers/maplibre/dist/umd/index.js +1 -1
  111. package/providers/maplibre/src/maplibreProvider.js +50 -17
  112. package/providers/maplibre/src/maplibreProvider.test.js +74 -20
  113. package/providers/maplibre/src/utils/highlightFeatures.js +19 -14
  114. package/providers/maplibre/src/utils/highlightFeatures.test.js +20 -14
  115. package/providers/maplibre/src/utils/patternImages.js +46 -29
  116. package/providers/maplibre/src/utils/patternImages.test.js +52 -4
  117. package/providers/maplibre/src/utils/symbolImages.js +80 -39
  118. package/providers/maplibre/src/utils/symbolImages.test.js +157 -54
  119. package/src/App/components/Markers/Markers.jsx +16 -25
  120. package/src/App/components/Markers/Markers.test.jsx +34 -48
  121. package/src/App/components/Markers/SymbolLabelMarker.jsx +1 -1
  122. package/src/App/components/Markers/SymbolMarker.jsx +1 -1
  123. package/src/App/store/ServiceProvider.jsx +6 -3
  124. package/src/App/store/ServiceProvider.test.jsx +24 -0
  125. package/src/config/appConfig.js +1 -5
  126. package/src/config/mapSizeScales.js +8 -0
  127. package/src/config/symbolConfig.js +101 -25
  128. package/src/services/patternRegistry.js +97 -76
  129. package/src/services/patternRegistry.test.js +19 -1
  130. package/src/services/symbolComposer.js +184 -0
  131. package/src/services/symbolComposer.test.js +132 -0
  132. package/src/services/symbolRegistry.js +326 -155
  133. package/src/services/symbolRegistry.test.js +334 -32
  134. package/src/types.js +9 -3
  135. package/src/utils/hashString.js +23 -0
  136. package/src/utils/hashString.test.js +29 -0
  137. package/src/utils/imageDataCache.js +43 -0
  138. package/src/utils/imageDataCache.test.js +38 -0
  139. package/src/utils/pathBounds.js +330 -0
  140. package/src/utils/pathBounds.test.js +145 -0
  141. package/src/utils/patternUtils.js +0 -8
  142. package/src/utils/patternUtils.test.js +0 -25
  143. package/src/utils/recentImageSets.js +35 -0
  144. package/src/utils/recentImageSets.test.js +46 -0
  145. package/src/utils/symbolUtils.js +26 -29
  146. package/src/utils/symbolUtils.test.js +27 -41
  147. package/plugins/map-key/dist/umd/im-map-key-plugin.js.LICENSE.txt +0 -1
@@ -26,11 +26,11 @@ const makeEventBus = () => {
26
26
  }
27
27
  }
28
28
 
29
+ // Stands in for the registry: every marker resolves to a 38×38 symbol anchored at its bottom centre
29
30
  const makeSymbolRegistry = (overrides = {}) => ({
30
- get: jest.fn(() => ({ svg: '<circle/>', viewBox: '0 0 38 38', anchor: [0.5, 1] })),
31
- getDefaults: jest.fn(() => ({ symbol: 'pin', viewBox: '0 0 38 38', anchor: [0.5, 1] })),
32
- resolve: jest.fn(() => '<circle/>'),
33
- resolveSelected: jest.fn(() => '<circle class="selected"/>'),
31
+ getDefaults: jest.fn(() => ({ symbol: 'pin' })),
32
+ getMarkerSymbolDef: jest.fn(() => ({ svg: '<circle/>', viewBox: '0 0 38 38', anchor: [0.5, 1] })),
33
+ resolveVariant: jest.fn((symbolDef, styleValues, mapStyle, variant) => `<circle class="${variant}"/>`),
34
34
  ...overrides
35
35
  })
36
36
 
@@ -76,7 +76,7 @@ describe('Markers — basic rendering', () => {
76
76
 
77
77
  describe('Markers — routing', () => {
78
78
  it('renders a LabelMarker for a marker with symbol: null', () => {
79
- const marker = makeMarker({ id: 'lbl', label: 'My label', symbol: null, symbolSvgContent: null })
79
+ const marker = makeMarker({ id: 'lbl', label: 'My label', symbol: null, svgContent: null })
80
80
  const { result } = setup({ markers: [marker] })
81
81
  const wrapper = result.container.querySelector('.im-c-marker-wrapper--label')
82
82
  expect(wrapper).toBeTruthy()
@@ -103,42 +103,30 @@ describe('Markers — routing', () => {
103
103
  // ─── Markers — symbol resolution ─────────────────────────────────────────────
104
104
 
105
105
  describe('Markers — symbol resolution', () => {
106
- it('uses inline symbolSvgContent over the symbol registry', () => {
107
- const sr = makeSymbolRegistry()
108
- setup({ markers: [makeMarker({ symbolSvgContent: '<rect/>' })], symbolRegistry: sr })
109
- expect(sr.get).not.toHaveBeenCalled()
106
+ it('asks the registry for the marker\'s symbol definition', () => {
107
+ const marker = makeMarker({ size: 'large', viewBox: '0 0 50 60' })
108
+ const { sr } = setup({ markers: [marker] })
109
+ expect(sr.getMarkerSymbolDef).toHaveBeenCalledWith(marker)
110
110
  })
111
111
 
112
- it('falls back to defaults.symbolSvgContent', () => {
113
- const sr = makeSymbolRegistry({
114
- getDefaults: jest.fn(() => ({ symbolSvgContent: '<default-svg/>', viewBox: '0 0 38 38', anchor: [0.5, 1] }))
115
- })
116
- setup({ markers: [makeMarker({ symbol: null })], symbolRegistry: sr })
117
- expect(sr.get).not.toHaveBeenCalled()
112
+ it('renders at the definition\'s viewBox and anchor, and keeps marker options out of the style values', () => {
113
+ const sr = makeSymbolRegistry({ getMarkerSymbolDef: jest.fn(() => ({ svg: '<circle/>', viewBox: '0 0 30 40', anchor: [0.5, 1] })) })
114
+ const { result } = setup({ markers: [makeMarker({ size: 'large', anchor: [0, 0], backgroundColor: '#123456' })], symbolRegistry: sr })
115
+ const svg = result.container.querySelector(SVG_SEL)
116
+ expect(svg.getAttribute('width')).toBe('30')
117
+ expect(svg.getAttribute('height')).toBe('40')
118
+ expect(svg).toHaveStyle({ marginLeft: '-15px', marginTop: '-40px' })
119
+ const styleValues = sr.resolveVariant.mock.calls[0][1]
120
+ expect(styleValues).toEqual({ backgroundColor: '#123456' })
118
121
  })
119
122
 
120
- it('uses marker.viewBox when provided', () => {
121
- const svg = setup({ markers: [makeMarker({ viewBox: '0 0 50 60' })] }).result.container.querySelector(SVG_SEL)
122
- expect(svg.getAttribute('viewBox')).toBe('0 0 50 60')
123
- expect(svg.getAttribute('width')).toBe('50')
124
- expect(svg.getAttribute('height')).toBe('60')
125
- })
126
-
127
- it("falls back to '0 0 44 44' viewBox when none is provided", () => {
128
- const sr = makeSymbolRegistry({
129
- get: jest.fn(() => ({ svg: '<circle/>' })),
130
- getDefaults: jest.fn(() => ({ symbol: 'pin' }))
131
- })
132
- expect(setup({ markers: [makeMarker()], symbolRegistry: sr }).result.container.querySelector(SVG_SEL).getAttribute('viewBox')).toBe('0 0 44 44')
133
- })
134
-
135
- it.each([
136
- ['marker.anchor', makeMarker({ anchor: [0, 0] }), null, '0px', '0px'],
137
- ['symbolDef.anchor', makeMarker(), { get: jest.fn(() => ({ svg: '<circle/>', viewBox: '0 0 38 38', anchor: [0, 0.5] })), getDefaults: jest.fn(() => ({ symbol: 'pin', viewBox: '0 0 38 38' })) }, '0px', '-19px'],
138
- ['[0.5, 0.5] fallback', makeMarker(), { get: jest.fn(() => ({ svg: '<circle/>', viewBox: '0 0 38 38' })), getDefaults: jest.fn(() => ({ symbol: 'pin', viewBox: '0 0 38 38' })) }, '-19px', '-19px']
139
- ])('resolveAnchor uses %s', (_, marker, srOverrides, left, top) => {
140
- const sr = srOverrides ? makeSymbolRegistry(srOverrides) : null
141
- expect(setup({ markers: [marker], symbolRegistry: sr }).result.container.querySelector(SVG_SEL)).toHaveStyle({ marginLeft: left, marginTop: top })
123
+ it('falls back to a centred 44×44 viewBox for a marker with no known symbol', () => {
124
+ const sr = makeSymbolRegistry({ getMarkerSymbolDef: jest.fn(() => undefined) })
125
+ const { result } = setup({ markers: [makeMarker({ symbol: 'not-registered' })], symbolRegistry: sr })
126
+ const svg = result.container.querySelector(SVG_SEL)
127
+ expect(sr.resolveVariant).toHaveBeenCalledWith(undefined, expect.any(Object), 'outdoor', 'normal')
128
+ expect(svg.getAttribute('viewBox')).toBe('0 0 44 44')
129
+ expect(svg).toHaveStyle({ marginLeft: '-22px', marginTop: '-22px' })
142
130
  })
143
131
 
144
132
  it.each([
@@ -161,27 +149,25 @@ describe('Markers — symbol resolution', () => {
161
149
  // ─── Markers — selection ──────────────────────────────────────────────────────
162
150
 
163
151
  describe('Markers — selection', () => {
164
- it('adds selected class and calls resolveSelected when marker is selected', () => {
152
+ it('adds selected class and resolves the selected variant when marker is selected', () => {
165
153
  const { eb, sr, result } = setup({ markers: [makeMarker()] })
166
154
  act(() => eb.emit(SEL_CHANGE, { selectedMarkers: [MARKER_ID] }))
167
155
  expect(result.container.querySelector(SVG_SEL)).toHaveClass(SELECTED_CLASS)
168
- expect(sr.resolveSelected).toHaveBeenCalled()
169
- expect(sr.resolve).not.toHaveBeenCalledAfter?.(sr.resolveSelected)
156
+ expect(sr.resolveVariant).toHaveBeenLastCalledWith(expect.anything(), expect.any(Object), 'outdoor', 'selected')
170
157
  })
171
158
 
172
- it('calls resolveActive when the marker is the active listbox item', () => {
159
+ it('resolves the active variant for the active listbox item, even when selected', () => {
173
160
  const SET_ACTIVE = 'map:setactiveitem'
174
- const sr = makeSymbolRegistry({ resolveActive: jest.fn(() => '<circle class="active"/>') })
175
- const { eb } = setup({ markers: [makeMarker()], symbolRegistry: sr })
161
+ const { eb, sr } = setup({ markers: [makeMarker()] })
162
+ act(() => eb.emit(SEL_CHANGE, { selectedMarkers: [MARKER_ID] }))
176
163
  act(() => eb.emit(SET_ACTIVE, { id: MARKER_ID }))
177
- expect(sr.resolveActive).toHaveBeenCalled()
178
- expect(sr.resolveSelected).not.toHaveBeenCalled()
164
+ expect(sr.resolveVariant).toHaveBeenLastCalledWith(expect.anything(), expect.any(Object), 'outdoor', 'active')
179
165
  })
180
166
 
181
- it('uses resolve (not resolveSelected) for unselected markers', () => {
167
+ it('resolves the normal variant for unselected markers', () => {
182
168
  const { sr } = setup({ markers: [makeMarker()] })
183
- expect(sr.resolve).toHaveBeenCalled()
184
- expect(sr.resolveSelected).not.toHaveBeenCalled()
169
+ expect(sr.resolveVariant).toHaveBeenCalledWith(expect.anything(), expect.any(Object), 'outdoor', 'normal')
170
+ expect(sr.resolveVariant).not.toHaveBeenCalledWith(expect.anything(), expect.any(Object), 'outdoor', 'selected')
185
171
  })
186
172
 
187
173
  it.each([
@@ -28,7 +28,7 @@ const SymbolLabelMarker = ({ marker, mapId, markerRef, isSelected, symbolProps }
28
28
  width={scaledWidth}
29
29
  height={scaledHeight}
30
30
  viewBox={viewBox}
31
- overflow='visible'
31
+ overflow='hidden'
32
32
  aria-hidden='true'
33
33
  >
34
34
  <g dangerouslySetInnerHTML={{ __html: resolvedSvg }} />
@@ -14,7 +14,7 @@ const SymbolMarker = ({ marker, mapId, markerRef, isSelected, symbolProps }) =>
14
14
  width={scaledWidth}
15
15
  height={scaledHeight}
16
16
  viewBox={viewBox}
17
- overflow='visible'
17
+ overflow='hidden'
18
18
  aria-hidden='true'
19
19
  style={{
20
20
  display: marker.isVisible ? 'block' : 'none',
@@ -5,8 +5,8 @@ import { createHints } from '../../services/hints.js'
5
5
  import { reverseGeocode } from '../../services/reverseGeocode.js'
6
6
  import { useConfig } from '../store/configContext.js'
7
7
  import { closeApp } from '../../services/closeApp.js'
8
- import { symbolRegistry } from '../../services/symbolRegistry.js'
9
- import { patternRegistry } from '../../services/patternRegistry.js'
8
+ import { createSymbolRegistry } from '../../services/symbolRegistry.js'
9
+ import { createPatternRegistry } from '../../services/patternRegistry.js'
10
10
 
11
11
  export const ServiceContext = createContext(null)
12
12
 
@@ -15,6 +15,9 @@ export const ServiceProvider = ({ eventBus, pluginRegistry, children }) => {
15
15
  const mapStatusRef = useRef(null)
16
16
  const announce = useMemo(() => createAnnouncer(mapStatusRef), [])
17
17
  const hints = useMemo(() => createHints(announce), [announce])
18
+ // One of each per map, so maps on the same page keep their own symbols, symbolDefaults and patterns
19
+ const symbolRegistry = useMemo(() => createSymbolRegistry(), [])
20
+ const patternRegistry = useMemo(() => createPatternRegistry(), [])
18
21
 
19
22
  symbolRegistry.setDefaults(constructorSymbolDefaults || {})
20
23
 
@@ -29,7 +32,7 @@ export const ServiceProvider = ({ eventBus, pluginRegistry, children }) => {
29
32
  patternRegistry,
30
33
  // See pluginRegistry.js's getPlugin() for what this does and doesn't guarantee.
31
34
  getPlugin: (pluginId) => pluginRegistry?.getPlugin(pluginId)
32
- }), [announce, hints, pluginRegistry])
35
+ }), [announce, hints, pluginRegistry, symbolRegistry, patternRegistry])
33
36
 
34
37
  return (
35
38
  <ServiceContext.Provider value={services}>
@@ -56,6 +56,30 @@ describe('ServiceProvider', () => {
56
56
  expect(result.current.mapStatusRef.current).toBeNull()
57
57
  })
58
58
 
59
+ test('gives each map its own symbol registry, kept across renders, with that map\'s symbolDefaults', () => {
60
+ const { useConfig } = jest.requireMock('../store/configContext.js')
61
+ useConfig.mockReturnValue({ id: 'map-a', symbolDefaults: { backgroundColor: '#111111' } })
62
+ const first = renderHook(() => React.useContext(ServiceContext), { wrapper })
63
+ const firstRegistry = first.result.current.symbolRegistry
64
+ first.rerender()
65
+ expect(first.result.current.symbolRegistry).toBe(firstRegistry)
66
+
67
+ useConfig.mockReturnValue({ id: 'map-b', symbolDefaults: { backgroundColor: '#222222' } })
68
+ const second = renderHook(() => React.useContext(ServiceContext), { wrapper })
69
+ expect(second.result.current.symbolRegistry).not.toBe(firstRegistry)
70
+ expect(firstRegistry.getDefaults().backgroundColor).toBe('#111111')
71
+ expect(second.result.current.symbolRegistry.getDefaults().backgroundColor).toBe('#222222')
72
+ })
73
+
74
+ test('gives each map its own pattern registry, kept across renders', () => {
75
+ const first = renderHook(() => React.useContext(ServiceContext), { wrapper })
76
+ const firstRegistry = first.result.current.patternRegistry
77
+ first.rerender()
78
+ expect(first.result.current.patternRegistry).toBe(firstRegistry)
79
+ const second = renderHook(() => React.useContext(ServiceContext), { wrapper })
80
+ expect(second.result.current.patternRegistry).not.toBe(firstRegistry)
81
+ })
82
+
59
83
  test('renders children', () => {
60
84
  const { result } = renderHook(() => React.useContext(ServiceContext), {
61
85
  wrapper,
@@ -228,8 +228,4 @@ export const defaultControlConfig = {
228
228
  }
229
229
  }
230
230
 
231
- export const scaleFactor = {
232
- small: 1,
233
- medium: 1.5,
234
- large: 2
235
- }
231
+ export { scaleFactor } from './mapSizeScales.js'
@@ -0,0 +1,8 @@
1
+ // Scale factor per app map size — applied to the map's pixel ratio, marker/symbol sizes and the
2
+ // draw UI. Kept in its own module (re-exported by appConfig.js) so plugins can share the one
3
+ // table without importing appConfig's UI components.
4
+ export const scaleFactor = {
5
+ small: 1,
6
+ medium: 1.5,
7
+ large: 2
8
+ }
@@ -6,27 +6,64 @@
6
6
  */
7
7
  export const symbolDefaults = {
8
8
  symbol: 'pin',
9
+ size: 'medium',
9
10
  backgroundColor: '#ca3535',
10
11
  foregroundColor: '#ffffff'
11
12
  }
12
13
 
14
+ /** The symbol style keys a dataset or draw style can set (see docs/plugins/datasets.md) */
15
+ export const SYMBOL_STYLE_KEYS = [
16
+ 'symbol', 'symbolSvgContent', 'symbolViewBox', 'symbolAnchor', 'symbolSize',
17
+ 'symbolBackgroundColor', 'symbolForegroundColor', 'symbolHaloWidth', 'symbolGraphic'
18
+ ]
19
+
20
+ /**
21
+ * Scale factor for each symbol size (`size` on markers, `symbolSize` on dataset and draw styles).
22
+ * Scales a symbol's shape and graphic; the halo and the selected/active rings stay a fixed width at
23
+ * every size (see getSymbolScale in symbolUtils.js).
24
+ */
25
+ export const SYMBOL_SIZES = {
26
+ small: 0.75, // NOSONAR
27
+ medium: 1,
28
+ large: 1.25 // NOSONAR
29
+ }
30
+
13
31
  /** Stroke width for the halo (background shape outline) in SVG units */
14
32
  export const HALO_STROKE_WIDTH = 2
15
33
 
16
34
  /** Stroke width for the selected state — symbol rings and feature highlight lines */
17
35
  export const SELECTED_STROKE_WIDTH = 3
18
36
 
37
+ // A stroke is centred on its path, so it reaches half its width either side
38
+ const BOTH_SIDES = 2
39
+
19
40
  /** Stroke width for the active (keyboard cursor) state — double selected, extends 1× each side */
20
- export const ACTIVE_STROKE_WIDTH = SELECTED_STROKE_WIDTH * 2
41
+ export const ACTIVE_STROKE_WIDTH = SELECTED_STROKE_WIDTH * BOTH_SIDES
42
+
43
+ // Built-in symbols draw their halo and rings as strokes centred on the body outline, so each
44
+ // stroke is twice the distance its visible edge reaches beyond the body: halo 1, selected ring
45
+ // 1 + 3 = 4, active ring 4 + 3 = 7. A stroke is an exact offset, so rings stay even round corners.
46
+ export const SELECTED_RING_STROKE_WIDTH = HALO_STROKE_WIDTH + SELECTED_STROKE_WIDTH * BOTH_SIDES
47
+ export const ACTIVE_RING_STROKE_WIDTH = SELECTED_RING_STROKE_WIDTH + ACTIVE_STROKE_WIDTH
48
+
49
+ const CENTRE = 0.5
50
+
51
+ /** Anchor used when a symbol doesn't set one — its centre */
52
+ export const DEFAULT_SYMBOL_ANCHOR = [CENTRE, CENTRE]
53
+
54
+ /** View box used when a custom SVG symbol doesn't set one */
55
+ export const DEFAULT_SYMBOL_VIEWBOX = '0 0 44 44'
56
+
57
+ /** Space around a built-in symbol's body: its outermost (active) ring plus 1px clearance */
58
+ export const SYMBOL_PADDING = ACTIVE_RING_STROKE_WIDTH / BOTH_SIDES + 1
21
59
 
22
60
  /**
23
61
  * Built-in graphic path data strings for use with the `graphic` token.
24
62
  *
25
63
  * Each value is an SVG `d` attribute string in a 16×16 coordinate space,
26
- * centred at (8, 8). The built-in symbols (`pin`, `circle`, `square`) apply a
27
- * `translate` transform to position this 16×16 area correctly within their
28
- * 38×38 viewBox — so graphic path data does not need to account for symbol
29
- * positioning.
64
+ * centred at (8, 8). The built-in symbols (`pin`, `circle`, `square`, `hexagon`, `triangle`, `diamond`)
65
+ * centre this 16×16 area on their `graphicCentre` at 0.8 scale — so graphic path data does not
66
+ * need to account for symbol positioning or size.
30
67
  *
31
68
  * @example
32
69
  * markers.add('id', coords, { symbol: 'pin', graphic: graphics.dot })
@@ -53,35 +90,74 @@ export const graphics = {
53
90
  }
54
91
 
55
92
  // ─── Built-in symbol definitions ─────────────────────────────────────────────
56
- // Each symbol uses a 44×44 viewBox. SVG templates use {{token}} placeholders
57
- // resolved at render time by the symbolRegistry.
93
+ // Each is a single body `path` in its own coordinates, with:
94
+ // bounds [x, y, width, height] — the body path's tight bounding box
95
+ // anchorPoint [x, y] — the point that sits on the map coordinate
96
+ // graphicCentre [x, y] — where the 16×16 graphic is centred (drawn at 0.8 scale)
97
+ // symbolRegistry composes the rendered SVG, viewBox and fractional anchor from these for each
98
+ // size: the body and graphic scale, the halo and rings don't.
58
99
 
100
+ // Circle-headed pin, head r=13. The anchor is the halo's tip, 1 below the body's.
59
101
  export const pin = {
60
102
  id: 'pin',
61
- viewBox: '0 0 44 44',
62
- anchor: [0.5, 0.9], // NOSONAR
63
- graphic: graphics.dot,
64
- svg: `<path d="M22 40.999c-3.621 0-8.306-5.864-10.258-8.3C9.02 29.302 6 23.66 6 19.002a16.01 16.01 0 0 1 16-16 16.01 16.01 0 0 1 16 16c0 4.658-3.02 10.3-5.742 13.697-1.952 2.437-6.637 8.3-10.258 8.3z" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>
65
- <path d="M22 7.001a12.01 12.01 0 0 1 12 12c0 7.623-10.377 17.998-12 17.998S10 26.624 10 19.001a12.01 12.01 0 0 1 12-12z" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>
66
- <g transform="translate(22, 19) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>`
103
+ path: 'M22 7a13 13 0 0 1 13 13C35 28.258 23.758 39.499 22 39.499S9 28.259 9 20.001a13 13 0 0 1 13-13z',
104
+ bounds: [9, 7, 26, 32.499], // NOSONAR
105
+ anchorPoint: [22, 40.5], // NOSONAR
106
+ graphicCentre: [22, 20], // NOSONAR
107
+ graphic: graphics.dot
67
108
  }
68
109
 
110
+ // r=13 — the reference size the other shapes' areas are compared against.
69
111
  export const circle = {
70
112
  id: 'circle',
71
- viewBox: '0 0 44 44',
72
- anchor: [0.5, 0.5],
73
- graphic: graphics.dot,
74
- svg: `<circle cx="22" cy="22" r="16" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>
75
- <circle cx="22" cy="22" r="12" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>
76
- <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>`
113
+ path: 'M22 9a13 13 0 1 1 0 26 13 13 0 1 1 0-26z',
114
+ bounds: [9, 9, 26, 26], // NOSONAR
115
+ anchorPoint: [22, 22], // NOSONAR
116
+ graphicCentre: [22, 22], // NOSONAR
117
+ graphic: graphics.dot
77
118
  }
78
119
 
120
+ // 23.6 body with 3px corner radii — ~103% of circle's area, Material's square-to-circle keyline
121
+ // ratio (18×18 square vs 20 circle).
79
122
  export const square = {
80
123
  id: 'square',
81
- viewBox: '0 0 44 44',
82
- anchor: [0.5, 0.5],
83
- graphic: graphics.dot,
84
- svg: `<path d="M13 6h18c3.863 0 7 3.137 7 7v18c0 3.863-3.137 7-7 7H13c-3.863 0-7-3.137-7-7V13c0-3.863 3.137-7 7-7" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>
85
- <path d="M13 34a3 3 0 0 1-3-3V13a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v18a3 3 0 0 1-3 3H13z" fill-rule="nonzero" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>
86
- <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>`
124
+ path: 'M13.2 33.8a3 3 0 0 1-3-3V13.2a3 3 0 0 1 3-3h17.6a3 3 0 0 1 3 3v17.6a3 3 0 0 1-3 3H13.2z',
125
+ bounds: [10.2, 10.2, 23.6, 23.6], // NOSONAR
126
+ anchorPoint: [22, 22], // NOSONAR
127
+ graphicCentre: [22, 22], // NOSONAR
128
+ graphic: graphics.dot
129
+ }
130
+
131
+ // Pointy-top hexagon, flat sides 12.6 from the centre, 3px corner radii — ~103% of circle's
132
+ // area, between circle and square (cornered shapes need slightly more area than a circle to
133
+ // read as the same size).
134
+ export const hexagon = {
135
+ id: 'hexagon',
136
+ path: 'M23.5 8.317L33.1 13.859A3 3 0 0 1 34.6 16.457L34.6 27.543A3 3 0 0 1 33.1 30.141L23.5 35.683A3 3 0 0 1 20.5 35.683L10.9 30.141A3 3 0 0 1 9.4 27.543L9.4 16.457A3 3 0 0 1 10.9 13.859L20.5 8.317A3 3 0 0 1 23.5 8.317z',
137
+ bounds: [9.4, 7.915, 25.2, 28.17], // NOSONAR
138
+ anchorPoint: [22, 22], // NOSONAR
139
+ graphicCentre: [22, 22], // NOSONAR
140
+ graphic: graphics.dot
141
+ }
142
+
143
+ // Point-up equilateral triangle, edges 10.4 from the centroid, 3px corner radii — ~102% of
144
+ // circle's area. Anchored at the centroid; the graphic sits 0.5 below it.
145
+ export const triangle = {
146
+ id: 'triangle',
147
+ path: 'M25.598 9.7L38.415 31.9A3 3 0 0 1 35.817 36.4L10.183 36.4A3 3 0 0 1 7.585 31.9L20.402 9.7A3 3 0 0 1 25.598 9.7z',
148
+ bounds: [7.183, 8.2, 31.634, 28.2], // NOSONAR
149
+ anchorPoint: [23, 26], // NOSONAR
150
+ graphicCentre: [23, 26.5], // NOSONAR
151
+ graphic: graphics.dot
152
+ }
153
+
154
+ // A square rotated 45°, edges 11.6 from the centre, 3px corner radii — the same area as circle
155
+ // (less than square's, since its points reach further and make it read larger).
156
+ export const diamond = {
157
+ id: 'diamond',
158
+ path: 'M25.121 8.716L37.284 20.879A3 3 0 0 1 37.284 25.121L25.121 37.284A3 3 0 0 1 20.879 37.284L8.716 25.121A3 3 0 0 1 8.716 20.879L20.879 8.716A3 3 0 0 1 25.121 8.716z',
159
+ bounds: [7.838, 7.838, 30.325, 30.325], // NOSONAR
160
+ anchorPoint: [23, 23], // NOSONAR
161
+ graphicCentre: [23, 23], // NOSONAR
162
+ graphic: graphics.dot
87
163
  }
@@ -1,56 +1,21 @@
1
1
  import { BUILT_IN_PATTERNS } from '../config/patternConfig.js'
2
2
  import { getValueForStyle } from '../utils/getValueForStyle.js'
3
- import { KEY_BORDER_PATH, getEffectivePixelRatio, injectColors, hashString } from '../utils/patternUtils.js'
3
+ import { KEY_BORDER_PATH, getEffectivePixelRatio, injectColors } from '../utils/patternUtils.js'
4
4
  import { rasteriseToImageData } from '../utils/rasteriseToImageData.js'
5
- const patterns = new Map()
6
- // Module-level cache: imageId → ImageData. Avoids re-rasterising identical patterns.
7
- const imageDataCache = new Map()
5
+ import { hashString } from '../utils/hashString.js'
6
+ import { createImageDataCache } from '../utils/imageDataCache.js'
8
7
 
9
- export const patternRegistry = {
10
- /**
11
- * Register a named pattern.
12
- *
13
- * @param {string} id - Unique pattern name (e.g. 'my-hatch')
14
- * @param {string} svgContent - Inner SVG path content in a 16×16 coordinate space.
15
- * Use {{foregroundColor}} and {{backgroundColor}} tokens for colour injection.
16
- */
17
- register (id, svgContent) {
18
- patterns.set(id, { id, svgContent })
19
- },
20
-
21
- /**
22
- * Retrieve a registered pattern by name.
23
- *
24
- * @param {string} id
25
- * @returns {{ id: string, svgContent: string }|undefined}
26
- */
27
- get (id) {
28
- return patterns.get(id)
29
- },
30
-
31
- /**
32
- * Returns all registered patterns.
33
- *
34
- * @returns {{ id: string, svgContent: string }[]}
35
- */
36
- list () {
37
- return [...patterns.values()]
38
- },
39
-
40
- /**
41
- * Clears all registered patterns (including built-ins). Mainly for testing purposes.
42
- */
43
- clear () {
44
- patterns.clear()
45
- },
8
+ // Shared by every registry: imageId → ImageData. Every style or pixel-ratio change brings new
9
+ // ids, so it's bounded.
10
+ const IMAGE_DATA_CACHE_SIZE = 128
11
+ const imageDataCache = createImageDataCache(IMAGE_DATA_CACHE_SIZE)
46
12
 
47
- initialise () {
48
- // Seed built-in patterns
49
- Object.entries(BUILT_IN_PATTERNS).forEach(([id, svgContent]) => {
50
- this.register(id, svgContent)
51
- })
52
- },
13
+ const PATTERN_VIEWBOX_SIZE = 16 // patterns are authored in a 16×16 space...
14
+ const PATTERN_TILE_SIZE = 8 // ...and tiled at 8 CSS pixels
53
15
 
16
+ // Colouring, image ids and rasterising. They read the registry only through `this` (its
17
+ // registered patterns), so every registry shares them.
18
+ const patternImageMethods = {
54
19
  /**
55
20
  * Returns the raw (un-coloured) inner SVG content for a style's pattern.
56
21
  * Precedence: inline fillPatternSvgContent → named fillPattern from registry.
@@ -69,14 +34,14 @@ export const patternRegistry = {
69
34
  },
70
35
 
71
36
  /**
72
- * Returns colour-injected SVG path content for use in Key panel pattern symbols.
73
- * Returns { border, content } where border is the rounded-rect outline and content
74
- * is the pattern fill. Returns null if the style has no pattern.
75
- *
76
- * @param {Object} style
77
- * @param {string} mapStyleId
78
- * @returns {{ border: string, content: string }|null}
79
- */
37
+ * Returns colour-injected SVG path content for use in Key panel pattern symbols.
38
+ * Returns { border, content } where border is the rounded-rect outline and content
39
+ * is the pattern fill. Returns null if the style has no pattern.
40
+ *
41
+ * @param {Object} style
42
+ * @param {string} mapStyleId
43
+ * @returns {{ border: string, content: string }|null}
44
+ */
80
45
  getKeyPatternPaths (style, mapStyleId) {
81
46
  const innerContent = this.getPatternInnerContent(style)
82
47
  if (!innerContent) {
@@ -93,14 +58,14 @@ export const patternRegistry = {
93
58
  },
94
59
 
95
60
  /**
96
- * Returns a deterministic image ID for a pattern + resolved colour + pixel ratio combination.
97
- *
98
- * @param {Object} dataset
99
- * @param {string} mapStyleId
100
- * @param {number} [pixelRatio=1]
101
- * @returns {string|null}
102
- */
103
- getPatternImageId (dataset, mapStyleId, pixelRatio = 1) {
61
+ * Returns a deterministic image ID for a pattern + resolved colour + pixel ratio combination.
62
+ *
63
+ * @param {Object} dataset
64
+ * @param {string} mapStyleId
65
+ * @param {number} pixelRatio - Device pixel ratio × map size scale factor
66
+ * @returns {string|null}
67
+ */
68
+ getPatternImageId (dataset, mapStyleId, pixelRatio) {
104
69
  const innerContent = this.getPatternInnerContent(dataset)
105
70
  if (!innerContent) {
106
71
  return null
@@ -112,17 +77,14 @@ export const patternRegistry = {
112
77
  },
113
78
 
114
79
  /**
115
- * Rasterise a pattern to ImageData, cached by imageId — shared by MapLibre's map.addImage()
116
- * and OpenLayers' CanvasPattern (canvasPatternStyle.js). Note: the two currently render the
117
- * pattern tile at different on-screen sizes (8px vs 16px CSS) — not yet confirmed if that
118
- * needs aligning.
80
+ * Rasterise a pattern to ImageData, cached by imageId, for a map provider to register.
119
81
  *
120
82
  * @param {Object} style - Dataset or marker config with fillPattern* properties
121
83
  * @param {string} mapStyleId - Current style/theme identifier
122
- * @param {number} [pixelRatio=1] - Device pixel ratio × map size scale factor
84
+ * @param {number} pixelRatio - Device pixel ratio × map size scale factor
123
85
  * @returns {Promise<{imageId: string, imageData: ImageData}|null>}
124
86
  */
125
- async rasterisePatternImage (style, mapStyleId, pixelRatio = 1) {
87
+ async rasterisePatternImage (style, mapStyleId, pixelRatio) {
126
88
  const innerContent = this.getPatternInnerContent(style)
127
89
  if (!innerContent) {
128
90
  return null
@@ -136,15 +98,74 @@ export const patternRegistry = {
136
98
  const fg = getValueForStyle(style.fillPatternForegroundColor, mapStyleId) || 'black'
137
99
  const bg = getValueForStyle(style.fillPatternBackgroundColor, mapStyleId) || 'transparent'
138
100
  const colored = injectColors(innerContent, fg, bg)
139
- const bgRect = `<rect width="16" height="16" fill="${bg}"/>`
140
- const effectiveRatio = getEffectivePixelRatio(pixelRatio)
141
- const physicalSize = Math.round(8 * effectiveRatio)
142
- const svgString = `<svg xmlns="http://www.w3.org/2000/svg" width="${physicalSize}" height="${physicalSize}" viewBox="0 0 16 16">${bgRect}${colored}</svg>`
143
- imageData = await rasteriseToImageData(svgString, physicalSize, physicalSize)
144
- imageDataCache.set(imageId, imageData)
101
+ const bgRect = `<rect width="${PATTERN_VIEWBOX_SIZE}" height="${PATTERN_VIEWBOX_SIZE}" fill="${bg}"/>`
102
+ const physicalSize = Math.round(PATTERN_TILE_SIZE * getEffectivePixelRatio(pixelRatio))
103
+ const svgString = `<svg xmlns="http://www.w3.org/2000/svg" width="${physicalSize}" height="${physicalSize}" viewBox="0 0 ${PATTERN_VIEWBOX_SIZE} ${PATTERN_VIEWBOX_SIZE}">${bgRect}${colored}</svg>`
104
+ imageData = await imageDataCache.rasteriseOnce(imageId, () => rasteriseToImageData(svgString, physicalSize, physicalSize))
145
105
  }
146
106
  return { imageId, imageData }
147
107
  }
148
108
  }
149
109
 
150
- patternRegistry.initialise() // Seed built-in patterns
110
+ /**
111
+ * Creates a pattern registry: the built-in fill patterns plus any registered custom ones. Each
112
+ * map instance has its own, so maps on the same page can register different patterns.
113
+ *
114
+ * @returns {Object} the registry
115
+ */
116
+ export const createPatternRegistry = () => {
117
+ const patterns = new Map()
118
+
119
+ const registry = {
120
+ /**
121
+ * Register a named pattern.
122
+ *
123
+ * @param {string} id - Unique pattern name (e.g. 'my-hatch')
124
+ * @param {string} svgContent - Inner SVG path content in a 16×16 coordinate space.
125
+ * Use {{foregroundColor}} and {{backgroundColor}} tokens for colour injection.
126
+ */
127
+ register (id, svgContent) {
128
+ patterns.set(id, { id, svgContent })
129
+ },
130
+
131
+ /**
132
+ * Retrieve a registered pattern by name.
133
+ *
134
+ * @param {string} id
135
+ * @returns {{ id: string, svgContent: string }|undefined}
136
+ */
137
+ get (id) {
138
+ return patterns.get(id)
139
+ },
140
+
141
+ /**
142
+ * Returns all registered patterns.
143
+ *
144
+ * @returns {{ id: string, svgContent: string }[]}
145
+ */
146
+ list () {
147
+ return [...patterns.values()]
148
+ },
149
+
150
+ /**
151
+ * Clears all registered patterns (including built-ins). Mainly for testing purposes.
152
+ */
153
+ clear () {
154
+ patterns.clear()
155
+ },
156
+
157
+ /**
158
+ * Registers the built-in patterns. Called when the registry is created.
159
+ */
160
+ initialise () {
161
+ Object.entries(BUILT_IN_PATTERNS).forEach(([id, svgContent]) => {
162
+ this.register(id, svgContent)
163
+ })
164
+ },
165
+
166
+ ...patternImageMethods
167
+ }
168
+
169
+ registry.initialise()
170
+ return registry
171
+ }
@@ -1,6 +1,8 @@
1
- import { patternRegistry } from './patternRegistry.js'
1
+ import { createPatternRegistry } from './patternRegistry.js'
2
2
  import { KEY_BORDER_PATH } from '../utils/patternUtils.js'
3
3
 
4
+ const patternRegistry = createPatternRegistry()
5
+
4
6
  beforeAll(() => {
5
7
  globalThis.Image = class {
6
8
  constructor (w, h) {
@@ -19,6 +21,22 @@ beforeAll(() => {
19
21
  }))
20
22
  })
21
23
 
24
+ describe('createPatternRegistry', () => {
25
+ it('gives each registry its own patterns, each starting with the built-ins', () => {
26
+ const first = createPatternRegistry()
27
+ const second = createPatternRegistry()
28
+ first.register('my-hatch', '<path d="M0 0 L16 16"/>')
29
+ expect(second.get('my-hatch')).toBeUndefined()
30
+ expect(second.list().map((pattern) => pattern.id)).toEqual(first.list().map((pattern) => pattern.id).filter((id) => id !== 'my-hatch'))
31
+ })
32
+
33
+ it('clear removes every pattern, built-ins included', () => {
34
+ const registry = createPatternRegistry()
35
+ registry.clear()
36
+ expect(registry.list()).toEqual([])
37
+ })
38
+ })
39
+
22
40
  describe('patternRegistry', () => {
23
41
  describe('built-in patterns', () => {
24
42
  test.each([