@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
@@ -1,7 +1,7 @@
1
1
  import { createOLDraw } from './olDraw.js'
2
2
  import { OLDrawManager } from './core/OLDrawManager.js'
3
3
  import { refreshAllPointSymbols } from './point/pointSymbolImages.js'
4
- import { MAP_SIZE_SCALES } from './defaults.js'
4
+ import { logger } from '../../../../../src/services/logger.js'
5
5
 
6
6
  jest.mock('./core/OLDrawManager.js', () => ({
7
7
  OLDrawManager: jest.fn(function () {
@@ -10,8 +10,10 @@ jest.mock('./core/OLDrawManager.js', () => ({
10
10
  })
11
11
  }))
12
12
  jest.mock('./point/pointSymbolImages.js', () => ({ refreshAllPointSymbols: jest.fn(() => Promise.resolve()) }))
13
+ jest.mock('../../../../../src/services/logger.js', () => ({ logger: { error: jest.fn() } }))
13
14
 
14
- const events = { MAP_SET_SIZE: 'app:size', MAP_SET_STYLE: 'app:style', MAP_DATA_CHANGE: 'app:datachange' }
15
+ const symbolRegistry = { id: 'app-symbol-registry' }
16
+ const events = { MAP_SET_PIXEL_RATIO: 'app:pixelratio', MAP_SET_STYLE: 'app:style', MAP_DATA_CHANGE: 'app:datachange' }
15
17
 
16
18
  const setup = (mapStyle = null) => {
17
19
  const listeners = {}
@@ -21,7 +23,7 @@ const setup = (mapStyle = null) => {
21
23
  emit: jest.fn((type, payload) => listeners[type]?.(payload))
22
24
  }
23
25
  const mapProvider = { map: { id: 'ol-map' } }
24
- const olDraw = createOLDraw({ mapProvider, events, eventBus, pluginConfig: { snapRadius: 5 }, mapStyle })
26
+ const olDraw = createOLDraw({ mapProvider, symbolRegistry, events, eventBus, pluginConfig: { snapRadius: 5 }, mapStyle })
25
27
  const manager = OLDrawManager.mock.instances.at(-1)
26
28
  return { eventBus, mapProvider, olDraw, manager }
27
29
  }
@@ -30,38 +32,21 @@ afterEach(() => jest.clearAllMocks())
30
32
 
31
33
  test('creates the manager for the map, exposes it as mapProvider.draw and applies an initial style', () => {
32
34
  const { mapProvider, manager } = setup({ id: 'dark' })
33
- expect(OLDrawManager).toHaveBeenCalledWith(mapProvider.map, { snapRadius: 5 })
35
+ // the provider and the app's registry, for resolving drawn points' symbols
36
+ expect(OLDrawManager).toHaveBeenCalledWith(mapProvider.map, { snapRadius: 5 }, { mapProvider, symbolRegistry })
34
37
  expect(mapProvider.draw).toBe(manager)
35
38
  expect(manager.setMapStyle).toHaveBeenCalledWith({ id: 'dark' })
36
39
 
37
40
  expect(setup().manager.setMapStyle).not.toHaveBeenCalled() // no initial style
38
41
  })
39
42
 
40
- // Regression: MAP_SET_SIZE only ever fires from the map-size UI control being clicked at
41
- // runtime, so a map that loads directly at medium/large left drawScale unset (defaulting to 1,
42
- // i.e. small) until the user happened to change size — rasterising the first symbol placed at
43
- // the wrong resolution. mapProvider.mapSize already holds the size the map actually loaded at.
44
- test('seeds drawScale from the provider\'s own starting map size, before any size-change event', () => {
45
- const eventBus = { on: jest.fn(), off: jest.fn() }
46
- const mapProvider = { map: { id: 'ol-map' }, mapSize: 'large' }
47
- createOLDraw({ mapProvider, events, eventBus })
48
- expect(mapProvider.drawScale).toBe(MAP_SIZE_SCALES.large)
49
- })
50
-
51
- test('defaults the seeded drawScale to 1 when the provider has no starting map size', () => {
52
- const eventBus = { on: jest.fn(), off: jest.fn() }
53
- const mapProvider = { map: { id: 'ol-map' } }
54
- createOLDraw({ mapProvider, events, eventBus })
55
- expect(mapProvider.drawScale).toBe(1)
56
- })
57
-
58
- test('map size changes update the draw UI scale, defaulting to 1 for unknown sizes, and re-resolve point symbols', async () => {
43
+ // Point symbols are rasterised at the map's own pixelRatio (see point/pointSymbolImages.js's
44
+ // getPixelRatio), which the map is created with — so a map that loads straight at medium/large
45
+ // is already right. A runtime map-size change sets a new ratio, which re-resolves them.
46
+ test('pixel ratio changes re-resolve point symbols at the new ratio carried by the event', () => {
59
47
  const { eventBus, mapProvider, manager } = setup()
60
- eventBus.emit(events.MAP_SET_SIZE, 'large')
61
- expect(mapProvider.drawScale).toBe(MAP_SIZE_SCALES.large)
62
- expect(refreshAllPointSymbols).toHaveBeenCalledWith({ manager, mapProvider })
63
- eventBus.emit(events.MAP_SET_SIZE, 'enormous')
64
- expect(mapProvider.drawScale).toBe(1)
48
+ eventBus.emit(events.MAP_SET_PIXEL_RATIO, 3)
49
+ expect(refreshAllPointSymbols).toHaveBeenCalledWith({ manager, mapProvider, pixelRatioOverride: 3 })
65
50
  })
66
51
 
67
52
  // A selected point's highlight overlay only re-applies on MAP_DATA_CHANGE, and (unlike
@@ -71,18 +56,28 @@ test('map size changes update the draw UI scale, defaulting to 1 for unknown siz
71
56
  // already-selected point's ring stuck on its old (now wrong-resolution) icon.
72
57
  test('emits MAP_DATA_CHANGE once point symbols have actually finished re-resolving after a size change', async () => {
73
58
  const { eventBus, manager, mapProvider } = setup()
74
- eventBus.emit(events.MAP_SET_SIZE, 'large')
59
+ eventBus.emit(events.MAP_SET_PIXEL_RATIO, 4)
75
60
  await Promise.resolve() // flush the refreshAllPointSymbols().then(...) microtask
76
- expect(refreshAllPointSymbols).toHaveBeenCalledWith({ manager, mapProvider })
61
+ expect(refreshAllPointSymbols).toHaveBeenCalledWith({ manager, mapProvider, pixelRatioOverride: 4 })
77
62
  expect(eventBus.emit).toHaveBeenCalledWith(events.MAP_DATA_CHANGE)
78
63
  })
79
64
 
65
+ test('logs, rather than leaving unhandled, a failure to refresh point symbols', async () => {
66
+ const { eventBus } = setup()
67
+ const failure = new Error('rasterise failed')
68
+ refreshAllPointSymbols.mockReturnValueOnce(Promise.reject(failure))
69
+ eventBus.emit(events.MAP_SET_PIXEL_RATIO, 2)
70
+ await new Promise((resolve) => setTimeout(resolve, 0))
71
+ expect(logger.error).toHaveBeenCalledWith('[draw] failed to refresh point symbols', failure)
72
+ expect(eventBus.emit).not.toHaveBeenCalledWith(events.MAP_DATA_CHANGE)
73
+ })
74
+
80
75
  test('pluginConfig and mapStyle are optional, defaulting to {} and no initial style', () => {
81
76
  const eventBus = { on: jest.fn(), off: jest.fn() }
82
77
  const mapProvider = { map: { id: 'ol-map' } }
83
78
  const olDraw = createOLDraw({ mapProvider, events, eventBus }) // no pluginConfig, no mapStyle
84
79
  const manager = OLDrawManager.mock.instances.at(-1)
85
- expect(OLDrawManager).toHaveBeenCalledWith(mapProvider.map, {})
80
+ expect(OLDrawManager).toHaveBeenCalledWith(mapProvider.map, {}, { mapProvider, symbolRegistry: undefined })
86
81
  expect(manager.setMapStyle).not.toHaveBeenCalled()
87
82
  expect(mapProvider.draw).toBe(manager)
88
83
  olDraw.remove()
@@ -105,7 +100,7 @@ test('emits MAP_DATA_CHANGE once point symbols have actually finished re-resolvi
105
100
  test('remove unsubscribes, destroys the manager and clears mapProvider.draw', () => {
106
101
  const { eventBus, mapProvider, olDraw, manager } = setup()
107
102
  olDraw.remove()
108
- expect(eventBus.off).toHaveBeenCalledWith(events.MAP_SET_SIZE, expect.any(Function))
103
+ expect(eventBus.off).toHaveBeenCalledWith(events.MAP_SET_PIXEL_RATIO, expect.any(Function))
109
104
  expect(eventBus.off).toHaveBeenCalledWith(events.MAP_SET_STYLE, expect.any(Function))
110
105
  expect(manager.remove).toHaveBeenCalled()
111
106
  expect(mapProvider.draw).toBeNull()
@@ -1,69 +1,59 @@
1
- import { symbolRegistry } from '../../../../../../src/services/symbolRegistry.js'
2
- import { getOrCreateSymbolImage } from '../../../../../../providers/beta/openlayers/src/utils/symbolImages.js'
1
+ import { hasSymbol } from '../../../../../../src/utils/symbolUtils.js'
3
2
 
4
3
  /**
5
- * Resolves a drawn point's symbol-config icon and writes the resolved image id back onto the
6
- * OL feature, so core/styles.js's createFeatureStyle() can render it via an ol/style/Icon.
7
- * Also resolves and caches the 'active'/'selected' variants as symbolActiveImageId/
8
- * symbolSelectedImageId, read directly by highlightFeatures.js's selection overlay.
4
+ * Resolves a drawn point's symbol-config icon: registers its images with the OL provider (as
5
+ * the MapLibre adapter does with its own provider), then writes the resolved image ids — normal,
6
+ * active and selected — plus the anchor and pixel ratio they were drawn at back onto the OL
7
+ * feature. core/styles.js renders the icon from these, and the provider's highlightFeatures.js
8
+ * the selection ring.
9
9
  */
10
10
 
11
- const VARIANTS = ['normal', 'active', 'selected']
12
- const PROPERTY_FOR_VARIANT = { normal: 'symbolImageId', active: 'symbolActiveImageId', selected: 'symbolSelectedImageId' }
13
-
14
- export const hasSymbolStyle = (properties) => !!(properties?.symbol || properties?.symbolSvgContent)
15
-
16
- // Combines the browser's native devicePixelRatio with this app's own map-size scale factor
17
- // (mapProvider.drawScale), matching MapController.jsx's construction-time formula.
18
- export const getPixelRatio = (mapProvider) => (globalThis.devicePixelRatio || 1) * (mapProvider?.drawScale ?? 1)
11
+ // The map's own pixelRatio (device pixel ratio × map-size scale factor) — the same source the
12
+ // datasets plugin rasterises its OL symbols at, so both draw them 1:1.
13
+ export const getPixelRatio = (mapProvider) => mapProvider?.map?.getPixelRatio?.() || 1
19
14
 
20
15
  /**
21
16
  * Resolve one point feature's symbol image and write it back onto the feature.
22
17
  * A no-op for points with no symbol config (nothing to render as an icon).
23
18
  *
24
19
  * @param {Object} params
25
- * @param {Object} params.manager - OLDrawManager (needs store.source, mapStyle)
26
- * @param {Object} params.mapProvider
20
+ * @param {Object} params.manager - OLDrawManager (needs store.source, mapStyle, symbolRegistry)
21
+ * @param {Object} params.mapProvider - OpenLayersProvider (needs addSymbolsToMap and the
22
+ * active/selected image id lookups)
27
23
  * @param {import('ol/Feature.js').default} params.olFeature
28
- * @returns {Promise<void>}
24
+ * @param {number} [params.pixelRatioOverride] - use this instead of the map's pixelRatio, for
25
+ * callers (MAP_SET_PIXEL_RATIO) that already have the freshly set value
26
+ * @param {number} [params.refreshId] - set by refreshAllPointSymbols; the result is dropped if a
27
+ * newer refresh has started since
28
+ * @returns {Promise<void>} rejects if the symbol's images couldn't be registered
29
29
  */
30
- export const resolvePointSymbol = async ({ manager, mapProvider, olFeature }) => {
30
+ export const resolvePointSymbol = async ({ manager, mapProvider, olFeature, pixelRatioOverride, refreshId }) => {
31
31
  const properties = olFeature.getProperties()
32
- if (!hasSymbolStyle(properties)) {
32
+ if (!hasSymbol(properties)) {
33
33
  return
34
34
  }
35
35
 
36
- const pixelRatio = getPixelRatio(mapProvider)
36
+ const { symbolRegistry, mapStyle } = manager
37
+ const pixelRatio = pixelRatioOverride ?? getPixelRatio(mapProvider)
37
38
 
38
- try {
39
- const results = await Promise.all(
40
- VARIANTS.map((variant) => symbolRegistry.rasteriseSymbolImage(properties, manager.mapStyle, variant, pixelRatio))
41
- )
42
- // All three variants resolve from the same symbol config, so either all succeed or (an
43
- // unresolvable symbol id) all fail together — gating on 'normal' alone is enough.
44
- if (!results[0]) {
45
- return
46
- }
47
-
48
- // The feature may have been deleted/cancelled while rasterising was in flight.
49
- if (!manager.store.source.hasFeature(olFeature)) {
50
- return
51
- }
52
- VARIANTS.forEach((variant, i) => {
53
- const result = results[i]
54
- if (!result) { return }
55
- getOrCreateSymbolImage(result.imageId, result.imageData)
56
- olFeature.set(PROPERTY_FOR_VARIANT[variant], result.imageId)
57
- })
39
+ await mapProvider.addSymbolsToMap([properties], mapStyle, symbolRegistry, pixelRatio)
40
+ const symbolImageId = symbolRegistry.getSymbolImageId(properties, mapStyle, 'normal', pixelRatio)
41
+ // Unresolvable (e.g. an unknown symbol id), deleted/cancelled while registering, or
42
+ // superseded by a newer refresh (another size or style change)
43
+ if (!symbolImageId || !manager.store.source.hasFeature(olFeature) || (refreshId !== undefined && refreshId !== manager.pointSymbolRefreshId)) {
44
+ return
45
+ }
46
+ // One write, so the feature changes (and re-renders) once
47
+ olFeature.setProperties({
48
+ symbolImageId,
49
+ symbolActiveImageId: mapProvider.getActiveSymbolImageId(symbolImageId),
50
+ symbolSelectedImageId: mapProvider.getSelectedSymbolImageId(symbolImageId),
51
+ symbolImageAnchor: symbolRegistry.getSymbolDef(properties).anchor,
58
52
  // ol/style/Icon draws its source canvas at native pixel size — core/styles.js reads this
59
53
  // back to apply `scale: 1 / symbolPixelRatio`, correcting for the canvas being rasterised
60
54
  // at pixelRatio device pixels for crispness.
61
- olFeature.set('symbolPixelRatio', pixelRatio)
62
- } catch (err) {
63
- // A silent failure here means a point simply never gets/keeps an icon, with nothing in
64
- // the UI to explain why — surface it instead of letting the rejection vanish.
65
- console.error('[draw] failed to resolve point symbol', olFeature.getId(), err) // NOSONAR
66
- }
55
+ symbolPixelRatio: pixelRatio
56
+ })
67
57
  }
68
58
 
69
59
  /**
@@ -73,11 +63,16 @@ export const resolvePointSymbol = async ({ manager, mapProvider, olFeature }) =>
73
63
  * @param {Object} params
74
64
  * @param {Object} params.manager
75
65
  * @param {Object} params.mapProvider
66
+ * @param {number} [params.pixelRatioOverride] - see resolvePointSymbol
76
67
  * @returns {Promise<void>}
77
68
  */
78
- export const refreshAllPointSymbols = ({ manager, mapProvider }) => {
69
+ export const refreshAllPointSymbols = ({ manager, mapProvider, pixelRatioOverride }) => {
70
+ // Refreshes overlap when the map size or style changes again before one finishes; only the
71
+ // latest may write back, so an older one finishing last can't restore its stale images
72
+ manager.pointSymbolRefreshId = (manager.pointSymbolRefreshId ?? 0) + 1
73
+ const refreshId = manager.pointSymbolRefreshId
79
74
  const points = manager.store.source.getFeatures().filter(
80
- (f) => f.getGeometry()?.getType() === 'Point' && hasSymbolStyle(f.getProperties())
75
+ (feature) => feature.getGeometry()?.getType() === 'Point' && hasSymbol(feature.getProperties())
81
76
  )
82
- return Promise.all(points.map((olFeature) => resolvePointSymbol({ manager, mapProvider, olFeature })))
77
+ return Promise.all(points.map((olFeature) => resolvePointSymbol({ manager, mapProvider, olFeature, pixelRatioOverride, refreshId })))
83
78
  }
@@ -1,23 +1,36 @@
1
- import { hasSymbolStyle, getPixelRatio, resolvePointSymbol, refreshAllPointSymbols } from './pointSymbolImages.js'
2
- import { symbolRegistry } from '../../../../../../src/services/symbolRegistry.js'
3
- import { getCachedSymbolImage, clearSymbolImageCache } from '../../../../../../providers/beta/openlayers/src/utils/symbolImages.js'
1
+ import { getPixelRatio, resolvePointSymbol, refreshAllPointSymbols } from './pointSymbolImages.js'
2
+ import { createSymbolRegistry } from '../../../../../../src/services/symbolRegistry.js'
3
+ import { SymbolImageCache } from '../../../../../../providers/beta/openlayers/src/utils/symbolImages.js'
4
+
5
+ const symbolRegistry = createSymbolRegistry()
4
6
 
5
7
  const mapStyle = { id: 'outdoor', mapColorScheme: 'light' }
6
8
 
7
- const createMapProvider = ({ drawScale = 1 } = {}) => ({ drawScale })
9
+ // The OL provider's symbol image methods, backed by a real cache
10
+ const createMapProvider = ({ pixelRatio = 1 } = {}) => {
11
+ const symbolImages = new SymbolImageCache()
12
+ return {
13
+ map: { getPixelRatio: () => pixelRatio },
14
+ symbolImages,
15
+ addSymbolsToMap: jest.fn((configs, ms, registry, ratio) => symbolImages.registerSymbols(configs, ms, registry, ratio)),
16
+ getActiveSymbolImageId: (imageId) => symbolImages.getActiveImageId(imageId),
17
+ getSelectedSymbolImageId: (imageId) => symbolImages.getSelectedImageId(imageId)
18
+ }
19
+ }
8
20
 
9
- // A minimal ol.Feature stand-in — resolvePointSymbol only ever calls
10
- // getProperties()/set() on it, and manager.store.source.hasFeature() to check liveness.
21
+ // A minimal ol.Feature stand-in — resolvePointSymbol only ever calls getProperties()/
22
+ // setProperties() on it, and manager.store.source.hasFeature() to check liveness.
11
23
  const createOlFeature = (properties) => {
12
24
  const props = { ...properties }
13
25
  return {
14
26
  getProperties: () => props,
15
- set: jest.fn((key, value) => { props[key] = value })
27
+ setProperties: jest.fn((values) => { Object.assign(props, values) })
16
28
  }
17
29
  }
18
30
 
19
31
  const createManager = ({ features = [] } = {}) => ({
20
32
  mapStyle,
33
+ symbolRegistry,
21
34
  store: {
22
35
  source: {
23
36
  hasFeature: jest.fn((f) => features.includes(f)),
@@ -27,162 +40,101 @@ const createManager = ({ features = [] } = {}) => ({
27
40
  })
28
41
 
29
42
  // symbolRegistry.rasteriseSymbolImage() draws an SVG through a real `new Image()`/onload
30
- // round-trip that jsdom never resolves — every other test file touching it (e.g. the
31
- // MapLibre adapter's pointSymbolImages.test.js) instead lets a mocked provider call
32
- // (addSymbolsToMap) stand in for it. This adapter calls rasteriseSymbolImage directly (it
33
- // *is* the last-mile pipeline, with no provider-level call to mock instead), so it's stubbed
34
- // here with a fake resolved ImageData keyed to the properties/pixelRatio, matching
35
- // getSymbolImageId's own id shape closely enough for assertions to key off it.
43
+ // round-trip that jsdom never resolves, so it's stubbed with a fake ImageData under the ids the
44
+ // real one would give.
36
45
  const stubRasterise = () => jest.spyOn(symbolRegistry, 'rasteriseSymbolImage')
37
- .mockImplementation(async (style, ms, variant, pixelRatio) => ({
38
- // variant folded into the id (mirroring the real act-/sel- prefixing) so normal/active/
39
- // selected resolve to distinct ids, the way real symbol configs do.
40
- imageId: `${variant}-${symbolRegistry.getSymbolImageId(style, ms, false, pixelRatio)}`,
41
- imageData: { width: 10, height: 10 }
42
- }))
46
+ .mockImplementation(async (style, ms, variant, pixelRatio) => {
47
+ const imageId = symbolRegistry.getSymbolImageId(style, ms, variant, pixelRatio)
48
+ return imageId ? { imageId, imageData: { width: 10, height: 10 } } : null
49
+ })
43
50
 
44
51
  beforeEach(() => {
45
- clearSymbolImageCache()
46
52
  HTMLCanvasElement.prototype.getContext = jest.fn(function () {
47
53
  this._ctx ??= { putImageData: jest.fn() }
48
54
  return this._ctx
49
55
  })
56
+ HTMLCanvasElement.prototype.toDataURL = jest.fn(() => 'data:image/png;base64,mock')
50
57
  stubRasterise()
51
58
  })
52
59
 
53
60
  afterEach(() => jest.restoreAllMocks())
54
61
 
55
- describe('hasSymbolStyle', () => {
56
- it('is true when symbol is set', () => {
57
- expect(hasSymbolStyle({ symbol: 'pin' })).toBe(true)
58
- })
59
-
60
- it('is true when symbolSvgContent is set', () => {
61
- expect(hasSymbolStyle({ symbolSvgContent: '<path/>' })).toBe(true)
62
- })
63
-
64
- it('is false with neither, or no properties at all', () => {
65
- expect(hasSymbolStyle({})).toBe(false)
66
- expect(hasSymbolStyle(undefined)).toBe(false)
67
- })
68
- })
69
-
70
62
  describe('getPixelRatio', () => {
71
- it('combines devicePixelRatio and mapProvider.drawScale', () => {
72
- const restore = globalThis.devicePixelRatio
73
- globalThis.devicePixelRatio = 2
74
- expect(getPixelRatio(createMapProvider({ drawScale: 1.5 }))).toBe(3)
75
- globalThis.devicePixelRatio = restore
63
+ it('reads the map\'s own pixelRatio (device pixel ratio × map-size scale)', () => {
64
+ expect(getPixelRatio(createMapProvider({ pixelRatio: 3 }))).toBe(3)
76
65
  })
77
66
 
78
- it('falls back to 1 for either factor when unset', () => {
79
- const restore = globalThis.devicePixelRatio
80
- delete globalThis.devicePixelRatio
81
- expect(getPixelRatio(createMapProvider({ drawScale: undefined }))).toBe(1)
67
+ it('falls back to 1 when there is no map or no ratio', () => {
82
68
  expect(getPixelRatio(undefined)).toBe(1)
83
- globalThis.devicePixelRatio = restore
69
+ expect(getPixelRatio({ map: {} })).toBe(1)
70
+ expect(getPixelRatio(createMapProvider({ pixelRatio: 0 }))).toBe(1)
84
71
  })
85
72
  })
86
73
 
87
74
  describe('resolvePointSymbol', () => {
88
75
  it('does nothing for a feature with no symbol config', async () => {
89
76
  const olFeature = createOlFeature({})
90
- const manager = createManager()
91
- await resolvePointSymbol({ manager, mapProvider: createMapProvider(), olFeature })
92
- expect(olFeature.set).not.toHaveBeenCalled()
93
- })
94
-
95
- it('rasterises, caches the canvas and writes symbolImageId/symbolPixelRatio back onto the feature', async () => {
96
- const properties = { symbol: 'pin' }
97
- const olFeature = createOlFeature(properties)
98
- const manager = createManager({ features: [olFeature] })
99
- const mapProvider = createMapProvider({ drawScale: 2 })
100
-
101
- await resolvePointSymbol({ manager, mapProvider, olFeature })
102
-
103
- const pixelRatio = getPixelRatio(mapProvider)
104
- const baseId = symbolRegistry.getSymbolImageId(properties, mapStyle, false, pixelRatio)
105
- expect(olFeature.set).toHaveBeenCalledWith('symbolImageId', `normal-${baseId}`)
106
- // symbolPixelRatio is what core/styles.js later uses to scale the (pixelRatio×-oversized)
107
- // cached canvas back down to its intended CSS display size.
108
- expect(olFeature.set).toHaveBeenCalledWith('symbolPixelRatio', pixelRatio)
109
- expect(getCachedSymbolImage(`normal-${baseId}`)).toBeInstanceOf(HTMLCanvasElement)
77
+ const mapProvider = createMapProvider()
78
+ await resolvePointSymbol({ manager: createManager(), mapProvider, olFeature })
79
+ expect(mapProvider.addSymbolsToMap).not.toHaveBeenCalled()
80
+ expect(olFeature.setProperties).not.toHaveBeenCalled()
110
81
  })
111
82
 
112
- it('also rasterises, caches and writes the active/selected variants — one image id each, keyed to the same symbol config', async () => {
83
+ it('registers the images with the provider at the map\'s pixel ratio, then writes every resolved property in one go', async () => {
113
84
  const properties = { symbol: 'pin' }
114
85
  const olFeature = createOlFeature(properties)
115
86
  const manager = createManager({ features: [olFeature] })
116
- const mapProvider = createMapProvider()
87
+ const mapProvider = createMapProvider({ pixelRatio: 2 })
117
88
 
118
89
  await resolvePointSymbol({ manager, mapProvider, olFeature })
119
90
 
120
- const pixelRatio = getPixelRatio(mapProvider)
121
- const baseId = symbolRegistry.getSymbolImageId(properties, mapStyle, false, pixelRatio)
122
- expect(olFeature.set).toHaveBeenCalledWith('symbolActiveImageId', `active-${baseId}`)
123
- expect(olFeature.set).toHaveBeenCalledWith('symbolSelectedImageId', `selected-${baseId}`)
124
- expect(getCachedSymbolImage(`active-${baseId}`)).toBeInstanceOf(HTMLCanvasElement)
125
- expect(getCachedSymbolImage(`selected-${baseId}`)).toBeInstanceOf(HTMLCanvasElement)
126
- // objectContaining, not the exact `properties` object — resolvePointSymbol's own
127
- // property-write calls mutate that same (by-reference) object in place afterwards, and
128
- // jest's mock.calls records the reference, not a snapshot at call time.
129
- const symbolMatch = expect.objectContaining({ symbol: 'pin' })
130
- expect(symbolRegistry.rasteriseSymbolImage).toHaveBeenCalledWith(symbolMatch, mapStyle, 'normal', pixelRatio)
131
- expect(symbolRegistry.rasteriseSymbolImage).toHaveBeenCalledWith(symbolMatch, mapStyle, 'active', pixelRatio)
132
- expect(symbolRegistry.rasteriseSymbolImage).toHaveBeenCalledWith(symbolMatch, mapStyle, 'selected', pixelRatio)
91
+ expect(mapProvider.addSymbolsToMap).toHaveBeenCalledWith([expect.objectContaining({ symbol: 'pin' })], mapStyle, symbolRegistry, 2)
92
+ const imageId = symbolRegistry.getSymbolImageId(properties, mapStyle, 'normal', 2)
93
+ expect(olFeature.setProperties).toHaveBeenCalledTimes(1)
94
+ expect(olFeature.setProperties).toHaveBeenCalledWith({
95
+ symbolImageId: imageId,
96
+ symbolActiveImageId: symbolRegistry.getSymbolImageId(properties, mapStyle, 'active', 2),
97
+ symbolSelectedImageId: symbolRegistry.getSymbolImageId(properties, mapStyle, 'selected', 2),
98
+ symbolImageAnchor: symbolRegistry.getSymbolDef(properties).anchor,
99
+ // core/styles.js scales the (pixelRatio×-oversized) canvas back down by this
100
+ symbolPixelRatio: 2
101
+ })
102
+ expect(mapProvider.symbolImages.getImage(imageId)).toBeInstanceOf(HTMLCanvasElement)
133
103
  })
134
104
 
135
- it('skips just the active/selected properties if only those variants resolve null (normal still succeeds)', async () => {
136
- const properties = { symbol: 'pin' }
105
+ it('resolves a symbolAnchor override to the shape, as the anchor every style uses', async () => {
106
+ const properties = { symbol: 'circle', symbolAnchor: [0.5, 1] }
137
107
  const olFeature = createOlFeature(properties)
138
- const manager = createManager({ features: [olFeature] })
139
- symbolRegistry.rasteriseSymbolImage
140
- .mockImplementationOnce(async (style, ms, variant, pixelRatio) => // normal — real stub behaviour
141
- ({ imageId: `${variant}-${symbolRegistry.getSymbolImageId(style, ms, false, pixelRatio)}`, imageData: { width: 10, height: 10 } }))
142
- .mockResolvedValueOnce(null) // active
143
- .mockResolvedValueOnce(null) // selected
144
108
 
145
- await resolvePointSymbol({ manager, mapProvider: createMapProvider(), olFeature })
109
+ await resolvePointSymbol({ manager: createManager({ features: [olFeature] }), mapProvider: createMapProvider(), olFeature })
146
110
 
147
- expect(olFeature.set).toHaveBeenCalledWith('symbolImageId', expect.any(String))
148
- expect(olFeature.set).not.toHaveBeenCalledWith('symbolActiveImageId', expect.anything())
149
- expect(olFeature.set).not.toHaveBeenCalledWith('symbolSelectedImageId', expect.anything())
111
+ expect(olFeature.getProperties().symbolImageAnchor).toEqual(symbolRegistry.getSymbolDef(properties).anchor)
150
112
  })
151
113
 
152
- it('does nothing when rasterisation resolves null (e.g. an unresolvable symbol id)', async () => {
153
- const properties = { symbol: 'not-a-real-symbol' }
154
- const olFeature = createOlFeature(properties)
155
- const manager = createManager({ features: [olFeature] })
156
- symbolRegistry.rasteriseSymbolImage.mockResolvedValueOnce(null)
114
+ it('does nothing for an unresolvable symbol id', async () => {
115
+ const olFeature = createOlFeature({ symbol: 'not-a-real-symbol' })
157
116
 
158
- await resolvePointSymbol({ manager, mapProvider: createMapProvider(), olFeature })
117
+ await resolvePointSymbol({ manager: createManager({ features: [olFeature] }), mapProvider: createMapProvider(), olFeature })
159
118
 
160
- expect(olFeature.set).not.toHaveBeenCalled()
119
+ expect(olFeature.setProperties).not.toHaveBeenCalled()
161
120
  })
162
121
 
163
- it('does not write back if the feature was removed from the source while rasterising was in flight', async () => {
164
- const properties = { symbol: 'pin' }
165
- const olFeature = createOlFeature(properties)
166
- const manager = createManager({ features: [] }) // not present in the source
122
+ it('does not write back if the feature was removed from the source while registering', async () => {
123
+ const olFeature = createOlFeature({ symbol: 'pin' })
167
124
 
168
- await resolvePointSymbol({ manager, mapProvider: createMapProvider(), olFeature })
125
+ await resolvePointSymbol({ manager: createManager({ features: [] }), mapProvider: createMapProvider(), olFeature })
169
126
 
170
- expect(olFeature.set).not.toHaveBeenCalled()
127
+ expect(olFeature.setProperties).not.toHaveBeenCalled()
171
128
  })
172
129
 
173
- it('surfaces (rather than swallows) a rasterisation failure', async () => {
174
- const properties = { symbol: 'pin' }
175
- const olFeature = createOlFeature(properties)
176
- olFeature.getId = () => 'p1'
177
- const manager = createManager({ features: [olFeature] })
130
+ it('rejects, without writing to the feature, when registration fails', async () => {
131
+ const olFeature = createOlFeature({ symbol: 'pin' })
132
+ const mapProvider = createMapProvider()
178
133
  const error = new Error('rasterise failed')
179
- symbolRegistry.rasteriseSymbolImage.mockRejectedValueOnce(error)
180
- const consoleError = jest.spyOn(console, 'error').mockImplementation(() => {})
181
-
182
- await resolvePointSymbol({ manager, mapProvider: createMapProvider(), olFeature })
134
+ mapProvider.addSymbolsToMap.mockRejectedValueOnce(error)
183
135
 
184
- expect(olFeature.set).not.toHaveBeenCalled()
185
- expect(consoleError).toHaveBeenCalledWith('[draw] failed to resolve point symbol', 'p1', error)
136
+ await expect(resolvePointSymbol({ manager: createManager({ features: [olFeature] }), mapProvider, olFeature })).rejects.toBe(error)
137
+ expect(olFeature.setProperties).not.toHaveBeenCalled()
186
138
  })
187
139
  })
188
140
 
@@ -202,9 +154,38 @@ describe('refreshAllPointSymbols', () => {
202
154
 
203
155
  await refreshAllPointSymbols({ manager, mapProvider: createMapProvider() })
204
156
 
205
- expect(pointWithSymbol.set).toHaveBeenCalledWith('symbolImageId', expect.any(String))
206
- expect(pointWithoutSymbol.set).not.toHaveBeenCalled()
207
- expect(polygon.set).not.toHaveBeenCalled()
157
+ expect(pointWithSymbol.setProperties).toHaveBeenCalledWith(expect.objectContaining({ symbolImageId: expect.any(String) }))
158
+ expect(pointWithoutSymbol.setProperties).not.toHaveBeenCalled()
159
+ expect(polygon.setProperties).not.toHaveBeenCalled()
160
+ })
161
+
162
+ it('registers at pixelRatioOverride rather than the map\'s current ratio when given', async () => {
163
+ const point = feature('Point', { symbol: 'pin' })
164
+ const manager = createManager({ features: [point] })
165
+ const mapProvider = createMapProvider({ pixelRatio: 2 })
166
+
167
+ await refreshAllPointSymbols({ manager, mapProvider, pixelRatioOverride: 4 })
168
+
169
+ expect(mapProvider.addSymbolsToMap).toHaveBeenCalledWith(expect.any(Array), mapStyle, symbolRegistry, 4)
170
+ expect(point.setProperties).toHaveBeenCalledWith(expect.objectContaining({ symbolPixelRatio: 4 }))
171
+ })
172
+
173
+ it('drops an older refresh\'s results when a newer one has started since', async () => {
174
+ const point = feature('Point', { symbol: 'pin' })
175
+ const manager = createManager({ features: [point] })
176
+ const mapProvider = createMapProvider()
177
+ // the first refresh's registration is held until after the second has finished
178
+ let releaseFirst
179
+ const held = new Promise((resolve) => { releaseFirst = resolve })
180
+ mapProvider.addSymbolsToMap.mockImplementationOnce(() => held)
181
+
182
+ const first = refreshAllPointSymbols({ manager, mapProvider, pixelRatioOverride: 1 })
183
+ await refreshAllPointSymbols({ manager, mapProvider, pixelRatioOverride: 2 })
184
+ releaseFirst()
185
+ await first
186
+
187
+ expect(point.setProperties).toHaveBeenCalledTimes(1)
188
+ expect(point.setProperties).toHaveBeenCalledWith(expect.objectContaining({ symbolPixelRatio: 2 }))
208
189
  })
209
190
 
210
191
  it('does nothing when there are no drawn points', async () => {
@@ -44,12 +44,8 @@ export const KEYBOARD = {
44
44
  stepAmount: 5
45
45
  }
46
46
 
47
- // Scale factor applied to draw UI (touch targets, vertex handles) per app map size
48
- export const MAP_SIZE_SCALES = {
49
- small: 1,
50
- medium: 1.5,
51
- large: 2
52
- }
47
+ // Scale factor applied to draw UI (touch targets, vertex handles) per app map size — the app's own table
48
+ export { scaleFactor as MAP_SIZE_SCALES } from '../../../src/config/mapSizeScales.js'
53
49
 
54
50
  // The application mode draw enters while drawing or editing (declared in manifest.js)
55
51
  export const APPLICATION_MODE_ID = 'draw'
@@ -7,6 +7,7 @@ describe('stripInternalProperties', () => {
7
7
  properties: {
8
8
  symbol: 'pin',
9
9
  symbolBackgroundColor: '#ca3535',
10
+ symbolSize: 'large',
10
11
  symbolImageId: 'symbol-abc-2x',
11
12
  symbolIconAnchor: 'bottom',
12
13
  symbolIconOffset: [0, -10],
@@ -18,7 +19,7 @@ describe('stripInternalProperties', () => {
18
19
 
19
20
  expect(stripInternalProperties(feature)).toEqual({
20
21
  id: 'a',
21
- properties: { symbol: 'pin', symbolBackgroundColor: '#ca3535' }
22
+ properties: { symbol: 'pin', symbolBackgroundColor: '#ca3535', symbolSize: 'large' }
22
23
  })
23
24
  })
24
25
 
@@ -1,5 +1,4 @@
1
+ import { SYMBOL_STYLE_KEYS } from '../../../../src/config/symbolConfig.js'
2
+
1
3
  // Public symbol-config keys a caller can set on a Point (see docs/api/symbol-config.md).
2
- export const SYMBOL_KEYS = new Set([
3
- 'symbol', 'symbolSvgContent', 'symbolBackgroundColor', 'symbolForegroundColor',
4
- 'symbolHaloWidth', 'symbolGraphic', 'symbolViewBox', 'symbolAnchor'
5
- ])
4
+ export const SYMBOL_KEYS = new Set(SYMBOL_STYLE_KEYS)