@accelint/map-toolkit 0.1.0 → 0.3.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 (77) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/README.md +91 -18
  3. package/catalog-info.yaml +16 -10
  4. package/dist/cursor-coordinates/index.d.ts +3 -0
  5. package/dist/cursor-coordinates/index.js +3 -0
  6. package/dist/cursor-coordinates/index.js.map +1 -0
  7. package/dist/cursor-coordinates/use-cursor-coordinates.d.ts +76 -0
  8. package/dist/cursor-coordinates/use-cursor-coordinates.js +161 -0
  9. package/dist/cursor-coordinates/use-cursor-coordinates.js.map +1 -0
  10. package/dist/deckgl/base-map/events.d.ts +1 -0
  11. package/dist/deckgl/base-map/events.js +2 -1
  12. package/dist/deckgl/base-map/events.js.map +1 -1
  13. package/dist/deckgl/base-map/index.d.ts +91 -8
  14. package/dist/deckgl/base-map/index.js +93 -33
  15. package/dist/deckgl/base-map/index.js.map +1 -1
  16. package/dist/deckgl/base-map/provider.d.ts +129 -0
  17. package/dist/deckgl/base-map/provider.js +18 -0
  18. package/dist/deckgl/base-map/provider.js.map +1 -0
  19. package/dist/deckgl/base-map/types.d.ts +64 -3
  20. package/dist/deckgl/index.d.ts +3 -2
  21. package/dist/deckgl/index.js +1 -1
  22. package/dist/deckgl/text-layer/character-sets.d.ts +27 -0
  23. package/dist/deckgl/text-layer/character-sets.js +36 -0
  24. package/dist/deckgl/text-layer/character-sets.js.map +1 -0
  25. package/dist/deckgl/text-layer/default-settings.d.ts +5 -0
  26. package/dist/deckgl/text-layer/default-settings.js +23 -0
  27. package/dist/deckgl/text-layer/default-settings.js.map +1 -0
  28. package/dist/deckgl/text-layer/fiber.d.ts +31 -0
  29. package/dist/deckgl/text-layer/fiber.js +6 -0
  30. package/dist/deckgl/text-layer/fiber.js.map +1 -0
  31. package/dist/deckgl/text-layer/index.d.ts +43 -0
  32. package/dist/deckgl/text-layer/index.js +33 -0
  33. package/dist/deckgl/text-layer/index.js.map +1 -0
  34. package/dist/decorators/deckgl.d.ts +1 -1
  35. package/dist/decorators/deckgl.js +3 -1
  36. package/dist/decorators/deckgl.js.map +1 -1
  37. package/dist/map-mode/events.d.ts +37 -0
  38. package/dist/map-mode/events.js +15 -0
  39. package/dist/map-mode/events.js.map +1 -0
  40. package/dist/map-mode/index.d.ts +6 -0
  41. package/dist/map-mode/index.js +5 -0
  42. package/dist/map-mode/index.js.map +1 -0
  43. package/dist/map-mode/store.d.ts +48 -0
  44. package/dist/map-mode/store.js +306 -0
  45. package/dist/map-mode/store.js.map +1 -0
  46. package/dist/map-mode/types.d.ts +83 -0
  47. package/dist/map-mode/types.js +3 -0
  48. package/dist/map-mode/types.js.map +1 -0
  49. package/dist/map-mode/use-map-mode.d.ts +52 -0
  50. package/dist/map-mode/use-map-mode.js +29 -0
  51. package/dist/map-mode/use-map-mode.js.map +1 -0
  52. package/dist/maplibre/hooks/use-maplibre.d.ts +34 -0
  53. package/dist/maplibre/hooks/use-maplibre.js +3 -2
  54. package/dist/maplibre/hooks/use-maplibre.js.map +1 -1
  55. package/dist/metafile-esm.json +1 -1
  56. package/dist/viewport/constants.d.ts +9 -0
  57. package/dist/viewport/constants.js +11 -0
  58. package/dist/viewport/constants.js.map +1 -0
  59. package/dist/viewport/index.d.ts +13 -0
  60. package/dist/viewport/index.js +6 -0
  61. package/dist/viewport/index.js.map +1 -0
  62. package/dist/viewport/types.d.ts +22 -0
  63. package/dist/viewport/types.js +3 -0
  64. package/dist/viewport/types.js.map +1 -0
  65. package/dist/viewport/use-viewport-state.d.ts +85 -0
  66. package/dist/viewport/use-viewport-state.js +109 -0
  67. package/dist/viewport/use-viewport-state.js.map +1 -0
  68. package/dist/viewport/utils.d.ts +37 -0
  69. package/dist/viewport/utils.js +46 -0
  70. package/dist/viewport/utils.js.map +1 -0
  71. package/dist/viewport/viewport-size.d.ts +42 -0
  72. package/dist/viewport/viewport-size.js +16 -0
  73. package/dist/viewport/viewport-size.js.map +1 -0
  74. package/package.json +48 -46
  75. package/dist/test/setup.d.ts +0 -2
  76. package/dist/test/setup.js +0 -11
  77. package/dist/test/setup.js.map +0 -1
@@ -1 +1 @@
1
- {"inputs":{"src/deckgl/index.ts":{"bytes":1028,"imports":[],"format":"esm"},"src/decorators/deckgl.tsx":{"bytes":938,"imports":[],"format":"esm"},"src/maplibre/constants.ts":{"bytes":819,"imports":[],"format":"esm"},"src/maplibre/index.ts":{"bytes":750,"imports":[],"format":"esm"},"src/test/setup.ts":{"bytes":959,"imports":[],"format":"esm"},"src/deckgl/base-map/constants.ts":{"bytes":1129,"imports":[],"format":"esm"},"src/deckgl/base-map/events.ts":{"bytes":809,"imports":[],"format":"esm"},"src/deckgl/base-map/index.tsx":{"bytes":3886,"imports":[],"format":"esm"},"src/deckgl/base-map/types.ts":{"bytes":1829,"imports":[],"format":"esm"},"src/deckgl/symbol-layer/fiber.ts":{"bytes":1020,"imports":[],"format":"esm"},"src/deckgl/symbol-layer/index.ts":{"bytes":4786,"imports":[],"format":"esm"},"src/maplibre/hooks/use-maplibre.ts":{"bytes":1799,"imports":[],"format":"esm"}},"outputs":{"dist/deckgl/base-map/types.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/deckgl/base-map/types.js":{"imports":[],"exports":[],"entryPoint":"src/deckgl/base-map/types.ts","inputs":{"src/deckgl/base-map/types.ts":{"bytesInOutput":0}},"bytes":0},"dist/deckgl/symbol-layer/fiber.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1248},"dist/deckgl/symbol-layer/fiber.js":{"imports":[{"path":"@deckgl-fiber-renderer/dom","kind":"import-statement","external":true},{"path":"./index","kind":"import-statement","external":true}],"exports":[],"entryPoint":"src/deckgl/symbol-layer/fiber.ts","inputs":{"src/deckgl/symbol-layer/fiber.ts":{"bytesInOutput":117}},"bytes":117},"dist/deckgl/symbol-layer/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6569},"dist/deckgl/symbol-layer/index.js":{"imports":[{"path":"@deck.gl/layers","kind":"import-statement","external":true},{"path":"milsymbol","kind":"import-statement","external":true}],"exports":["SymbolLayer"],"entryPoint":"src/deckgl/symbol-layer/index.ts","inputs":{"src/deckgl/symbol-layer/index.ts":{"bytesInOutput":2593}},"bytes":2619},"dist/maplibre/hooks/use-maplibre.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":2654},"dist/maplibre/hooks/use-maplibre.js":{"imports":[{"path":"maplibre-gl","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["useMapLibre"],"entryPoint":"src/maplibre/hooks/use-maplibre.ts","inputs":{"src/maplibre/hooks/use-maplibre.ts":{"bytesInOutput":873}},"bytes":899},"dist/deckgl/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1276},"dist/deckgl/index.js":{"imports":[{"path":"./base-map","kind":"import-statement","external":true},{"path":"./base-map/constants","kind":"import-statement","external":true},{"path":"./base-map/events","kind":"import-statement","external":true},{"path":"./symbol-layer","kind":"import-statement","external":true}],"exports":["BASE_MAP_STYLE","BaseMap","MapEvents","MapEventsNamespace","PARAMETERS","SymbolLayer","bus"],"entryPoint":"src/deckgl/index.ts","inputs":{"src/deckgl/index.ts":{"bytesInOutput":227}},"bytes":338},"dist/decorators/deckgl.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1224},"dist/decorators/deckgl.js":{"imports":[{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"../deckgl/base-map","kind":"import-statement","external":true}],"exports":["withDeckGL"],"entryPoint":"src/decorators/deckgl.tsx","inputs":{"src/decorators/deckgl.tsx":{"bytesInOutput":257}},"bytes":282},"dist/maplibre/constants.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1102},"dist/maplibre/constants.js":{"imports":[],"exports":["INITIAL_VIEW_STATE"],"entryPoint":"src/maplibre/constants.ts","inputs":{"src/maplibre/constants.ts":{"bytesInOutput":141}},"bytes":174},"dist/maplibre/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":927},"dist/maplibre/index.js":{"imports":[{"path":"./constants","kind":"import-statement","external":true},{"path":"./hooks/use-maplibre","kind":"import-statement","external":true}],"exports":["INITIAL_VIEW_STATE","useMapLibre"],"entryPoint":"src/maplibre/index.ts","inputs":{"src/maplibre/index.ts":{"bytesInOutput":102}},"bytes":150},"dist/test/setup.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1237},"dist/test/setup.js":{"imports":[{"path":"@testing-library/jest-dom/matchers","kind":"import-statement","external":true},{"path":"@testing-library/react","kind":"import-statement","external":true},{"path":"vitest","kind":"import-statement","external":true}],"exports":[],"entryPoint":"src/test/setup.ts","inputs":{"src/test/setup.ts":{"bytesInOutput":258}},"bytes":258},"dist/deckgl/base-map/constants.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1523},"dist/deckgl/base-map/constants.js":{"imports":[],"exports":["BASE_MAP_STYLE","PARAMETERS"],"entryPoint":"src/deckgl/base-map/constants.ts","inputs":{"src/deckgl/base-map/constants.ts":{"bytesInOutput":442}},"bytes":485},"dist/deckgl/base-map/events.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1061},"dist/deckgl/base-map/events.js":{"imports":[],"exports":["MapEvents","MapEventsNamespace"],"entryPoint":"src/deckgl/base-map/events.ts","inputs":{"src/deckgl/base-map/events.ts":{"bytesInOutput":136}},"bytes":182},"dist/deckgl/base-map/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":5591},"dist/deckgl/base-map/index.js":{"imports":[{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"client-only","kind":"import-statement","external":true},{"path":"@accelint/bus","kind":"import-statement","external":true},{"path":"@accelint/bus/react","kind":"import-statement","external":true},{"path":"@deckgl-fiber-renderer/dom","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"../../maplibre/constants","kind":"import-statement","external":true},{"path":"../../maplibre/hooks/use-maplibre","kind":"import-statement","external":true},{"path":"./constants","kind":"import-statement","external":true},{"path":"./events","kind":"import-statement","external":true}],"exports":["BaseMap","bus"],"entryPoint":"src/deckgl/base-map/index.tsx","inputs":{"src/deckgl/base-map/index.tsx":{"bytesInOutput":2332}},"bytes":2375}}}
1
+ {"inputs":{"src/cursor-coordinates/index.ts":{"bytes":1035,"imports":[],"format":"esm"},"src/cursor-coordinates/use-cursor-coordinates.ts":{"bytes":13198,"imports":[],"format":"esm"},"src/deckgl/index.ts":{"bytes":1037,"imports":[],"format":"esm"},"src/decorators/deckgl.tsx":{"bytes":1101,"imports":[],"format":"esm"},"src/maplibre/constants.ts":{"bytes":819,"imports":[],"format":"esm"},"src/maplibre/index.ts":{"bytes":750,"imports":[],"format":"esm"},"src/viewport/constants.ts":{"bytes":773,"imports":[],"format":"esm"},"src/viewport/index.tsx":{"bytes":1012,"imports":[],"format":"esm"},"src/viewport/types.ts":{"bytes":1120,"imports":[],"format":"esm"},"src/viewport/use-viewport-state.ts":{"bytes":9491,"imports":[],"format":"esm"},"src/viewport/utils.ts":{"bytes":3891,"imports":[],"format":"esm"},"src/viewport/viewport-size.tsx":{"bytes":2070,"imports":[],"format":"esm"},"src/map-mode/events.ts":{"bytes":1961,"imports":[],"format":"esm"},"src/map-mode/index.ts":{"bytes":1117,"imports":[],"format":"esm"},"src/map-mode/store.ts":{"bytes":17572,"imports":[],"format":"esm"},"src/map-mode/types.ts":{"bytes":3586,"imports":[],"format":"esm"},"src/map-mode/use-map-mode.ts":{"bytes":3222,"imports":[],"format":"esm"},"src/deckgl/base-map/constants.ts":{"bytes":1129,"imports":[],"format":"esm"},"src/deckgl/base-map/events.ts":{"bytes":855,"imports":[],"format":"esm"},"src/deckgl/base-map/index.tsx":{"bytes":9952,"imports":[],"format":"esm"},"src/deckgl/base-map/provider.tsx":{"bytes":6192,"imports":[],"format":"esm"},"src/deckgl/base-map/types.ts":{"bytes":4067,"imports":[],"format":"esm"},"src/deckgl/symbol-layer/fiber.ts":{"bytes":1020,"imports":[],"format":"esm"},"src/deckgl/symbol-layer/index.ts":{"bytes":4786,"imports":[],"format":"esm"},"src/deckgl/text-layer/character-sets.ts":{"bytes":2340,"imports":[],"format":"esm"},"src/deckgl/text-layer/default-settings.ts":{"bytes":1222,"imports":[],"format":"esm"},"src/deckgl/text-layer/fiber.ts":{"bytes":1516,"imports":[],"format":"esm"},"src/deckgl/text-layer/index.ts":{"bytes":2455,"imports":[],"format":"esm"},"src/maplibre/hooks/use-maplibre.ts":{"bytes":3030,"imports":[],"format":"esm"}},"outputs":{"dist/deckgl/text-layer/character-sets.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3553},"dist/deckgl/text-layer/character-sets.js":{"imports":[],"exports":["CHARACTER_SETS"],"entryPoint":"src/deckgl/text-layer/character-sets.ts","inputs":{"src/deckgl/text-layer/character-sets.ts":{"bytesInOutput":1507}},"bytes":1536},"dist/deckgl/text-layer/default-settings.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1736},"dist/deckgl/text-layer/default-settings.js":{"imports":[],"exports":["defaultSettings"],"entryPoint":"src/deckgl/text-layer/default-settings.ts","inputs":{"src/deckgl/text-layer/default-settings.ts":{"bytesInOutput":389}},"bytes":419},"dist/deckgl/text-layer/fiber.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1761},"dist/deckgl/text-layer/fiber.js":{"imports":[{"path":"@deckgl-fiber-renderer/dom","kind":"import-statement","external":true},{"path":"./index","kind":"import-statement","external":true}],"exports":[],"entryPoint":"src/deckgl/text-layer/fiber.ts","inputs":{"src/deckgl/text-layer/fiber.ts":{"bytesInOutput":113}},"bytes":113},"dist/deckgl/text-layer/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3088},"dist/deckgl/text-layer/index.js":{"imports":[{"path":"@deck.gl/layers","kind":"import-statement","external":true},{"path":"./character-sets.js","kind":"import-statement","external":true},{"path":"./default-settings.js","kind":"import-statement","external":true}],"exports":["TextLayer"],"entryPoint":"src/deckgl/text-layer/index.ts","inputs":{"src/deckgl/text-layer/index.ts":{"bytesInOutput":832}},"bytes":856},"dist/maplibre/hooks/use-maplibre.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3948},"dist/maplibre/hooks/use-maplibre.js":{"imports":[{"path":"maplibre-gl","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["useMapLibre"],"entryPoint":"src/maplibre/hooks/use-maplibre.ts","inputs":{"src/maplibre/hooks/use-maplibre.ts":{"bytesInOutput":913}},"bytes":939},"dist/map-mode/use-map-mode.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3877},"dist/map-mode/use-map-mode.js":{"imports":[{"path":"client-only","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"../deckgl/base-map/provider","kind":"import-statement","external":true},{"path":"./store","kind":"import-statement","external":true}],"exports":["useMapMode"],"entryPoint":"src/map-mode/use-map-mode.ts","inputs":{"src/map-mode/use-map-mode.ts":{"bytesInOutput":756}},"bytes":795},"dist/deckgl/base-map/constants.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1523},"dist/deckgl/base-map/constants.js":{"imports":[],"exports":["BASE_MAP_STYLE","PARAMETERS"],"entryPoint":"src/deckgl/base-map/constants.ts","inputs":{"src/deckgl/base-map/constants.ts":{"bytesInOutput":442}},"bytes":485},"dist/deckgl/base-map/events.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1136},"dist/deckgl/base-map/events.js":{"imports":[],"exports":["MapEvents","MapEventsNamespace"],"entryPoint":"src/deckgl/base-map/events.ts","inputs":{"src/deckgl/base-map/events.ts":{"bytesInOutput":182}},"bytes":228},"dist/deckgl/base-map/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":12983},"dist/deckgl/base-map/index.js":{"imports":[{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"client-only","kind":"import-statement","external":true},{"path":"@accelint/bus/react","kind":"import-statement","external":true},{"path":"@deckgl-fiber-renderer/dom","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"../../maplibre/constants","kind":"import-statement","external":true},{"path":"../../maplibre/hooks/use-maplibre","kind":"import-statement","external":true},{"path":"./constants","kind":"import-statement","external":true},{"path":"./events","kind":"import-statement","external":true},{"path":"./provider","kind":"import-statement","external":true}],"exports":["BaseMap"],"entryPoint":"src/deckgl/base-map/index.tsx","inputs":{"src/deckgl/base-map/index.tsx":{"bytesInOutput":3979}},"bytes":4015},"dist/deckgl/base-map/provider.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6757},"dist/deckgl/base-map/provider.js":{"imports":[{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"client-only","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"../../map-mode/store","kind":"import-statement","external":true}],"exports":["MapContext","MapProvider"],"entryPoint":"src/deckgl/base-map/provider.tsx","inputs":{"src/deckgl/base-map/provider.tsx":{"bytesInOutput":417}},"bytes":471},"dist/deckgl/base-map/types.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/deckgl/base-map/types.js":{"imports":[],"exports":[],"entryPoint":"src/deckgl/base-map/types.ts","inputs":{"src/deckgl/base-map/types.ts":{"bytesInOutput":0}},"bytes":0},"dist/deckgl/symbol-layer/fiber.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1248},"dist/deckgl/symbol-layer/fiber.js":{"imports":[{"path":"@deckgl-fiber-renderer/dom","kind":"import-statement","external":true},{"path":"./index","kind":"import-statement","external":true}],"exports":[],"entryPoint":"src/deckgl/symbol-layer/fiber.ts","inputs":{"src/deckgl/symbol-layer/fiber.ts":{"bytesInOutput":117}},"bytes":117},"dist/deckgl/symbol-layer/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6569},"dist/deckgl/symbol-layer/index.js":{"imports":[{"path":"@deck.gl/layers","kind":"import-statement","external":true},{"path":"milsymbol","kind":"import-statement","external":true}],"exports":["SymbolLayer"],"entryPoint":"src/deckgl/symbol-layer/index.ts","inputs":{"src/deckgl/symbol-layer/index.ts":{"bytesInOutput":2593}},"bytes":2619},"dist/viewport/types.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/viewport/types.js":{"imports":[],"exports":[],"entryPoint":"src/viewport/types.ts","inputs":{"src/viewport/types.ts":{"bytesInOutput":0}},"bytes":0},"dist/viewport/use-viewport-state.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":12064},"dist/viewport/use-viewport-state.js":{"imports":[{"path":"@accelint/bus","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"../deckgl/base-map/events","kind":"import-statement","external":true}],"exports":["clearViewportState","useViewportState"],"entryPoint":"src/viewport/use-viewport-state.ts","inputs":{"src/viewport/use-viewport-state.ts":{"bytesInOutput":3400}},"bytes":3453},"dist/viewport/utils.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":5100},"dist/viewport/utils.js":{"imports":[{"path":"./constants","kind":"import-statement","external":true}],"exports":["getViewportSize"],"entryPoint":"src/viewport/utils.ts","inputs":{"src/viewport/utils.ts":{"bytesInOutput":1401}},"bytes":1431},"dist/viewport/viewport-size.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":2534},"dist/viewport/viewport-size.js":{"imports":[{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"./use-viewport-state","kind":"import-statement","external":true},{"path":"./utils","kind":"import-statement","external":true}],"exports":["ViewportSize"],"entryPoint":"src/viewport/viewport-size.tsx","inputs":{"src/viewport/viewport-size.tsx":{"bytesInOutput":404}},"bytes":431},"dist/map-mode/events.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":2316},"dist/map-mode/events.js":{"imports":[],"exports":["MapModeEvents","MapModeEventsNamespace"],"entryPoint":"src/map-mode/events.ts","inputs":{"src/map-mode/events.ts":{"bytesInOutput":570}},"bytes":624},"dist/map-mode/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1336},"dist/map-mode/index.js":{"imports":[{"path":"./events","kind":"import-statement","external":true},{"path":"./store","kind":"import-statement","external":true},{"path":"./use-map-mode","kind":"import-statement","external":true}],"exports":["MapModeEvents","MapModeEventsNamespace","clearMapModeState","getCurrentModeOwner","useMapMode"],"entryPoint":"src/map-mode/index.ts","inputs":{"src/map-mode/index.ts":{"bytesInOutput":177}},"bytes":289},"dist/map-mode/store.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":24245},"dist/map-mode/store.js":{"imports":[{"path":"@accelint/bus","kind":"import-statement","external":true},{"path":"@accelint/core","kind":"import-statement","external":true},{"path":"./events","kind":"import-statement","external":true}],"exports":["clearMapModeState","getCurrentModeOwner","getOrCreateRequestModeChange","getOrCreateSnapshot","getOrCreateSubscription"],"entryPoint":"src/map-mode/store.ts","inputs":{"src/map-mode/store.ts":{"bytesInOutput":9557}},"bytes":9694},"dist/map-mode/types.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/map-mode/types.js":{"imports":[],"exports":[],"entryPoint":"src/map-mode/types.ts","inputs":{"src/map-mode/types.ts":{"bytesInOutput":0}},"bytes":0},"dist/cursor-coordinates/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1234},"dist/cursor-coordinates/index.js":{"imports":[{"path":"./use-cursor-coordinates","kind":"import-statement","external":true}],"exports":["clearCursorCoordinateState","useCursorCoordinates"],"entryPoint":"src/cursor-coordinates/index.ts","inputs":{"src/cursor-coordinates/index.ts":{"bytesInOutput":97}},"bytes":162},"dist/cursor-coordinates/use-cursor-coordinates.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":17042},"dist/cursor-coordinates/use-cursor-coordinates.js":{"imports":[{"path":"client-only","kind":"import-statement","external":true},{"path":"@accelint/bus","kind":"import-statement","external":true},{"path":"@accelint/geo","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"../deckgl/base-map/events","kind":"import-statement","external":true},{"path":"../deckgl/base-map/provider","kind":"import-statement","external":true}],"exports":["clearCursorCoordinateState","useCursorCoordinates"],"entryPoint":"src/cursor-coordinates/use-cursor-coordinates.ts","inputs":{"src/cursor-coordinates/use-cursor-coordinates.ts":{"bytesInOutput":5069}},"bytes":5148},"dist/deckgl/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1268},"dist/deckgl/index.js":{"imports":[{"path":"./base-map","kind":"import-statement","external":true},{"path":"./base-map/constants","kind":"import-statement","external":true},{"path":"./base-map/events","kind":"import-statement","external":true},{"path":"./symbol-layer","kind":"import-statement","external":true}],"exports":["BASE_MAP_STYLE","BaseMap","MapEvents","MapEventsNamespace","PARAMETERS","SymbolLayer"],"entryPoint":"src/deckgl/index.ts","inputs":{"src/deckgl/index.ts":{"bytesInOutput":218}},"bytes":322},"dist/decorators/deckgl.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1441},"dist/decorators/deckgl.js":{"imports":[{"path":"react/jsx-runtime","kind":"import-statement","external":true},{"path":"@accelint/core","kind":"import-statement","external":true},{"path":"../deckgl/base-map","kind":"import-statement","external":true}],"exports":["withDeckGL"],"entryPoint":"src/decorators/deckgl.tsx","inputs":{"src/decorators/deckgl.tsx":{"bytesInOutput":351}},"bytes":376},"dist/maplibre/constants.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1102},"dist/maplibre/constants.js":{"imports":[],"exports":["INITIAL_VIEW_STATE"],"entryPoint":"src/maplibre/constants.ts","inputs":{"src/maplibre/constants.ts":{"bytesInOutput":141}},"bytes":174},"dist/maplibre/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":927},"dist/maplibre/index.js":{"imports":[{"path":"./constants","kind":"import-statement","external":true},{"path":"./hooks/use-maplibre","kind":"import-statement","external":true}],"exports":["INITIAL_VIEW_STATE","useMapLibre"],"entryPoint":"src/maplibre/index.ts","inputs":{"src/maplibre/index.ts":{"bytesInOutput":102}},"bytes":150},"dist/viewport/constants.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1020},"dist/viewport/constants.js":{"imports":[],"exports":["UNIT_MAP"],"entryPoint":"src/viewport/constants.ts","inputs":{"src/viewport/constants.ts":{"bytesInOutput":108}},"bytes":131},"dist/viewport/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1254},"dist/viewport/index.js":{"imports":[{"path":"./constants","kind":"import-statement","external":true},{"path":"./use-viewport-state","kind":"import-statement","external":true},{"path":"./utils","kind":"import-statement","external":true},{"path":"./viewport-size","kind":"import-statement","external":true}],"exports":["UNIT_MAP","ViewportSize","clearViewportState","getViewportSize","useViewportState"],"entryPoint":"src/viewport/index.tsx","inputs":{"src/viewport/index.tsx":{"bytesInOutput":212}},"bytes":312}}}
@@ -0,0 +1,9 @@
1
+ declare const UNIT_MAP: {
2
+ readonly km: "kilometers";
3
+ readonly m: "meters";
4
+ readonly nm: "nauticalmiles";
5
+ readonly mi: "miles";
6
+ readonly ft: "feet";
7
+ };
8
+
9
+ export { UNIT_MAP };
@@ -0,0 +1,11 @@
1
+ const UNIT_MAP = {
2
+ km: "kilometers",
3
+ m: "meters",
4
+ nm: "nauticalmiles",
5
+ mi: "miles",
6
+ ft: "feet"
7
+ };
8
+
9
+ export { UNIT_MAP };
10
+ //# sourceMappingURL=constants.js.map
11
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/viewport/constants.ts"],"names":[],"mappings":"AAYO,MAAM,QAAA,GAAW;AAAA,EACtB,EAAA,EAAI,YAAA;AAAA,EACJ,CAAA,EAAG,QAAA;AAAA,EACH,EAAA,EAAI,eAAA;AAAA,EACJ,EAAA,EAAI,OAAA;AAAA,EACJ,EAAA,EAAI;AACN","file":"constants.js","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 UNIT_MAP = {\n km: 'kilometers',\n m: 'meters',\n nm: 'nauticalmiles',\n mi: 'miles',\n ft: 'feet',\n} as const;\n"]}
@@ -0,0 +1,13 @@
1
+ export { UNIT_MAP } from './constants.js';
2
+ export { UseViewportStateProps, clearViewportState, useViewportState } from './use-viewport-state.js';
3
+ export { getViewportSize } from './utils.js';
4
+ export { ViewportSize, ViewportSizeProps } from './viewport-size.js';
5
+ export { GeoCoordinate, GetViewportSizeArgs, SupportedDistanceUnit } from './types.js';
6
+ import 'react';
7
+ import '@accelint/core';
8
+ import '../deckgl/base-map/types.js';
9
+ import '@accelint/bus';
10
+ import '@deck.gl/core';
11
+ import 'mjolnir.js';
12
+ import '../deckgl/base-map/events.js';
13
+ import 'react/jsx-runtime';
@@ -0,0 +1,6 @@
1
+ export { UNIT_MAP } from './constants.js';
2
+ export { clearViewportState, useViewportState } from './use-viewport-state.js';
3
+ export { getViewportSize } from './utils.js';
4
+ export { ViewportSize } from './viewport-size.js';
5
+ //# sourceMappingURL=index.js.map
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
@@ -0,0 +1,22 @@
1
+ import { Bounds } from '../deckgl/base-map/types.js';
2
+ import { UNIT_MAP } from './constants.js';
3
+ import '@accelint/bus';
4
+ import '@accelint/core';
5
+ import '@deck.gl/core';
6
+ import 'mjolnir.js';
7
+ import '../deckgl/base-map/events.js';
8
+
9
+ type SupportedDistanceUnit = keyof typeof UNIT_MAP;
10
+ type GetViewportSizeArgs = {
11
+ bounds: Bounds;
12
+ zoom: number;
13
+ /** Viewport width in pixels */
14
+ width: number;
15
+ /** Viewport height in pixels */
16
+ height: number;
17
+ unit?: SupportedDistanceUnit;
18
+ formatter?: Intl.NumberFormat;
19
+ };
20
+ type GeoCoordinate = [longitude: number, latitude: number];
21
+
22
+ export type { GeoCoordinate, GetViewportSizeArgs, SupportedDistanceUnit };
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=types.js.map
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"types.js"}
@@ -0,0 +1,85 @@
1
+ import { useSyncExternalStore } from 'react';
2
+ import { UniqueId } from '@accelint/core';
3
+ import { MapViewportPayload } from '../deckgl/base-map/types.js';
4
+ import '@accelint/bus';
5
+ import '@deck.gl/core';
6
+ import 'mjolnir.js';
7
+ import '../deckgl/base-map/events.js';
8
+
9
+ type UseViewportStateProps = {
10
+ instanceId: UniqueId;
11
+ subscribe?: Parameters<typeof useSyncExternalStore<MapViewportPayload>>[0];
12
+ getSnapshot?: Parameters<typeof useSyncExternalStore<MapViewportPayload>>[1];
13
+ getServerSnapshot?: Parameters<typeof useSyncExternalStore<MapViewportPayload>>[2];
14
+ };
15
+ /**
16
+ * Hook to subscribe to viewport state changes for a specific view.
17
+ *
18
+ * By default, subscribes to MapEvents.viewport events from the event bus and
19
+ * automatically cleans up when all subscribers unmount. For advanced use cases,
20
+ * custom subscribe/getSnapshot functions can be provided.
21
+ *
22
+ * A thin wrapper around [useSyncExternalStore](https://react.dev/reference/react/useSyncExternalStore).
23
+ *
24
+ * @param instanceId - Unique identifier for the viewport to track
25
+ * @param subscribe - Optional custom subscription function
26
+ * @param getSnapshot - Optional custom snapshot getter
27
+ * @param getServerSnapshot - Optional server-side snapshot getter
28
+ * @returns Current viewport state including bounds, latitude, longitude, zoom
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * function MapInfo({ instanceId }) {
33
+ * const { bounds, latitude, longitude, zoom } = useViewportState({
34
+ * instanceId
35
+ * });
36
+ *
37
+ * return (
38
+ * <div>
39
+ * Lat: {latitude?.toFixed(2)}, Lon: {longitude?.toFixed(2)}, Zoom: {zoom}
40
+ * </div>
41
+ * );
42
+ * }
43
+ * ```
44
+ *
45
+ * @example
46
+ * ```tsx
47
+ * // With custom subscribe/getSnapshot for advanced use cases
48
+ * function CustomMapInfo() {
49
+ * const customSubscribe = (onStoreChange) => {
50
+ * // Custom subscription logic
51
+ * return () => { // cleanup }
52
+ * }
53
+ *
54
+ * const customGetSnapshot = () => {
55
+ * // Custom snapshot logic
56
+ * return { latitude: 0, longitude: 0, zoom: 1 };
57
+ * };
58
+ *
59
+ * const viewState = useViewportState({
60
+ * instanceId: 'some-uuid',
61
+ * subscribe: customSubscribe,
62
+ * getSnapshot: customGetSnapshot,
63
+ * });
64
+ *
65
+ * return <div>Custom viewport state</div>;
66
+ * }
67
+ * ```
68
+ */
69
+ declare function useViewportState({ instanceId, subscribe, getSnapshot, getServerSnapshot, }: UseViewportStateProps): MapViewportPayload;
70
+ /**
71
+ * Manually clear viewport state for a specific instanceId.
72
+ * This is typically not needed as cleanup happens automatically when all subscribers unmount.
73
+ * Use this only in advanced scenarios where manual cleanup is required.
74
+ *
75
+ * @param instanceId - The unique identifier for the viewport to clear
76
+ *
77
+ * @example
78
+ * ```tsx
79
+ * // Manual cleanup (rarely needed)
80
+ * clearViewportState('my-map-instance');
81
+ * ```
82
+ */
83
+ declare function clearViewportState(instanceId: UniqueId): void;
84
+
85
+ export { type UseViewportStateProps, clearViewportState, useViewportState };
@@ -0,0 +1,109 @@
1
+ import { Broadcast } from '@accelint/bus';
2
+ import { useSyncExternalStore } from 'react';
3
+ import { MapEvents } from '../deckgl/base-map/events.js';
4
+
5
+ const bus = Broadcast.getInstance();
6
+ const viewportStore = /* @__PURE__ */ new Map();
7
+ const componentSubscribers = /* @__PURE__ */ new Map();
8
+ const busUnsubscribers = /* @__PURE__ */ new Map();
9
+ const subscriptionCache = /* @__PURE__ */ new Map();
10
+ const snapshotCache = /* @__PURE__ */ new Map();
11
+ const fallbackCache = /* @__PURE__ */ new Map();
12
+ function ensureBusListener(instanceId) {
13
+ if (busUnsubscribers.has(instanceId)) {
14
+ return;
15
+ }
16
+ const unsub = bus.on(MapEvents.viewport, ({ payload }) => {
17
+ if (instanceId === payload.id) {
18
+ viewportStore.set(instanceId, payload);
19
+ const subscribers = componentSubscribers.get(instanceId);
20
+ if (subscribers) {
21
+ for (const onStoreChange of subscribers) {
22
+ onStoreChange();
23
+ }
24
+ }
25
+ }
26
+ });
27
+ busUnsubscribers.set(instanceId, unsub);
28
+ }
29
+ function cleanupBusListenerIfNeeded(instanceId) {
30
+ const subscribers = componentSubscribers.get(instanceId);
31
+ if (!subscribers || subscribers.size === 0) {
32
+ const unsub = busUnsubscribers.get(instanceId);
33
+ if (unsub) {
34
+ unsub();
35
+ busUnsubscribers.delete(instanceId);
36
+ }
37
+ viewportStore.delete(instanceId);
38
+ componentSubscribers.delete(instanceId);
39
+ subscriptionCache.delete(instanceId);
40
+ snapshotCache.delete(instanceId);
41
+ fallbackCache.delete(instanceId);
42
+ }
43
+ }
44
+ function getOrCreateSubscription(instanceId) {
45
+ const subscription = subscriptionCache.get(instanceId) ?? ((onStoreChange) => {
46
+ ensureBusListener(instanceId);
47
+ let subscriberSet = componentSubscribers.get(instanceId);
48
+ if (!subscriberSet) {
49
+ subscriberSet = /* @__PURE__ */ new Set();
50
+ componentSubscribers.set(instanceId, subscriberSet);
51
+ }
52
+ subscriberSet.add(onStoreChange);
53
+ return () => {
54
+ const currentSubscriberSet = componentSubscribers.get(instanceId);
55
+ if (currentSubscriberSet) {
56
+ currentSubscriberSet.delete(onStoreChange);
57
+ }
58
+ cleanupBusListenerIfNeeded(instanceId);
59
+ };
60
+ });
61
+ subscriptionCache.set(instanceId, subscription);
62
+ return subscription;
63
+ }
64
+ function getOrCreateSnapshot(instanceId) {
65
+ const fallback = fallbackCache.get(instanceId) ?? (() => {
66
+ const newFallback = {
67
+ id: instanceId,
68
+ bounds: [Number.NaN, Number.NaN, Number.NaN, Number.NaN],
69
+ latitude: Number.NaN,
70
+ longitude: Number.NaN,
71
+ zoom: Number.NaN,
72
+ width: 0,
73
+ height: 0
74
+ };
75
+ fallbackCache.set(instanceId, newFallback);
76
+ return newFallback;
77
+ })();
78
+ const snapshot = snapshotCache.get(instanceId) ?? (() => viewportStore.get(instanceId) ?? fallback);
79
+ snapshotCache.set(instanceId, snapshot);
80
+ return snapshot;
81
+ }
82
+ function useViewportState({
83
+ instanceId,
84
+ subscribe,
85
+ getSnapshot,
86
+ getServerSnapshot
87
+ }) {
88
+ return useSyncExternalStore(
89
+ subscribe ?? getOrCreateSubscription(instanceId),
90
+ getSnapshot ?? getOrCreateSnapshot(instanceId),
91
+ getServerSnapshot
92
+ );
93
+ }
94
+ function clearViewportState(instanceId) {
95
+ const unsub = busUnsubscribers.get(instanceId);
96
+ if (unsub) {
97
+ unsub();
98
+ busUnsubscribers.delete(instanceId);
99
+ }
100
+ viewportStore.delete(instanceId);
101
+ componentSubscribers.delete(instanceId);
102
+ subscriptionCache.delete(instanceId);
103
+ snapshotCache.delete(instanceId);
104
+ fallbackCache.delete(instanceId);
105
+ }
106
+
107
+ export { clearViewportState, useViewportState };
108
+ //# sourceMappingURL=use-viewport-state.js.map
109
+ //# sourceMappingURL=use-viewport-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/viewport/use-viewport-state.ts"],"names":[],"mappings":"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","file":"use-viewport-state.js","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\nimport { Broadcast } from '@accelint/bus';\nimport { useSyncExternalStore } from 'react';\nimport { MapEvents } from '../deckgl/base-map/events';\nimport type { UniqueId } from '@accelint/core';\nimport type {\n MapEventType,\n MapViewportPayload,\n} from '../deckgl/base-map/types';\n\nconst bus = Broadcast.getInstance<MapEventType>();\n\nexport type UseViewportStateProps = {\n instanceId: UniqueId;\n subscribe?: Parameters<typeof useSyncExternalStore<MapViewportPayload>>[0];\n getSnapshot?: Parameters<typeof useSyncExternalStore<MapViewportPayload>>[1];\n getServerSnapshot?: Parameters<\n typeof useSyncExternalStore<MapViewportPayload>\n >[2];\n};\n\n/**\n * Store for viewport state keyed by instanceId\n */\nconst viewportStore = new Map<UniqueId, MapViewportPayload>();\n\n/**\n * Track React component subscribers per instanceId (for fan-out notifications).\n * Each Set contains onStoreChange callbacks from useSyncExternalStore.\n */\nconst componentSubscribers = new Map<UniqueId, Set<() => void>>();\n\n/**\n * Cache of bus unsubscribe functions (1 per instanceId).\n * This ensures we only have one bus listener per viewport, regardless of\n * how many React components subscribe to it.\n */\nconst busUnsubscribers = new Map<UniqueId, () => void>();\n\ntype Subscription = (onStoreChange: () => void) => () => void;\n/**\n * Cache of subscription functions per instanceId to avoid recreating on every render\n */\nconst subscriptionCache = new Map<UniqueId, Subscription>();\n\n/**\n * Cache of snapshot functions per instanceId to maintain referential stability\n */\nconst snapshotCache = new Map<UniqueId, () => MapViewportPayload>();\n\n/**\n * Cache of fallback snapshots per instanceId to maintain referential stability.\n * This prevents unnecessary re-renders when no viewport data exists yet.\n */\nconst fallbackCache = new Map<UniqueId, MapViewportPayload>();\n\n/**\n * Ensures a single bus listener exists for the given instanceId.\n * All React subscribers will be notified via fan-out when the bus event fires.\n * This prevents creating N bus listeners for N React components.\n *\n * @param instanceId - The unique identifier for the viewport\n */\nfunction ensureBusListener(instanceId: UniqueId): void {\n if (busUnsubscribers.has(instanceId)) {\n return; // Already listening\n }\n\n const unsub = bus.on(MapEvents.viewport, ({ payload }) => {\n if (instanceId === payload.id) {\n // Write to store once\n viewportStore.set(instanceId, payload);\n\n // Fan-out: notify all React subscribers\n const subscribers = componentSubscribers.get(instanceId);\n if (subscribers) {\n for (const onStoreChange of subscribers) {\n onStoreChange();\n }\n }\n }\n });\n\n busUnsubscribers.set(instanceId, unsub);\n}\n\n/**\n * Cleans up the bus listener if no React subscribers remain.\n *\n * @param instanceId - The unique identifier for the viewport\n */\nfunction cleanupBusListenerIfNeeded(instanceId: UniqueId): void {\n const subscribers = componentSubscribers.get(instanceId);\n\n if (!subscribers || subscribers.size === 0) {\n // No more React subscribers - clean up bus listener\n const unsub = busUnsubscribers.get(instanceId);\n if (unsub) {\n unsub();\n busUnsubscribers.delete(instanceId);\n }\n\n // Clean up all state\n viewportStore.delete(instanceId);\n componentSubscribers.delete(instanceId);\n subscriptionCache.delete(instanceId);\n snapshotCache.delete(instanceId);\n fallbackCache.delete(instanceId);\n }\n}\n\n/**\n * Creates or retrieves a cached subscription function for a given instanceId.\n * Uses a fan-out pattern: 1 bus listener -> N React subscribers.\n * Automatically cleans up viewport state when the last subscriber unsubscribes.\n *\n * @param instanceId - The unique identifier for the viewport\n * @returns A subscription function for useSyncExternalStore\n */\nfunction getOrCreateSubscription(\n instanceId: UniqueId,\n): (onStoreChange: () => void) => () => void {\n const subscription =\n subscriptionCache.get(instanceId) ??\n ((onStoreChange: () => void) => {\n // Ensure single bus listener exists for this instanceId\n ensureBusListener(instanceId);\n\n // Get or create the subscriber set for this map instance, then add this component's callback\n let subscriberSet = componentSubscribers.get(instanceId);\n if (!subscriberSet) {\n subscriberSet = new Set();\n componentSubscribers.set(instanceId, subscriberSet);\n }\n subscriberSet.add(onStoreChange);\n\n // Return cleanup function to remove this component's subscription\n return () => {\n const currentSubscriberSet = componentSubscribers.get(instanceId);\n if (currentSubscriberSet) {\n currentSubscriberSet.delete(onStoreChange);\n }\n\n // Clean up bus listener if this was the last React subscriber\n cleanupBusListenerIfNeeded(instanceId);\n };\n });\n\n subscriptionCache.set(instanceId, subscription);\n\n return subscription;\n}\n\n/**\n * Creates or retrieves a cached snapshot function for a given instanceId.\n * The object returned gets equality checked, so it needs to be stable or React re-renders unnecessarily.\n *\n * @param instanceId - The unique identifier for the viewport\n * @returns A snapshot function for useSyncExternalStore\n */\nfunction getOrCreateSnapshot(instanceId: UniqueId): () => MapViewportPayload {\n // Get or create stable fallback reference for this instanceId\n const fallback =\n fallbackCache.get(instanceId) ??\n (() => {\n const newFallback: MapViewportPayload = {\n id: instanceId,\n bounds: [Number.NaN, Number.NaN, Number.NaN, Number.NaN],\n latitude: Number.NaN,\n longitude: Number.NaN,\n zoom: Number.NaN,\n width: 0,\n height: 0,\n };\n fallbackCache.set(instanceId, newFallback);\n return newFallback;\n })();\n\n const snapshot =\n snapshotCache.get(instanceId) ??\n (() => viewportStore.get(instanceId) ?? fallback);\n\n snapshotCache.set(instanceId, snapshot);\n\n return snapshot;\n}\n\n/**\n * Hook to subscribe to viewport state changes for a specific view.\n *\n * By default, subscribes to MapEvents.viewport events from the event bus and\n * automatically cleans up when all subscribers unmount. For advanced use cases,\n * custom subscribe/getSnapshot functions can be provided.\n *\n * A thin wrapper around [useSyncExternalStore](https://react.dev/reference/react/useSyncExternalStore).\n *\n * @param instanceId - Unique identifier for the viewport to track\n * @param subscribe - Optional custom subscription function\n * @param getSnapshot - Optional custom snapshot getter\n * @param getServerSnapshot - Optional server-side snapshot getter\n * @returns Current viewport state including bounds, latitude, longitude, zoom\n *\n * @example\n * ```tsx\n * function MapInfo({ instanceId }) {\n * const { bounds, latitude, longitude, zoom } = useViewportState({\n * instanceId\n * });\n *\n * return (\n * <div>\n * Lat: {latitude?.toFixed(2)}, Lon: {longitude?.toFixed(2)}, Zoom: {zoom}\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With custom subscribe/getSnapshot for advanced use cases\n * function CustomMapInfo() {\n * const customSubscribe = (onStoreChange) => {\n * // Custom subscription logic\n * return () => { // cleanup }\n * }\n *\n * const customGetSnapshot = () => {\n * // Custom snapshot logic\n * return { latitude: 0, longitude: 0, zoom: 1 };\n * };\n *\n * const viewState = useViewportState({\n * instanceId: 'some-uuid',\n * subscribe: customSubscribe,\n * getSnapshot: customGetSnapshot,\n * });\n *\n * return <div>Custom viewport state</div>;\n * }\n * ```\n */\nexport function useViewportState({\n instanceId,\n subscribe,\n getSnapshot,\n getServerSnapshot,\n}: UseViewportStateProps) {\n return useSyncExternalStore<MapViewportPayload>(\n subscribe ?? getOrCreateSubscription(instanceId),\n getSnapshot ?? getOrCreateSnapshot(instanceId),\n getServerSnapshot,\n );\n}\n\n/**\n * Manually clear viewport state for a specific instanceId.\n * This is typically not needed as cleanup happens automatically when all subscribers unmount.\n * Use this only in advanced scenarios where manual cleanup is required.\n *\n * @param instanceId - The unique identifier for the viewport to clear\n *\n * @example\n * ```tsx\n * // Manual cleanup (rarely needed)\n * clearViewportState('my-map-instance');\n * ```\n */\nexport function clearViewportState(instanceId: UniqueId): void {\n // Unsubscribe from bus if listening\n const unsub = busUnsubscribers.get(instanceId);\n if (unsub) {\n unsub();\n busUnsubscribers.delete(instanceId);\n }\n\n // Clear all state\n viewportStore.delete(instanceId);\n componentSubscribers.delete(instanceId);\n subscriptionCache.delete(instanceId);\n snapshotCache.delete(instanceId);\n fallbackCache.delete(instanceId);\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import { GetViewportSizeArgs } from './types.js';
2
+ import '../deckgl/base-map/types.js';
3
+ import '@accelint/bus';
4
+ import '@accelint/core';
5
+ import '@deck.gl/core';
6
+ import 'mjolnir.js';
7
+ import '../deckgl/base-map/events.js';
8
+ import './constants.js';
9
+
10
+ /**
11
+ * Returns a formatted viewport size string i.e. `660 x 1,801 NM`
12
+ *
13
+ * Calculates the geographic distance of the viewport using zoom level and
14
+ * pixel dimensions with the Web Mercator projection formula. This approach
15
+ * provides stable results without the edge cases of bounds-based calculations.
16
+ *
17
+ * @param args - Viewport size calculation arguments
18
+ * @param args.bounds - Geographic bounds [minLon, minLat, maxLon, maxLat]
19
+ * @param args.zoom - Zoom level for meters-per-pixel calculation
20
+ * @param args.width - Viewport width in pixels
21
+ * @param args.height - Viewport height in pixels
22
+ * @param args.unit - Unit of distance measurement: `km | m | nm | mi | ft`. Defaults to `nm`
23
+ * @param args.formatter - Number formatter for localization (defaults to en-US)
24
+ * @returns Formatted string like "660 x 1,801 NM" or "-- x -- NM" if invalid
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * getViewportSize({ bounds: [-82, 22, -71, 52], zoom: 5, width: 800, height: 600, unit: 'nm' })
29
+ * // returns "612 x 459 NM"
30
+ *
31
+ * getViewportSize({ bounds: [170, 50, -170, 60], zoom: 4, width: 1024, height: 768, unit: 'km' })
32
+ * // returns "2,050 x 1,538 KM"
33
+ * ```
34
+ */
35
+ declare function getViewportSize({ bounds, zoom, width: pixelWidth, height: pixelHeight, unit, formatter, }: GetViewportSizeArgs): string;
36
+
37
+ export { getViewportSize };
@@ -0,0 +1,46 @@
1
+ import { UNIT_MAP } from './constants.js';
2
+
3
+ const numberFormatter = Intl.NumberFormat("en-US");
4
+ const METERS_PER_PIXEL_AT_ZOOM_0 = 156543.03392;
5
+ const METERS_TO_UNIT = {
6
+ kilometers: 1e-3,
7
+ meters: 1,
8
+ nauticalmiles: 539957e-9,
9
+ miles: 621371e-9,
10
+ feet: 3.28084
11
+ };
12
+ function getViewportSize({
13
+ bounds,
14
+ zoom,
15
+ width: pixelWidth,
16
+ height: pixelHeight,
17
+ unit = "nm",
18
+ formatter = numberFormatter
19
+ }) {
20
+ const defaultValue = `-- x -- ${unit.toUpperCase()}`;
21
+ if (bounds.every((b) => Number.isNaN(b))) {
22
+ return defaultValue;
23
+ }
24
+ if (Number.isNaN(zoom) || pixelWidth === 0 || pixelHeight === 0) {
25
+ return defaultValue;
26
+ }
27
+ const [, minLat, , maxLat] = bounds;
28
+ if (minLat < -90 || minLat > 90 || maxLat < -90 || maxLat > 90) {
29
+ return defaultValue;
30
+ }
31
+ const centerLat = (minLat + maxLat) / 2;
32
+ const metersPerPixel = METERS_PER_PIXEL_AT_ZOOM_0 * Math.cos(centerLat * Math.PI / 180) / 2 ** zoom;
33
+ const widthMeters = pixelWidth * metersPerPixel;
34
+ const heightMeters = pixelHeight * metersPerPixel;
35
+ const unitKey = UNIT_MAP[unit];
36
+ const conversionFactor = METERS_TO_UNIT[unitKey];
37
+ const widthDistance = Math.round(widthMeters * conversionFactor);
38
+ const heightDistance = Math.round(heightMeters * conversionFactor);
39
+ const width = formatter.format(widthDistance);
40
+ const height = formatter.format(heightDistance);
41
+ return `${width} x ${height} ${unit.toUpperCase()}`;
42
+ }
43
+
44
+ export { getViewportSize };
45
+ //# sourceMappingURL=utils.js.map
46
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/viewport/utils.ts"],"names":[],"mappings":";;AAeA,MAAM,eAAA,GAAkB,IAAA,CAAK,YAAA,CAAa,OAAO,CAAA;AAMjD,MAAM,0BAAA,GAA6B,YAAA;AAKnC,MAAM,cAAA,GAAiB;AAAA,EACrB,UAAA,EAAY,IAAA;AAAA,EACZ,MAAA,EAAQ,CAAA;AAAA,EACR,aAAA,EAAe,SAAA;AAAA,EACf,KAAA,EAAO,SAAA;AAAA,EACP,IAAA,EAAM;AACR,CAAA;AA2BO,SAAS,eAAA,CAAgB;AAAA,EAC9B,MAAA;AAAA,EACA,IAAA;AAAA,EACA,KAAA,EAAO,UAAA;AAAA,EACP,MAAA,EAAQ,WAAA;AAAA,EACR,IAAA,GAAO,IAAA;AAAA,EACP,SAAA,GAAY;AACd,CAAA,EAAwB;AACtB,EAAA,MAAM,YAAA,GAAe,CAAA,QAAA,EAAW,IAAA,CAAK,WAAA,EAAa,CAAA,CAAA;AAGlD,EAAA,IAAI,MAAA,CAAO,MAAM,CAAC,CAAA,KAAM,OAAO,KAAA,CAAM,CAAC,CAAC,CAAA,EAAG;AACxC,IAAA,OAAO,YAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAO,KAAA,CAAM,IAAI,KAAK,UAAA,KAAe,CAAA,IAAK,gBAAgB,CAAA,EAAG;AAC/D,IAAA,OAAO,YAAA;AAAA,EACT;AAEA,EAAA,MAAM,GAAG,MAAA,IAAU,MAAM,CAAA,GAAI,MAAA;AAG7B,EAAA,IAAI,SAAS,GAAA,IAAO,MAAA,GAAS,MAAM,MAAA,GAAS,GAAA,IAAO,SAAS,EAAA,EAAI;AAC9D,IAAA,OAAO,YAAA;AAAA,EACT;AAGA,EAAA,MAAM,SAAA,GAAA,CAAa,SAAS,MAAA,IAAU,CAAA;AAItC,EAAA,MAAM,cAAA,GACH,6BAA6B,IAAA,CAAK,GAAA,CAAK,YAAY,IAAA,CAAK,EAAA,GAAM,GAAG,CAAA,GAClE,CAAA,IAAK,IAAA;AAGP,EAAA,MAAM,cAAc,UAAA,GAAa,cAAA;AACjC,EAAA,MAAM,eAAe,WAAA,GAAc,cAAA;AAGnC,EAAA,MAAM,OAAA,GAAU,SAAS,IAAI,CAAA;AAC7B,EAAA,MAAM,gBAAA,GAAmB,eAAe,OAAO,CAAA;AAE/C,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,KAAA,CAAM,WAAA,GAAc,gBAAgB,CAAA;AAC/D,EAAA,MAAM,cAAA,GAAiB,IAAA,CAAK,KAAA,CAAM,YAAA,GAAe,gBAAgB,CAAA;AAEjE,EAAA,MAAM,KAAA,GAAQ,SAAA,CAAU,MAAA,CAAO,aAAa,CAAA;AAC5C,EAAA,MAAM,MAAA,GAAS,SAAA,CAAU,MAAA,CAAO,cAAc,CAAA;AAE9C,EAAA,OAAO,GAAG,KAAK,CAAA,GAAA,EAAM,MAAM,CAAA,CAAA,EAAI,IAAA,CAAK,aAAa,CAAA,CAAA;AACnD","file":"utils.js","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\nimport { UNIT_MAP } from './constants';\nimport type { GetViewportSizeArgs } from './types';\n\nconst numberFormatter = Intl.NumberFormat('en-US');\n\n/**\n * Web Mercator constant: meters per pixel at zoom 0, equator.\n * This is Earth's circumference (40075016.686m) divided by 256 (tile size).\n */\nconst METERS_PER_PIXEL_AT_ZOOM_0 = 156543.03392;\n\n/**\n * Unit conversion factors from meters.\n */\nconst METERS_TO_UNIT = {\n kilometers: 0.001,\n meters: 1,\n nauticalmiles: 0.000539957,\n miles: 0.000621371,\n feet: 3.28084,\n} as const;\n\n/**\n * Returns a formatted viewport size string i.e. `660 x 1,801 NM`\n *\n * Calculates the geographic distance of the viewport using zoom level and\n * pixel dimensions with the Web Mercator projection formula. This approach\n * provides stable results without the edge cases of bounds-based calculations.\n *\n * @param args - Viewport size calculation arguments\n * @param args.bounds - Geographic bounds [minLon, minLat, maxLon, maxLat]\n * @param args.zoom - Zoom level for meters-per-pixel calculation\n * @param args.width - Viewport width in pixels\n * @param args.height - Viewport height in pixels\n * @param args.unit - Unit of distance measurement: `km | m | nm | mi | ft`. Defaults to `nm`\n * @param args.formatter - Number formatter for localization (defaults to en-US)\n * @returns Formatted string like \"660 x 1,801 NM\" or \"-- x -- NM\" if invalid\n *\n * @example\n * ```typescript\n * getViewportSize({ bounds: [-82, 22, -71, 52], zoom: 5, width: 800, height: 600, unit: 'nm' })\n * // returns \"612 x 459 NM\"\n *\n * getViewportSize({ bounds: [170, 50, -170, 60], zoom: 4, width: 1024, height: 768, unit: 'km' })\n * // returns \"2,050 x 1,538 KM\"\n * ```\n */\nexport function getViewportSize({\n bounds,\n zoom,\n width: pixelWidth,\n height: pixelHeight,\n unit = 'nm',\n formatter = numberFormatter,\n}: GetViewportSizeArgs) {\n const defaultValue = `-- x -- ${unit.toUpperCase()}`;\n\n // Validate inputs\n if (bounds.every((b) => Number.isNaN(b))) {\n return defaultValue;\n }\n\n if (Number.isNaN(zoom) || pixelWidth === 0 || pixelHeight === 0) {\n return defaultValue;\n }\n\n const [, minLat, , maxLat] = bounds;\n\n // Validate latitude bounds are within valid geographic ranges\n if (minLat < -90 || minLat > 90 || maxLat < -90 || maxLat > 90) {\n return defaultValue;\n }\n\n // Calculate center latitude for the viewport\n const centerLat = (minLat + maxLat) / 2;\n\n // Web Mercator formula: meters per pixel at given zoom and latitude\n // Resolution = 156543.03392 * cos(latitude * π/180) / 2^zoom\n const metersPerPixel =\n (METERS_PER_PIXEL_AT_ZOOM_0 * Math.cos((centerLat * Math.PI) / 180)) /\n 2 ** zoom;\n\n // Calculate distances in meters\n const widthMeters = pixelWidth * metersPerPixel;\n const heightMeters = pixelHeight * metersPerPixel;\n\n // Convert to requested unit\n const unitKey = UNIT_MAP[unit] as keyof typeof METERS_TO_UNIT;\n const conversionFactor = METERS_TO_UNIT[unitKey];\n\n const widthDistance = Math.round(widthMeters * conversionFactor);\n const heightDistance = Math.round(heightMeters * conversionFactor);\n\n const width = formatter.format(widthDistance);\n const height = formatter.format(heightDistance);\n\n return `${width} x ${height} ${unit.toUpperCase()}`;\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { UniqueId } from '@accelint/core';
3
+ import { ComponentPropsWithRef } from 'react';
4
+ import { SupportedDistanceUnit } from './types.js';
5
+ import '../deckgl/base-map/types.js';
6
+ import '@accelint/bus';
7
+ import '@deck.gl/core';
8
+ import 'mjolnir.js';
9
+ import '../deckgl/base-map/events.js';
10
+ import './constants.js';
11
+
12
+ type ViewportSizeProps = ComponentPropsWithRef<'span'> & {
13
+ instanceId: UniqueId;
14
+ unit?: SupportedDistanceUnit;
15
+ };
16
+ /**
17
+ * A span element displaying the current viewport bounds in the specified unit.
18
+ *
19
+ * Displays the viewport dimensions in a format like `660 x 1,801 NM`.
20
+ * Updates automatically as the viewport changes by subscribing to viewport events.
21
+ *
22
+ * @param props - Extends `<span>` props
23
+ * @param props.instanceId - The id of the view to subscribe to
24
+ * @param props.unit - Measure of distance: `km | m | nm | mi | ft`. Defaults to `nm`
25
+ * @param props.className - CSS classes for styling
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * // Basic usage with default nautical miles
30
+ * <ViewportSize instanceId="some-uuid" />
31
+ *
32
+ * // With custom unit and styling
33
+ * <ViewportSize
34
+ * instanceId="some-uuid"
35
+ * unit="km"
36
+ * className="text-sm text-gray-600"
37
+ * />
38
+ * ```
39
+ */
40
+ declare function ViewportSize({ instanceId, unit, ...rest }: ViewportSizeProps): react_jsx_runtime.JSX.Element;
41
+
42
+ export { ViewportSize, type ViewportSizeProps };
@@ -0,0 +1,16 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useViewportState } from './use-viewport-state.js';
3
+ import { getViewportSize } from './utils.js';
4
+
5
+ function ViewportSize({
6
+ instanceId,
7
+ unit = "nm",
8
+ ...rest
9
+ }) {
10
+ const { bounds, zoom, width, height } = useViewportState({ instanceId });
11
+ return /* @__PURE__ */ jsx("span", { ...rest, children: getViewportSize({ bounds, unit, zoom, width, height }) });
12
+ }
13
+
14
+ export { ViewportSize };
15
+ //# sourceMappingURL=viewport-size.js.map
16
+ //# sourceMappingURL=viewport-size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/viewport/viewport-size.tsx"],"names":[],"mappings":";;;;AA+CO,SAAS,YAAA,CAAa;AAAA,EAC3B,UAAA;AAAA,EACA,IAAA,GAAO,IAAA;AAAA,EACP,GAAG;AACL,CAAA,EAAsB;AACpB,EAAA,MAAM,EAAE,QAAQ,IAAA,EAAM,KAAA,EAAO,QAAO,GAAI,gBAAA,CAAiB,EAAE,UAAA,EAAY,CAAA;AAEvE,EAAA,uBACE,GAAA,CAAC,MAAA,EAAA,EAAM,GAAG,IAAA,EACP,QAAA,EAAA,eAAA,CAAgB,EAAE,MAAA,EAAQ,IAAA,EAAM,IAAA,EAAM,KAAA,EAAO,MAAA,EAAQ,CAAA,EACxD,CAAA;AAEJ","file":"viewport-size.js","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\nimport { useViewportState } from './use-viewport-state';\nimport { getViewportSize } from './utils';\nimport type { UniqueId } from '@accelint/core';\nimport type { ComponentPropsWithRef } from 'react';\nimport type { SupportedDistanceUnit } from './types';\n\nexport type ViewportSizeProps = ComponentPropsWithRef<'span'> & {\n instanceId: UniqueId;\n unit?: SupportedDistanceUnit;\n};\n\n/**\n * A span element displaying the current viewport bounds in the specified unit.\n *\n * Displays the viewport dimensions in a format like `660 x 1,801 NM`.\n * Updates automatically as the viewport changes by subscribing to viewport events.\n *\n * @param props - Extends `<span>` props\n * @param props.instanceId - The id of the view to subscribe to\n * @param props.unit - Measure of distance: `km | m | nm | mi | ft`. Defaults to `nm`\n * @param props.className - CSS classes for styling\n *\n * @example\n * ```tsx\n * // Basic usage with default nautical miles\n * <ViewportSize instanceId=\"some-uuid\" />\n *\n * // With custom unit and styling\n * <ViewportSize\n * instanceId=\"some-uuid\"\n * unit=\"km\"\n * className=\"text-sm text-gray-600\"\n * />\n * ```\n */\nexport function ViewportSize({\n instanceId,\n unit = 'nm',\n ...rest\n}: ViewportSizeProps) {\n const { bounds, zoom, width, height } = useViewportState({ instanceId });\n\n return (\n <span {...rest}>\n {getViewportSize({ bounds, unit, zoom, width, height })}\n </span>\n );\n}\n"]}