@accelint/map-toolkit 0.6.0 → 1.1.0

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 (207) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/catalog-info.yaml +7 -6
  3. package/dist/camera/events.js.map +1 -1
  4. package/dist/camera/index.d.ts +2 -2
  5. package/dist/camera/index.js +2 -2
  6. package/dist/camera/store.d.ts +120 -0
  7. package/dist/camera/store.js +279 -0
  8. package/dist/camera/store.js.map +1 -0
  9. package/dist/cursor-coordinates/index.d.ts +4 -2
  10. package/dist/cursor-coordinates/index.js +3 -2
  11. package/dist/cursor-coordinates/store.d.ts +48 -0
  12. package/dist/cursor-coordinates/store.js +92 -0
  13. package/dist/cursor-coordinates/store.js.map +1 -0
  14. package/dist/cursor-coordinates/types.d.ts +87 -0
  15. package/dist/cursor-coordinates/types.js +12 -0
  16. package/dist/cursor-coordinates/use-cursor-coordinates.d.ts +41 -37
  17. package/dist/cursor-coordinates/use-cursor-coordinates.js +131 -202
  18. package/dist/cursor-coordinates/use-cursor-coordinates.js.map +1 -1
  19. package/dist/deckgl/base-map/constants.d.ts +1 -6
  20. package/dist/deckgl/base-map/constants.js +1 -6
  21. package/dist/deckgl/base-map/constants.js.map +1 -1
  22. package/dist/deckgl/base-map/controls.js +2 -0
  23. package/dist/deckgl/base-map/controls.js.map +1 -1
  24. package/dist/deckgl/base-map/events.js.map +1 -1
  25. package/dist/deckgl/base-map/index.d.ts +2 -2
  26. package/dist/deckgl/base-map/index.js +10 -11
  27. package/dist/deckgl/base-map/index.js.map +1 -1
  28. package/dist/deckgl/base-map/provider.d.ts +2 -2
  29. package/dist/deckgl/base-map/provider.js +1 -1
  30. package/dist/deckgl/base-map/provider.js.map +1 -1
  31. package/dist/deckgl/index.d.ts +4 -4
  32. package/dist/deckgl/index.js +4 -4
  33. package/dist/deckgl/saved-viewports/index.js.map +1 -1
  34. package/dist/deckgl/saved-viewports/storage.js +10 -2
  35. package/dist/deckgl/saved-viewports/storage.js.map +1 -1
  36. package/dist/deckgl/shapes/display-shape-layer/constants.js +5 -8
  37. package/dist/deckgl/shapes/display-shape-layer/constants.js.map +1 -1
  38. package/dist/deckgl/shapes/display-shape-layer/fiber.js.map +1 -1
  39. package/dist/deckgl/shapes/display-shape-layer/index.d.ts +18 -14
  40. package/dist/deckgl/shapes/display-shape-layer/index.js +63 -30
  41. package/dist/deckgl/shapes/display-shape-layer/index.js.map +1 -1
  42. package/dist/deckgl/shapes/display-shape-layer/shape-label-layer.js +2 -16
  43. package/dist/deckgl/shapes/display-shape-layer/shape-label-layer.js.map +1 -1
  44. package/dist/deckgl/shapes/display-shape-layer/store.js +58 -272
  45. package/dist/deckgl/shapes/display-shape-layer/store.js.map +1 -1
  46. package/dist/deckgl/shapes/display-shape-layer/types.d.ts +22 -11
  47. package/dist/deckgl/shapes/display-shape-layer/{use-shape-selection.d.ts → use-select-shape.d.ts} +9 -9
  48. package/dist/deckgl/shapes/display-shape-layer/{use-shape-selection.js → use-select-shape.js} +12 -12
  49. package/dist/deckgl/shapes/display-shape-layer/use-select-shape.js.map +1 -0
  50. package/dist/deckgl/shapes/display-shape-layer/utils/display-style.js +5 -66
  51. package/dist/deckgl/shapes/display-shape-layer/utils/display-style.js.map +1 -1
  52. package/dist/deckgl/shapes/display-shape-layer/utils/labels.d.ts +2 -65
  53. package/dist/deckgl/shapes/display-shape-layer/utils/labels.js +3 -121
  54. package/dist/deckgl/shapes/display-shape-layer/utils/labels.js.map +1 -1
  55. package/dist/deckgl/shapes/draw-shape-layer/constants.js +46 -0
  56. package/dist/deckgl/shapes/draw-shape-layer/constants.js.map +1 -0
  57. package/dist/deckgl/shapes/draw-shape-layer/events.d.ts +92 -0
  58. package/dist/deckgl/shapes/draw-shape-layer/events.js +56 -0
  59. package/dist/deckgl/shapes/draw-shape-layer/events.js.map +1 -0
  60. package/dist/deckgl/shapes/draw-shape-layer/fiber.d.ts +11 -0
  61. package/dist/{maplibre/constants.js → deckgl/shapes/draw-shape-layer/fiber.js} +6 -12
  62. package/dist/deckgl/shapes/draw-shape-layer/fiber.js.map +1 -0
  63. package/dist/deckgl/shapes/draw-shape-layer/index.d.ts +53 -0
  64. package/dist/deckgl/shapes/draw-shape-layer/index.js +95 -0
  65. package/dist/deckgl/shapes/draw-shape-layer/index.js.map +1 -0
  66. package/dist/deckgl/shapes/draw-shape-layer/modes/draw-circle-mode-with-tooltip.js +51 -0
  67. package/dist/deckgl/shapes/draw-shape-layer/modes/draw-circle-mode-with-tooltip.js.map +1 -0
  68. package/dist/deckgl/shapes/draw-shape-layer/modes/draw-ellipse-mode-with-tooltip.js +73 -0
  69. package/dist/deckgl/shapes/draw-shape-layer/modes/draw-ellipse-mode-with-tooltip.js.map +1 -0
  70. package/dist/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.js +87 -0
  71. package/dist/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.js.map +1 -0
  72. package/dist/deckgl/shapes/draw-shape-layer/modes/draw-polygon-mode-with-tooltip.js +88 -0
  73. package/dist/deckgl/shapes/draw-shape-layer/modes/draw-polygon-mode-with-tooltip.js.map +1 -0
  74. package/dist/deckgl/shapes/draw-shape-layer/modes/draw-rectangle-mode-with-tooltip.js +77 -0
  75. package/dist/deckgl/shapes/draw-shape-layer/modes/draw-rectangle-mode-with-tooltip.js.map +1 -0
  76. package/dist/deckgl/shapes/draw-shape-layer/modes/index.js +64 -0
  77. package/dist/deckgl/shapes/draw-shape-layer/modes/index.js.map +1 -0
  78. package/dist/deckgl/shapes/draw-shape-layer/store.js +175 -0
  79. package/dist/deckgl/shapes/draw-shape-layer/store.js.map +1 -0
  80. package/dist/deckgl/shapes/draw-shape-layer/types.d.ts +86 -0
  81. package/dist/{viewport/constants.js → deckgl/shapes/draw-shape-layer/types.js} +1 -12
  82. package/dist/deckgl/shapes/draw-shape-layer/use-draw-shape.d.ts +82 -0
  83. package/dist/deckgl/shapes/draw-shape-layer/use-draw-shape.js +112 -0
  84. package/dist/deckgl/shapes/draw-shape-layer/use-draw-shape.js.map +1 -0
  85. package/dist/deckgl/shapes/draw-shape-layer/utils/feature-conversion.js +147 -0
  86. package/dist/deckgl/shapes/draw-shape-layer/utils/feature-conversion.js.map +1 -0
  87. package/dist/deckgl/shapes/edit-shape-layer/constants.js +41 -0
  88. package/dist/deckgl/shapes/edit-shape-layer/constants.js.map +1 -0
  89. package/dist/deckgl/shapes/edit-shape-layer/events.d.ts +92 -0
  90. package/dist/deckgl/shapes/edit-shape-layer/events.js +56 -0
  91. package/dist/deckgl/shapes/edit-shape-layer/events.js.map +1 -0
  92. package/dist/deckgl/shapes/edit-shape-layer/fiber.d.ts +13 -0
  93. package/dist/deckgl/shapes/edit-shape-layer/fiber.js +14 -0
  94. package/dist/deckgl/shapes/edit-shape-layer/index.d.ts +63 -0
  95. package/dist/deckgl/shapes/edit-shape-layer/index.js +162 -0
  96. package/dist/deckgl/shapes/edit-shape-layer/index.js.map +1 -0
  97. package/dist/deckgl/shapes/edit-shape-layer/modes/base-transform-mode.js +154 -0
  98. package/dist/deckgl/shapes/edit-shape-layer/modes/base-transform-mode.js.map +1 -0
  99. package/dist/deckgl/shapes/edit-shape-layer/modes/bounding-transform-mode.js +147 -0
  100. package/dist/deckgl/shapes/edit-shape-layer/modes/bounding-transform-mode.js.map +1 -0
  101. package/dist/deckgl/shapes/edit-shape-layer/modes/circle-transform-mode.js +87 -0
  102. package/dist/deckgl/shapes/edit-shape-layer/modes/circle-transform-mode.js.map +1 -0
  103. package/dist/deckgl/shapes/edit-shape-layer/modes/index.js +61 -0
  104. package/dist/deckgl/shapes/edit-shape-layer/modes/index.js.map +1 -0
  105. package/dist/deckgl/shapes/edit-shape-layer/modes/rotate-mode-with-snap.js +109 -0
  106. package/dist/deckgl/shapes/edit-shape-layer/modes/rotate-mode-with-snap.js.map +1 -0
  107. package/dist/deckgl/shapes/edit-shape-layer/modes/scale-mode-with-free-transform.js +289 -0
  108. package/dist/deckgl/shapes/edit-shape-layer/modes/scale-mode-with-free-transform.js.map +1 -0
  109. package/dist/deckgl/shapes/edit-shape-layer/modes/vertex-transform-mode.js +121 -0
  110. package/dist/deckgl/shapes/edit-shape-layer/modes/vertex-transform-mode.js.map +1 -0
  111. package/dist/deckgl/shapes/edit-shape-layer/store.js +194 -0
  112. package/dist/deckgl/shapes/edit-shape-layer/store.js.map +1 -0
  113. package/dist/deckgl/shapes/edit-shape-layer/types.d.ts +93 -0
  114. package/dist/deckgl/shapes/edit-shape-layer/types.js +14 -0
  115. package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.d.ts +82 -0
  116. package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.js +114 -0
  117. package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.js.map +1 -0
  118. package/dist/deckgl/shapes/index.d.ts +15 -6
  119. package/dist/deckgl/shapes/index.js +12 -5
  120. package/dist/deckgl/shapes/shared/constants.d.ts +27 -32
  121. package/dist/deckgl/shapes/shared/constants.js +189 -25
  122. package/dist/deckgl/shapes/shared/constants.js.map +1 -1
  123. package/dist/deckgl/shapes/shared/events.d.ts +1 -20
  124. package/dist/deckgl/shapes/shared/events.js +1 -31
  125. package/dist/deckgl/shapes/shared/events.js.map +1 -1
  126. package/dist/deckgl/shapes/shared/hooks/use-shift-zoom-disable.js +84 -0
  127. package/dist/deckgl/shapes/shared/hooks/use-shift-zoom-disable.js.map +1 -0
  128. package/dist/deckgl/shapes/shared/types.d.ts +187 -28
  129. package/dist/deckgl/shapes/shared/types.js +55 -1
  130. package/dist/deckgl/shapes/shared/types.js.map +1 -1
  131. package/dist/deckgl/shapes/shared/utils/geometry-measurements.js +128 -0
  132. package/dist/deckgl/shapes/shared/utils/geometry-measurements.js.map +1 -0
  133. package/dist/deckgl/shapes/shared/utils/layer-config.js +50 -0
  134. package/dist/deckgl/shapes/shared/utils/layer-config.js.map +1 -0
  135. package/dist/deckgl/shapes/shared/utils/mode-utils.js +113 -0
  136. package/dist/deckgl/shapes/shared/utils/mode-utils.js.map +1 -0
  137. package/dist/deckgl/shapes/shared/utils/pick-filtering.js +57 -0
  138. package/dist/deckgl/shapes/shared/utils/pick-filtering.js.map +1 -0
  139. package/dist/deckgl/shapes/shared/utils/style-utils.d.ts +64 -0
  140. package/dist/deckgl/shapes/shared/utils/style-utils.js +101 -0
  141. package/dist/deckgl/shapes/shared/utils/style-utils.js.map +1 -0
  142. package/dist/deckgl/symbol-layer/fiber.js.map +1 -1
  143. package/dist/deckgl/symbol-layer/index.js.map +1 -1
  144. package/dist/deckgl/text-layer/character-sets.js.map +1 -1
  145. package/dist/deckgl/text-layer/default-settings.js +4 -24
  146. package/dist/deckgl/text-layer/default-settings.js.map +1 -1
  147. package/dist/deckgl/text-layer/fiber.js.map +1 -1
  148. package/dist/deckgl/text-layer/index.js.map +1 -1
  149. package/dist/deckgl/text-settings.d.ts +77 -0
  150. package/dist/deckgl/text-settings.js +83 -0
  151. package/dist/deckgl/text-settings.js.map +1 -0
  152. package/dist/map-cursor/events.js.map +1 -1
  153. package/dist/map-cursor/index.d.ts +2 -2
  154. package/dist/map-cursor/index.js +2 -2
  155. package/dist/map-cursor/store.d.ts +32 -61
  156. package/dist/map-cursor/store.js +165 -294
  157. package/dist/map-cursor/store.js.map +1 -1
  158. package/dist/map-cursor/use-map-cursor.d.ts +5 -2
  159. package/dist/map-cursor/use-map-cursor.js +33 -15
  160. package/dist/map-cursor/use-map-cursor.js.map +1 -1
  161. package/dist/map-mode/events.js.map +1 -1
  162. package/dist/map-mode/index.d.ts +2 -2
  163. package/dist/map-mode/index.js +2 -2
  164. package/dist/map-mode/store.d.ts +36 -37
  165. package/dist/map-mode/store.js +131 -237
  166. package/dist/map-mode/store.js.map +1 -1
  167. package/dist/map-mode/use-map-mode.js +6 -5
  168. package/dist/map-mode/use-map-mode.js.map +1 -1
  169. package/dist/maplibre/hooks/use-maplibre.js.map +1 -1
  170. package/dist/maplibre/index.d.ts +2 -2
  171. package/dist/maplibre/index.js +2 -2
  172. package/dist/shared/constants.d.ts +19 -0
  173. package/dist/shared/constants.js +33 -0
  174. package/dist/shared/constants.js.map +1 -0
  175. package/dist/shared/create-map-store.d.ts +202 -0
  176. package/dist/shared/create-map-store.js +223 -0
  177. package/dist/shared/create-map-store.js.map +1 -0
  178. package/dist/shared/units.d.ts +39 -0
  179. package/dist/shared/units.js +49 -0
  180. package/dist/shared/units.js.map +1 -0
  181. package/dist/viewport/index.d.ts +3 -3
  182. package/dist/viewport/index.js +3 -3
  183. package/dist/viewport/store.d.ts +69 -0
  184. package/dist/viewport/store.js +125 -0
  185. package/dist/viewport/store.js.map +1 -0
  186. package/dist/viewport/types.d.ts +2 -2
  187. package/dist/viewport/utils.js +2 -2
  188. package/dist/viewport/utils.js.map +1 -1
  189. package/dist/viewport/viewport-size.d.ts +2 -2
  190. package/dist/viewport/viewport-size.js +2 -2
  191. package/dist/viewport/viewport-size.js.map +1 -1
  192. package/package.json +39 -19
  193. package/dist/camera/use-camera-state.d.ts +0 -153
  194. package/dist/camera/use-camera-state.js +0 -418
  195. package/dist/camera/use-camera-state.js.map +0 -1
  196. package/dist/deckgl/shapes/display-shape-layer/constants.d.ts +0 -44
  197. package/dist/deckgl/shapes/display-shape-layer/shape-label-layer.d.ts +0 -66
  198. package/dist/deckgl/shapes/display-shape-layer/store.d.ts +0 -87
  199. package/dist/deckgl/shapes/display-shape-layer/use-shape-selection.js.map +0 -1
  200. package/dist/deckgl/shapes/display-shape-layer/utils/display-style.d.ts +0 -61
  201. package/dist/maplibre/constants.d.ts +0 -13
  202. package/dist/maplibre/constants.js.map +0 -1
  203. package/dist/viewport/constants.d.ts +0 -11
  204. package/dist/viewport/constants.js.map +0 -1
  205. package/dist/viewport/use-viewport-state.d.ts +0 -100
  206. package/dist/viewport/use-viewport-state.js +0 -222
  207. package/dist/viewport/use-viewport-state.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,86 @@
1
1
  # @accelint/map-toolkit
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0175dd1: Update useCursorCoordinates to accept a custom formatter and return more information about the raw coordinate.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [45275c4]
12
+ - Updated dependencies [d328b71]
13
+ - @accelint/geo@0.5.1
14
+ - @accelint/logger@0.1.5
15
+
16
+ ## 1.0.0
17
+
18
+ ### Major Changes
19
+
20
+ - 4e614fb: Refactor map-toolkit for v1 release:
21
+
22
+ **Breaking Changes:**
23
+ - Rename `useViewportState` → `useMapViewport`
24
+ - Rename `useCameraState` → `useMapCamera`
25
+ - Rename `useShapeSelection` → `useSelectShape`
26
+ - Rename `INITIAL_VIEW_STATE` → `DEFAULT_VIEW_STATE` (in maplibre exports)
27
+ - Remove `@accelint/map-toolkit/maplibre/constants` export
28
+
29
+ **Bug Fixes:**
30
+ - Fix `useMapCursorEffect` not updating cursor when props change
31
+ - Fix saved viewports not restoring map position (now uses `CameraEventTypes.setCenter`)
32
+
33
+ **Internal Improvements:**
34
+ - Refactor all stores to use `createMapStore` factory pattern
35
+ - Hoist `DEFAULT_VIEW_STATE` to `shared/constants`
36
+ - Replace `console.warn` with `@accelint/logger` for conditional logging
37
+ - Standardize drawStore to use shared mode-utils
38
+ - Update saved viewports docs and story to use camera events correctly
39
+
40
+ ### Minor Changes
41
+
42
+ - fd26776: Add EditShapeLayer for interactive shape editing
43
+
44
+ **New features:**
45
+ - `EditShapeLayer` component for editing existing shapes on the map
46
+ - `showLabels` prop in `DisplayShapeLayer` now supports `'always' | 'hover' | 'never'` modes for flexible label display (hover mode shows labels only on shape hover)
47
+ - `useEditShape` hook for managing edit state with `edit()`, `save()`, and `cancel()` controls
48
+ - Support for all shape types: Point, LineString, Polygon, Rectangle, Circle, and Ellipse
49
+ - Live measurement tooltips during editing (dimensions and area)
50
+ - Shift key modifiers: hold for uniform scaling or 45° rotation snapping
51
+ - ESC key to cancel editing
52
+ - Locked shape support (`shape.locked` prevents editing)
53
+
54
+ **Bug fixes:**
55
+ - Add `boxZoom` to disabled controls list when Shift key is used for shape operations (prevents map zoom interference)
56
+
57
+ **Internal improvements:**
58
+ - Consolidate tooltip calculation logic into shared geometry measurement utilities
59
+ - Standardize `mapId` optionality across hooks (optional with context fallback)
60
+ - Add documentation for modes architecture (README.md in modes directory)
61
+ - Rename `strokeColor` to `lineColor` and `strokeWidth` to `lineWidth` in style properties to align with deck.gl conventions
62
+ - Rename `shapeType` to `shape` in Shape type for consistency with deck.gl
63
+
64
+ - fb3fe97: Add DrawShapeLayer for interactive shape drawing
65
+
66
+ **New features:**
67
+ - `DrawShapeLayer` component for drawing shapes on the map
68
+ - `useDrawShape` hook for managing drawing state with `draw()` and `cancel()` controls
69
+ - Support for multiple geometry types: Point, LineString, Polygon, Rectangle, Circle, and Ellipse
70
+ - Real-time tooltips showing distance/area measurements during drawing
71
+ - Protected drawing mode (cannot be interrupted by other map mode requests)
72
+ - Double-click to finish polygons and lines
73
+ - Shift-to-square constraint when drawing rectangles
74
+ - Custom styling support (fill/line colors) when initiating drawing
75
+ - ESC key to cancel drawing
76
+
77
+ **Internal improvements:**
78
+ - Refactor viewport to use shared unit abbreviation map from `shared/units.ts`
79
+
80
+ ### Patch Changes
81
+
82
+ - 2e6389a: Fixes a regression in viewport size where viewport changes weren't updating
83
+
3
84
  ## 0.6.0
4
85
 
5
86
  ### Minor Changes
package/catalog-info.yaml CHANGED
@@ -11,15 +11,15 @@ metadata:
11
11
 
12
12
  Dependencies:
13
13
 
14
- accelint_biome-config@1.0.2, accelint_bus@3.0.2, accelint_core@0.5.2,
15
- accelint_design-foundation@2.0.0, accelint_design-toolkit@9.1.1,
16
- accelint_geo@0.4.2, accelint_postcss-tailwind-css-modules@1.0.1,
17
- accelint_smeegl@0.3.4, accelint_typescript-config@0.1.4,
18
- accelint_vitest-config@0.1.6
14
+ accelint_biome-config@1.1.0, accelint_bus@3.0.2, accelint_core@0.5.2,
15
+ accelint_design-foundation@2.1.0, accelint_design-toolkit@9.3.0,
16
+ accelint_geo@0.5.1, accelint_logger@0.1.5,
17
+ accelint_postcss-tailwind-css-modules@1.0.1, accelint_smeegl@0.3.4,
18
+ accelint_typescript-config@0.1.4, accelint_vitest-config@0.1.6
19
19
  annotations:
20
20
  backstage.io/edit-url: https://github.com/gohypergiant/standard-toolkit/blob/main/packages/map-toolkit/catalog-info.yaml
21
21
  backstage.io/techdocs-ref: dir:.
22
- package/version: 0.6.0
22
+ package/version: 1.1.0
23
23
  github.com/project-slug: gohypergiant/standard-toolkit
24
24
  links:
25
25
  - url: https://github.com/gohypergiant/standard-toolkit/tree/main/packages/map-toolkit
@@ -42,6 +42,7 @@ spec:
42
42
  - component:accelint_design-foundation
43
43
  - component:accelint_design-toolkit
44
44
  - component:accelint_geo
45
+ - component:accelint_logger
45
46
  - component:accelint_postcss-tailwind-css-modules
46
47
  - component:accelint_smeegl
47
48
  - component:accelint_typescript-config
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","names":[],"sources":["../../src/camera/events.ts"],"sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport const CameraEventNamespace = 'camera';\n\nexport const CameraEventTypes = {\n setView: `${CameraEventNamespace}:setView`,\n setProjection: `${CameraEventNamespace}:setProjection`,\n setZoom: `${CameraEventNamespace}:setZoom`,\n setRotation: `${CameraEventNamespace}:setRotation`,\n setPitch: `${CameraEventNamespace}:setPitch`,\n setCenter: `${CameraEventNamespace}:setCenter`,\n fitBounds: `${CameraEventNamespace}:fitBounds`,\n reset: `${CameraEventNamespace}:reset`,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAa,uBAAuB;AAEpC,MAAa,mBAAmB;CAC9B,SAAS,GAAG,qBAAqB;CACjC,eAAe,GAAG,qBAAqB;CACvC,SAAS,GAAG,qBAAqB;CACjC,aAAa,GAAG,qBAAqB;CACrC,UAAU,GAAG,qBAAqB;CAClC,WAAW,GAAG,qBAAqB;CACnC,WAAW,GAAG,qBAAqB;CACnC,OAAO,GAAG,qBAAqB;CAChC"}
1
+ {"version":3,"file":"events.js","names":[],"sources":["../../src/camera/events.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport const CameraEventNamespace = 'camera';\n\nexport const CameraEventTypes = {\n setView: `${CameraEventNamespace}:setView`,\n setProjection: `${CameraEventNamespace}:setProjection`,\n setZoom: `${CameraEventNamespace}:setZoom`,\n setRotation: `${CameraEventNamespace}:setRotation`,\n setPitch: `${CameraEventNamespace}:setPitch`,\n setCenter: `${CameraEventNamespace}:setCenter`,\n fitBounds: `${CameraEventNamespace}:fitBounds`,\n reset: `${CameraEventNamespace}:reset`,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAa,uBAAuB;AAEpC,MAAa,mBAAmB;CAC9B,SAAS,GAAG,qBAAqB;CACjC,eAAe,GAAG,qBAAqB;CACvC,SAAS,GAAG,qBAAqB;CACjC,aAAa,GAAG,qBAAqB;CACrC,UAAU,GAAG,qBAAqB;CAClC,WAAW,GAAG,qBAAqB;CACnC,WAAW,GAAG,qBAAqB;CACnC,OAAO,GAAG,qBAAqB;CAChC"}
@@ -11,6 +11,6 @@
11
11
  */
12
12
 
13
13
  import { CameraEventNamespace, CameraEventTypes } from "./events.js";
14
- import { CameraState, UseCameraStateProps, clearCameraState, useCameraState } from "./use-camera-state.js";
15
14
  import { CameraEvent, CameraFitBoundsEvent, CameraResetEvent, CameraSetCenterEvent, CameraSetPitchEvent, CameraSetProjectionEvent, CameraSetRotationEvent, CameraSetViewEvent, CameraSetZoomEvent, ProjectionType, ViewType } from "./types.js";
16
- export { type CameraEvent, CameraEventNamespace, CameraEventTypes, type CameraFitBoundsEvent, type CameraResetEvent, type CameraSetCenterEvent, type CameraSetPitchEvent, type CameraSetProjectionEvent, type CameraSetRotationEvent, type CameraSetViewEvent, type CameraSetZoomEvent, type CameraState, type ProjectionType, type UseCameraStateProps, type ViewType, clearCameraState, useCameraState };
15
+ import { CameraState, cameraStore, clearCameraState, useMapCamera } from "./store.js";
16
+ export { type CameraEvent, CameraEventNamespace, CameraEventTypes, type CameraFitBoundsEvent, type CameraResetEvent, type CameraSetCenterEvent, type CameraSetPitchEvent, type CameraSetProjectionEvent, type CameraSetRotationEvent, type CameraSetViewEvent, type CameraSetZoomEvent, type CameraState, type ProjectionType, type ViewType, cameraStore, clearCameraState, useMapCamera };
@@ -12,6 +12,6 @@
12
12
 
13
13
 
14
14
  import { CameraEventNamespace, CameraEventTypes } from "./events.js";
15
- import { clearCameraState, useCameraState } from "./use-camera-state.js";
15
+ import { cameraStore, clearCameraState, useMapCamera } from "./store.js";
16
16
 
17
- export { CameraEventNamespace, CameraEventTypes, clearCameraState, useCameraState };
17
+ export { CameraEventNamespace, CameraEventTypes, cameraStore, clearCameraState, useMapCamera };
@@ -0,0 +1,120 @@
1
+ /*
2
+ * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at https://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import { MapStore } from "../shared/create-map-store.js";
14
+ import { ProjectionType, ViewType } from "./types.js";
15
+ import { UniqueId } from "@accelint/core";
16
+
17
+ //#region src/camera/store.d.ts
18
+ /**
19
+ * Camera state for 2D view
20
+ */
21
+ type CameraState2D = {
22
+ latitude: number;
23
+ longitude: number;
24
+ zoom: number;
25
+ pitch: 0;
26
+ rotation: number;
27
+ projection: 'mercator';
28
+ view: '2D';
29
+ };
30
+ /**
31
+ * Camera state for 3D view
32
+ */
33
+ type CameraState3D = {
34
+ latitude: number;
35
+ longitude: number;
36
+ zoom: number;
37
+ pitch: 0;
38
+ rotation: number;
39
+ projection: 'globe';
40
+ view: '3D';
41
+ };
42
+ /**
43
+ * Camera state for 2.5D view
44
+ */
45
+ type CameraState2Point5D = {
46
+ latitude: number;
47
+ longitude: number;
48
+ zoom: number;
49
+ pitch: number;
50
+ rotation: number;
51
+ projection: 'mercator';
52
+ view: '2.5D';
53
+ };
54
+ /**
55
+ * Union type for all camera states
56
+ */
57
+ type CameraState = CameraState2D | CameraState3D | CameraState2Point5D;
58
+ /**
59
+ * Actions for camera management
60
+ */
61
+ type CameraActions = {
62
+ /** Update camera state directly */
63
+ setCameraState: (state: Partial<CameraState>) => void;
64
+ };
65
+ /**
66
+ * Input type for building camera state - simpler than union type
67
+ */
68
+ type CameraStateInput = {
69
+ latitude?: number;
70
+ longitude?: number;
71
+ zoom?: number;
72
+ pitch?: number;
73
+ rotation?: number;
74
+ projection?: ProjectionType;
75
+ view?: ViewType;
76
+ };
77
+ /**
78
+ * Camera store instance
79
+ */
80
+ declare const cameraStore: MapStore<CameraState, CameraActions>;
81
+ /**
82
+ * Initialize camera state for a map instance with optional initial values.
83
+ * Should be called before using the camera store for a given mapId.
84
+ *
85
+ * @param mapId - Unique identifier for the map instance
86
+ * @param initialState - Optional initial camera state
87
+ */
88
+ declare function initializeCameraState(mapId: UniqueId, initialState?: CameraStateInput): void;
89
+ /**
90
+ * Hook to subscribe to camera state changes for a specific map.
91
+ *
92
+ * @param mapId - Unique identifier for the map instance
93
+ * @param initialCameraState - Optional initial camera state (only used on first call)
94
+ * @returns Camera state and setCameraState action
95
+ *
96
+ * @example
97
+ * ```tsx
98
+ * function MapInfo({ mapId }) {
99
+ * const { cameraState, setCameraState } = useMapCamera(mapId);
100
+ * return (
101
+ * <div>
102
+ * Lat: {cameraState.latitude.toFixed(2)}, Lon: {cameraState.longitude.toFixed(2)}
103
+ * </div>
104
+ * );
105
+ * }
106
+ * ```
107
+ */
108
+ declare function useMapCamera(mapId: UniqueId, initialCameraState?: CameraStateInput): {
109
+ cameraState: CameraState;
110
+ setCameraState: (state: Partial<CameraState>) => void;
111
+ };
112
+ /**
113
+ * Manually clear camera state for a specific map instance.
114
+ *
115
+ * @param mapId - The unique identifier for the map instance to clear
116
+ */
117
+ declare function clearCameraState(mapId: UniqueId): void;
118
+ //#endregion
119
+ export { CameraState, cameraStore, clearCameraState, initializeCameraState, useMapCamera };
120
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1,279 @@
1
+ /*
2
+ * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at https://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+
14
+ import { CameraEventTypes } from "./events.js";
15
+ import { createMapStore } from "../shared/create-map-store.js";
16
+ import { Broadcast } from "@accelint/bus";
17
+ import { fitBounds } from "@math.gl/web-mercator";
18
+
19
+ //#region src/camera/store.ts
20
+ /**
21
+ * Camera Store
22
+ *
23
+ * Manages camera state (position, zoom, pitch, rotation, projection, view) per map instance.
24
+ * State is updated via bus events or direct actions.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * import { cameraStore } from '@accelint/map-toolkit/camera';
29
+ *
30
+ * function MapInfo({ mapId }) {
31
+ * const { state } = cameraStore.use(mapId);
32
+ * return (
33
+ * <div>
34
+ * Lat: {state.latitude.toFixed(2)}, Lon: {state.longitude.toFixed(2)}
35
+ * </div>
36
+ * );
37
+ * }
38
+ * ```
39
+ */
40
+ const cameraBus = Broadcast.getInstance();
41
+ /**
42
+ * Storage for initial camera state per instance.
43
+ * Used for reset operations to restore to initial values.
44
+ *
45
+ * @internal These caches live outside the store factory because reset operations
46
+ * need access to the original initial values. They are cleaned up via `onCleanup`
47
+ * hook when the store instance is destroyed, and via `clearCameraState()` for
48
+ * manual cleanup. Do NOT use `cameraStore.clear()` directly in tests - use
49
+ * `clearCameraState()` instead to ensure proper cleanup.
50
+ */
51
+ const initialStateCache = /* @__PURE__ */ new Map();
52
+ /**
53
+ * Track which instances have been initialized.
54
+ * @internal See note on initialStateCache about cleanup.
55
+ */
56
+ const initializedInstances = /* @__PURE__ */ new Set();
57
+ /**
58
+ * Build a complete camera state from partial input.
59
+ * Returns the appropriate discriminated union variant based on view/projection.
60
+ */
61
+ function buildCameraState(partial) {
62
+ const latitude = partial?.latitude ?? 0;
63
+ const longitude = partial?.longitude ?? 0;
64
+ const zoom = partial?.zoom ?? 0;
65
+ const rotation = partial?.rotation ?? 0;
66
+ const is3D = partial?.view === "3D" || partial?.projection === "globe";
67
+ const is2Point5D = partial?.view === "2.5D";
68
+ if (is3D) return {
69
+ latitude,
70
+ longitude,
71
+ zoom,
72
+ pitch: 0,
73
+ rotation: 0,
74
+ projection: "globe",
75
+ view: "3D"
76
+ };
77
+ if (is2Point5D) return {
78
+ latitude,
79
+ longitude,
80
+ zoom,
81
+ pitch: partial?.pitch ?? 45,
82
+ rotation,
83
+ projection: "mercator",
84
+ view: "2.5D"
85
+ };
86
+ return {
87
+ latitude,
88
+ longitude,
89
+ zoom,
90
+ pitch: 0,
91
+ rotation,
92
+ projection: "mercator",
93
+ view: "2D"
94
+ };
95
+ }
96
+ /**
97
+ * Default camera state
98
+ */
99
+ const DEFAULT_CAMERA_STATE = {
100
+ latitude: 0,
101
+ longitude: 0,
102
+ zoom: 0,
103
+ pitch: 0,
104
+ rotation: 0,
105
+ projection: "mercator",
106
+ view: "2D"
107
+ };
108
+ /**
109
+ * Camera store instance
110
+ */
111
+ const cameraStore = createMapStore({
112
+ defaultState: DEFAULT_CAMERA_STATE,
113
+ actions: (_mapId, { get, replace }) => ({ setCameraState: (updates) => {
114
+ replace(buildCameraState({
115
+ ...get(),
116
+ ...updates
117
+ }));
118
+ } }),
119
+ bus: (mapId, { get, replace }) => {
120
+ const unsubReset = cameraBus.on(CameraEventTypes.reset, ({ payload }) => {
121
+ if (payload.id !== mapId) return;
122
+ const state = get();
123
+ const initialState = initialStateCache.get(mapId);
124
+ replace(buildCameraState({
125
+ latitude: state.latitude,
126
+ longitude: state.longitude,
127
+ projection: state.projection,
128
+ view: state.view,
129
+ zoom: payload.zoom === false ? state.zoom : initialState?.zoom ?? 0,
130
+ pitch: payload.pitch === false ? state.pitch : initialState?.pitch ?? 0,
131
+ rotation: payload.rotation === false ? state.rotation : initialState?.rotation ?? 0
132
+ }));
133
+ });
134
+ const unsubSetCenter = cameraBus.on(CameraEventTypes.setCenter, ({ payload }) => {
135
+ if (payload.id !== mapId) return;
136
+ const state = get();
137
+ replace(buildCameraState({
138
+ ...state,
139
+ latitude: payload.latitude,
140
+ longitude: payload.longitude,
141
+ zoom: payload.zoom ?? state.zoom,
142
+ rotation: payload.heading ?? state.rotation,
143
+ pitch: payload.pitch ?? state.pitch
144
+ }));
145
+ });
146
+ const unsubFitBounds = cameraBus.on(CameraEventTypes.fitBounds, ({ payload }) => {
147
+ if (payload.id !== mapId) return;
148
+ const state = get();
149
+ const { longitude, latitude, zoom } = fitBounds({
150
+ width: payload.width,
151
+ height: payload.height,
152
+ bounds: [[payload.bounds[0], payload.bounds[1]], [payload.bounds[2], payload.bounds[3]]],
153
+ padding: payload.padding
154
+ });
155
+ replace(buildCameraState({
156
+ ...state,
157
+ latitude,
158
+ longitude,
159
+ zoom,
160
+ rotation: payload.heading ?? state.rotation,
161
+ pitch: payload.pitch ?? state.pitch
162
+ }));
163
+ });
164
+ const unsubSetProjection = cameraBus.on(CameraEventTypes.setProjection, ({ payload }) => {
165
+ if (payload.id !== mapId) return;
166
+ const newState = { ...get() };
167
+ newState.projection = payload.projection;
168
+ if (payload.projection === "globe") newState.view = "3D";
169
+ else {
170
+ newState.view = "2D";
171
+ newState.pitch = 0;
172
+ }
173
+ replace(newState);
174
+ });
175
+ const unsubSetView = cameraBus.on(CameraEventTypes.setView, ({ payload }) => {
176
+ if (payload.id !== mapId) return;
177
+ const newState = { ...get() };
178
+ newState.view = payload.view;
179
+ if (payload.view === "3D") {
180
+ newState.projection = "globe";
181
+ newState.pitch = 0;
182
+ } else newState.projection = "mercator";
183
+ if (payload.view === "2.5D") newState.pitch = 45;
184
+ replace(newState);
185
+ });
186
+ const unsubSetZoom = cameraBus.on(CameraEventTypes.setZoom, ({ payload }) => {
187
+ if (payload.id !== mapId) return;
188
+ replace({
189
+ ...get(),
190
+ zoom: payload.zoom
191
+ });
192
+ });
193
+ const unsubSetRotation = cameraBus.on(CameraEventTypes.setRotation, ({ payload }) => {
194
+ if (payload.id !== mapId) return;
195
+ const state = get();
196
+ if (state.view !== "3D") replace({
197
+ ...state,
198
+ rotation: payload.rotation
199
+ });
200
+ });
201
+ const unsubSetPitch = cameraBus.on(CameraEventTypes.setPitch, ({ payload }) => {
202
+ if (payload.id !== mapId) return;
203
+ const state = get();
204
+ if (state.view === "2.5D") replace({
205
+ ...state,
206
+ pitch: payload.pitch
207
+ });
208
+ });
209
+ return () => {
210
+ unsubReset();
211
+ unsubSetCenter();
212
+ unsubFitBounds();
213
+ unsubSetProjection();
214
+ unsubSetView();
215
+ unsubSetZoom();
216
+ unsubSetRotation();
217
+ unsubSetPitch();
218
+ };
219
+ },
220
+ onCleanup: (mapId) => {
221
+ initializedInstances.delete(mapId);
222
+ initialStateCache.delete(mapId);
223
+ }
224
+ });
225
+ /**
226
+ * Initialize camera state for a map instance with optional initial values.
227
+ * Should be called before using the camera store for a given mapId.
228
+ *
229
+ * @param mapId - Unique identifier for the map instance
230
+ * @param initialState - Optional initial camera state
231
+ */
232
+ function initializeCameraState(mapId, initialState) {
233
+ if (initializedInstances.has(mapId)) return;
234
+ initializedInstances.add(mapId);
235
+ if (initialState) initialStateCache.set(mapId, initialState);
236
+ const builtState = buildCameraState(initialState);
237
+ cameraStore.set(mapId, builtState);
238
+ }
239
+ /**
240
+ * Hook to subscribe to camera state changes for a specific map.
241
+ *
242
+ * @param mapId - Unique identifier for the map instance
243
+ * @param initialCameraState - Optional initial camera state (only used on first call)
244
+ * @returns Camera state and setCameraState action
245
+ *
246
+ * @example
247
+ * ```tsx
248
+ * function MapInfo({ mapId }) {
249
+ * const { cameraState, setCameraState } = useMapCamera(mapId);
250
+ * return (
251
+ * <div>
252
+ * Lat: {cameraState.latitude.toFixed(2)}, Lon: {cameraState.longitude.toFixed(2)}
253
+ * </div>
254
+ * );
255
+ * }
256
+ * ```
257
+ */
258
+ function useMapCamera(mapId, initialCameraState) {
259
+ if (initialCameraState && !initializedInstances.has(mapId)) initializeCameraState(mapId, initialCameraState);
260
+ const { state, setCameraState } = cameraStore.use(mapId);
261
+ return {
262
+ cameraState: state,
263
+ setCameraState
264
+ };
265
+ }
266
+ /**
267
+ * Manually clear camera state for a specific map instance.
268
+ *
269
+ * @param mapId - The unique identifier for the map instance to clear
270
+ */
271
+ function clearCameraState(mapId) {
272
+ initializedInstances.delete(mapId);
273
+ initialStateCache.delete(mapId);
274
+ cameraStore.clear(mapId);
275
+ }
276
+
277
+ //#endregion
278
+ export { cameraStore, clearCameraState, initializeCameraState, useMapCamera };
279
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","names":["DEFAULT_CAMERA_STATE: CameraState"],"sources":["../../src/camera/store.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Camera Store\n *\n * Manages camera state (position, zoom, pitch, rotation, projection, view) per map instance.\n * State is updated via bus events or direct actions.\n *\n * @example\n * ```tsx\n * import { cameraStore } from '@accelint/map-toolkit/camera';\n *\n * function MapInfo({ mapId }) {\n * const { state } = cameraStore.use(mapId);\n * return (\n * <div>\n * Lat: {state.latitude.toFixed(2)}, Lon: {state.longitude.toFixed(2)}\n * </div>\n * );\n * }\n * ```\n */\n\nimport { Broadcast } from '@accelint/bus';\nimport { fitBounds } from '@math.gl/web-mercator';\nimport { createMapStore } from '../shared/create-map-store';\nimport { CameraEventTypes } from './events';\nimport type { UniqueId } from '@accelint/core';\nimport type { CameraEvent, ProjectionType, ViewType } from './types';\n\nconst cameraBus = Broadcast.getInstance<CameraEvent>();\n\n/**\n * Camera state for 2D view\n */\ntype CameraState2D = {\n latitude: number;\n longitude: number;\n zoom: number;\n pitch: 0;\n rotation: number;\n projection: 'mercator';\n view: '2D';\n};\n\n/**\n * Camera state for 3D view\n */\ntype CameraState3D = {\n latitude: number;\n longitude: number;\n zoom: number;\n pitch: 0;\n rotation: number;\n projection: 'globe';\n view: '3D';\n};\n\n/**\n * Camera state for 2.5D view\n */\ntype CameraState2Point5D = {\n latitude: number;\n longitude: number;\n zoom: number;\n pitch: number;\n rotation: number;\n projection: 'mercator';\n view: '2.5D';\n};\n\n/**\n * Union type for all camera states\n */\nexport type CameraState = CameraState2D | CameraState3D | CameraState2Point5D;\n\n/**\n * Actions for camera management\n */\ntype CameraActions = {\n /** Update camera state directly */\n setCameraState: (state: Partial<CameraState>) => void;\n};\n\n/**\n * Storage for initial camera state per instance.\n * Used for reset operations to restore to initial values.\n *\n * @internal These caches live outside the store factory because reset operations\n * need access to the original initial values. They are cleaned up via `onCleanup`\n * hook when the store instance is destroyed, and via `clearCameraState()` for\n * manual cleanup. Do NOT use `cameraStore.clear()` directly in tests - use\n * `clearCameraState()` instead to ensure proper cleanup.\n */\nconst initialStateCache = new Map<UniqueId, CameraStateInput>();\n\n/**\n * Track which instances have been initialized.\n * @internal See note on initialStateCache about cleanup.\n */\nconst initializedInstances = new Set<UniqueId>();\n\n/**\n * Input type for building camera state - simpler than union type\n */\ntype CameraStateInput = {\n latitude?: number;\n longitude?: number;\n zoom?: number;\n pitch?: number;\n rotation?: number;\n projection?: ProjectionType;\n view?: ViewType;\n};\n\n/**\n * Build a complete camera state from partial input.\n * Returns the appropriate discriminated union variant based on view/projection.\n */\nfunction buildCameraState(partial?: CameraStateInput): CameraState {\n const latitude = partial?.latitude ?? 0;\n const longitude = partial?.longitude ?? 0;\n const zoom = partial?.zoom ?? 0;\n const rotation = partial?.rotation ?? 0;\n\n // Determine which variant to build based on view/projection\n const is3D = partial?.view === '3D' || partial?.projection === 'globe';\n const is2Point5D = partial?.view === '2.5D';\n\n if (is3D) {\n // 3D view: globe projection, no pitch, no rotation\n return {\n latitude,\n longitude,\n zoom,\n pitch: 0,\n rotation: 0,\n projection: 'globe',\n view: '3D',\n } satisfies CameraState3D;\n }\n\n if (is2Point5D) {\n // 2.5D view: mercator projection, variable pitch\n return {\n latitude,\n longitude,\n zoom,\n pitch: partial?.pitch ?? 45,\n rotation,\n projection: 'mercator',\n view: '2.5D',\n } satisfies CameraState2Point5D;\n }\n\n // Default: 2D view, mercator projection, no pitch\n return {\n latitude,\n longitude,\n zoom,\n pitch: 0,\n rotation,\n projection: 'mercator',\n view: '2D',\n } satisfies CameraState2D;\n}\n\n/**\n * Default camera state\n */\nconst DEFAULT_CAMERA_STATE: CameraState = {\n latitude: 0,\n longitude: 0,\n zoom: 0,\n pitch: 0,\n rotation: 0,\n projection: 'mercator',\n view: '2D',\n};\n\n/**\n * Camera store instance\n */\nexport const cameraStore = createMapStore<CameraState, CameraActions>({\n defaultState: DEFAULT_CAMERA_STATE,\n\n actions: (_mapId, { get, replace }) => ({\n setCameraState: (updates: Partial<CameraState>) => {\n const currentState = get();\n // Use buildCameraState to ensure proper discriminated union type\n replace(buildCameraState({ ...currentState, ...updates }));\n },\n }),\n\n bus: (mapId, { get, replace }) => {\n const unsubReset = cameraBus.on(CameraEventTypes.reset, ({ payload }) => {\n if (payload.id !== mapId) {\n return;\n }\n\n const state = get();\n const initialState = initialStateCache.get(mapId);\n const newState = buildCameraState({\n latitude: state.latitude,\n longitude: state.longitude,\n projection: state.projection,\n view: state.view,\n zoom: payload.zoom === false ? state.zoom : (initialState?.zoom ?? 0),\n pitch:\n payload.pitch === false ? state.pitch : (initialState?.pitch ?? 0),\n rotation:\n payload.rotation === false\n ? state.rotation\n : (initialState?.rotation ?? 0),\n });\n\n replace(newState);\n });\n\n const unsubSetCenter = cameraBus.on(\n CameraEventTypes.setCenter,\n ({ payload }) => {\n if (payload.id !== mapId) {\n return;\n }\n\n const state = get();\n replace(\n buildCameraState({\n ...state,\n latitude: payload.latitude,\n longitude: payload.longitude,\n zoom: payload.zoom ?? state.zoom,\n rotation: payload.heading ?? state.rotation,\n pitch: payload.pitch ?? state.pitch,\n }),\n );\n },\n );\n\n const unsubFitBounds = cameraBus.on(\n CameraEventTypes.fitBounds,\n ({ payload }) => {\n if (payload.id !== mapId) {\n return;\n }\n\n const state = get();\n const { longitude, latitude, zoom } = fitBounds({\n width: payload.width,\n height: payload.height,\n bounds: [\n [payload.bounds[0], payload.bounds[1]],\n [payload.bounds[2], payload.bounds[3]],\n ],\n padding: payload.padding,\n });\n\n replace(\n buildCameraState({\n ...state,\n latitude,\n longitude,\n zoom,\n rotation: payload.heading ?? state.rotation,\n pitch: payload.pitch ?? state.pitch,\n }),\n );\n },\n );\n\n const unsubSetProjection = cameraBus.on(\n CameraEventTypes.setProjection,\n ({ payload }) => {\n if (payload.id !== mapId) {\n return;\n }\n\n const state = get();\n const newState = { ...state };\n newState.projection = payload.projection;\n if (payload.projection === 'globe') {\n newState.view = '3D';\n } else {\n newState.view = '2D';\n newState.pitch = 0;\n }\n replace(newState);\n },\n );\n\n const unsubSetView = cameraBus.on(\n CameraEventTypes.setView,\n ({ payload }) => {\n if (payload.id !== mapId) {\n return;\n }\n\n const state = get();\n const newState = { ...state };\n newState.view = payload.view;\n if (payload.view === '3D') {\n newState.projection = 'globe';\n newState.pitch = 0;\n } else {\n newState.projection = 'mercator';\n }\n\n if (payload.view === '2.5D') {\n newState.pitch = 45;\n }\n replace(newState);\n },\n );\n\n const unsubSetZoom = cameraBus.on(\n CameraEventTypes.setZoom,\n ({ payload }) => {\n if (payload.id !== mapId) {\n return;\n }\n\n const state = get();\n replace({ ...state, zoom: payload.zoom });\n },\n );\n\n const unsubSetRotation = cameraBus.on(\n CameraEventTypes.setRotation,\n ({ payload }) => {\n if (payload.id !== mapId) {\n return;\n }\n\n const state = get();\n if (state.view !== '3D') {\n replace({ ...state, rotation: payload.rotation });\n }\n },\n );\n\n const unsubSetPitch = cameraBus.on(\n CameraEventTypes.setPitch,\n ({ payload }) => {\n if (payload.id !== mapId) {\n return;\n }\n\n const state = get();\n if (state.view === '2.5D') {\n replace({ ...state, pitch: payload.pitch });\n }\n },\n );\n\n return () => {\n unsubReset();\n unsubSetCenter();\n unsubFitBounds();\n unsubSetProjection();\n unsubSetView();\n unsubSetZoom();\n unsubSetRotation();\n unsubSetPitch();\n };\n },\n\n onCleanup: (mapId) => {\n initializedInstances.delete(mapId);\n initialStateCache.delete(mapId);\n },\n});\n\n// =============================================================================\n// Convenience exports\n// =============================================================================\n\n/**\n * Initialize camera state for a map instance with optional initial values.\n * Should be called before using the camera store for a given mapId.\n *\n * @param mapId - Unique identifier for the map instance\n * @param initialState - Optional initial camera state\n */\nexport function initializeCameraState(\n mapId: UniqueId,\n initialState?: CameraStateInput,\n): void {\n if (initializedInstances.has(mapId)) {\n return; // Already initialized\n }\n\n initializedInstances.add(mapId);\n if (initialState) {\n initialStateCache.set(mapId, initialState);\n }\n const builtState = buildCameraState(initialState);\n cameraStore.set(mapId, builtState);\n}\n\n/**\n * Hook to subscribe to camera state changes for a specific map.\n *\n * @param mapId - Unique identifier for the map instance\n * @param initialCameraState - Optional initial camera state (only used on first call)\n * @returns Camera state and setCameraState action\n *\n * @example\n * ```tsx\n * function MapInfo({ mapId }) {\n * const { cameraState, setCameraState } = useMapCamera(mapId);\n * return (\n * <div>\n * Lat: {cameraState.latitude.toFixed(2)}, Lon: {cameraState.longitude.toFixed(2)}\n * </div>\n * );\n * }\n * ```\n */\nexport function useMapCamera(\n mapId: UniqueId,\n initialCameraState?: CameraStateInput,\n): {\n cameraState: CameraState;\n setCameraState: (state: Partial<CameraState>) => void;\n} {\n // Initialize on first use if initial state provided\n if (initialCameraState && !initializedInstances.has(mapId)) {\n initializeCameraState(mapId, initialCameraState);\n }\n\n const { state, setCameraState } = cameraStore.use(mapId);\n\n return { cameraState: state, setCameraState };\n}\n\n/**\n * Manually clear camera state for a specific map instance.\n *\n * @param mapId - The unique identifier for the map instance to clear\n */\nexport function clearCameraState(mapId: UniqueId): void {\n initializedInstances.delete(mapId);\n initialStateCache.delete(mapId);\n cameraStore.clear(mapId);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAM,YAAY,UAAU,aAA0B;;;;;;;;;;;AAgEtD,MAAM,oCAAoB,IAAI,KAAiC;;;;;AAM/D,MAAM,uC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,IAAI,MAAM,CACxD,uBAAsB,OAAO,mBAAmB;CAGlD,MAAM,EAAE,OAAO,mBAAmB,YAAY,IAAI,MAAM;AAExD,QAAO;EAAE,aAAa;EAAO;EAAgB;;;;;;;AAQ/C,SAAgB,iBAAiB,OAAuB;AACtD,sBAAqB,OAAO,MAAM;AAClC,mBAAkB,OAAO,MAAM;AAC/B,aAAY,MAAM,MAAM"}
@@ -10,5 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { CoordinateFormatTypes, clearCursorCoordinateState, useCursorCoordinates } from "./use-cursor-coordinates.js";
14
- export { type CoordinateFormatTypes, clearCursorCoordinateState, useCursorCoordinates };
13
+ import { CoordinateFormatTypes, CoordinateFormatter, CursorCoordinateState, RawCoordinate, UseCursorCoordinatesOptions, UseCursorCoordinatesReturn } from "./types.js";
14
+ import { clearCursorCoordinateState, cursorCoordinateStore } from "./store.js";
15
+ import { useCursorCoordinates } from "./use-cursor-coordinates.js";
16
+ export { type CoordinateFormatTypes, type CoordinateFormatter, type CursorCoordinateState, type RawCoordinate, type UseCursorCoordinatesOptions, type UseCursorCoordinatesReturn, clearCursorCoordinateState, cursorCoordinateStore, useCursorCoordinates };
@@ -11,6 +11,7 @@
11
11
  */
12
12
 
13
13
 
14
- import { clearCursorCoordinateState, useCursorCoordinates } from "./use-cursor-coordinates.js";
14
+ import { clearCursorCoordinateState, cursorCoordinateStore } from "./store.js";
15
+ import { useCursorCoordinates } from "./use-cursor-coordinates.js";
15
16
 
16
- export { clearCursorCoordinateState, useCursorCoordinates };
17
+ export { clearCursorCoordinateState, cursorCoordinateStore, useCursorCoordinates };
@@ -0,0 +1,48 @@
1
+ /*
2
+ * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at https://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ import { MapStore } from "../shared/create-map-store.js";
14
+ import { CoordinateFormatTypes, CursorCoordinateState } from "./types.js";
15
+ import { UniqueId } from "@accelint/core";
16
+
17
+ //#region src/cursor-coordinates/store.d.ts
18
+ /**
19
+ * Actions for cursor coordinate management
20
+ */
21
+ type CursorCoordinateActions = {
22
+ /** Set the coordinate display format */
23
+ setFormat: (format: CoordinateFormatTypes) => void;
24
+ };
25
+ /**
26
+ * Cursor coordinates store
27
+ *
28
+ * Stores the current cursor position and display format for each map instance.
29
+ * Automatically subscribes to hover events when first React subscriber mounts.
30
+ */
31
+ declare const cursorCoordinateStore: MapStore<CursorCoordinateState, CursorCoordinateActions>;
32
+ /**
33
+ * Clear cursor coordinate state for a specific map instance.
34
+ * This is typically not needed as cleanup happens automatically when all subscribers unmount.
35
+ * Use this only in advanced scenarios where manual cleanup is required.
36
+ *
37
+ * @param instanceId - The unique identifier for the map to clear
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * // Manual cleanup (rarely needed)
42
+ * clearCursorCoordinateState('my-map-instance');
43
+ * ```
44
+ */
45
+ declare function clearCursorCoordinateState(instanceId: UniqueId): void;
46
+ //#endregion
47
+ export { clearCursorCoordinateState, cursorCoordinateStore };
48
+ //# sourceMappingURL=store.d.ts.map