@twinmatrix/spatialverse-sdk-web 0.0.2 → 0.0.3

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 (125) hide show
  1. package/lib/cjs/index.js +9 -9
  2. package/lib/cjs/index.js.map +1 -1
  3. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +213 -294
  4. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  5. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +43 -45
  6. package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  7. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +241 -271
  8. package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  9. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +167 -215
  10. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  11. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +28 -30
  12. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
  13. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +876 -1188
  14. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  15. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +173 -163
  16. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  17. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js +6 -6
  18. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js.map +1 -1
  19. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +6 -6
  20. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
  21. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js +3 -3
  22. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js.map +1 -1
  23. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +546 -620
  24. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  25. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +155 -160
  26. package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  27. package/lib/cjs/meta-atlas-sdk/customStyles.js +2 -2
  28. package/lib/cjs/meta-atlas-sdk/customStyles.js.map +1 -1
  29. package/lib/cjs/meta-atlas-sdk/customerLayer.js +15 -29
  30. package/lib/cjs/meta-atlas-sdk/customerLayer.js.map +1 -1
  31. package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js +5 -5
  32. package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js.map +1 -1
  33. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +832 -1060
  34. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  35. package/lib/cjs/meta-atlas-sdk/utils/helpers.js +33 -50
  36. package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
  37. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +18 -36
  38. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  39. package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js +6 -6
  40. package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js.map +1 -1
  41. package/lib/cjs/meta-atlas-sdk/utils/routing-store.js +6 -6
  42. package/lib/cjs/meta-atlas-sdk/utils/routing-store.js.map +1 -1
  43. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +428 -556
  44. package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  45. package/lib/cjs/react/MetaAtlasMap.js +127 -0
  46. package/lib/cjs/react/MetaAtlasMap.js.map +1 -0
  47. package/lib/cjs/react/hooks/useDrawing/index.js +17 -18
  48. package/lib/cjs/react/hooks/useDrawing/index.js.map +1 -1
  49. package/lib/cjs/react/hooks/useFocus/index.js +48 -55
  50. package/lib/cjs/react/hooks/useFocus/index.js.map +1 -1
  51. package/lib/cjs/react/hooks/useMapEvents/index.js +40 -50
  52. package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
  53. package/lib/cjs/react/hooks/useMapOverlays/index.js +20 -21
  54. package/lib/cjs/react/hooks/useMapOverlays/index.js.map +1 -1
  55. package/lib/cjs/react/hooks/useMetaAtlas/index.js +77 -95
  56. package/lib/cjs/react/hooks/useMetaAtlas/index.js.map +1 -1
  57. package/lib/cjs/react/hooks/useMetaAtlas.js +78 -96
  58. package/lib/cjs/react/hooks/useMetaAtlas.js.map +1 -1
  59. package/lib/cjs/react/hooks/useRouting/index.js +21 -20
  60. package/lib/cjs/react/hooks/useRouting/index.js.map +1 -1
  61. package/lib/cjs/react/hooks/useSearch/index.js +35 -34
  62. package/lib/cjs/react/hooks/useSearch/index.js.map +1 -1
  63. package/lib/cjs/react/hooks/useStampRally/index.js +30 -29
  64. package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
  65. package/lib/cjs/react/hooks/useStampRally/utils.js +2 -2
  66. package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
  67. package/lib/cjs/react/index.js +31 -31
  68. package/lib/cjs/react/index.js.map +1 -1
  69. package/lib/cjs/react/stores/useMapDataStore.js +53 -64
  70. package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
  71. package/lib/cjs/react/stores/useMetaAtlasStore.js +27 -40
  72. package/lib/cjs/react/stores/useMetaAtlasStore.js.map +1 -1
  73. package/lib/esm/index.js +3 -7
  74. package/lib/esm/index.js.map +1 -1
  75. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +2 -1
  76. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
  77. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +10 -9
  78. package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
  79. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +2 -2
  80. package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
  81. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +3 -3
  82. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
  83. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +4 -3
  84. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
  85. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +22 -14
  86. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
  87. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +8 -8
  88. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
  89. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +3 -3
  90. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
  91. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +18 -11
  92. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
  93. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +4 -3
  94. package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
  95. package/lib/esm/meta-atlas-sdk/customerLayer.js +4 -1
  96. package/lib/esm/meta-atlas-sdk/customerLayer.js.map +1 -1
  97. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +80 -61
  98. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  99. package/lib/esm/meta-atlas-sdk/utils/helpers.js +3 -1
  100. package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
  101. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +19 -15
  102. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  103. package/lib/esm/react/MetaAtlasMap.js +120 -0
  104. package/lib/esm/react/MetaAtlasMap.js.map +1 -0
  105. package/lib/esm/react/hooks/useDrawing/index.js +2 -2
  106. package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
  107. package/lib/esm/react/hooks/useFocus/index.js +4 -3
  108. package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
  109. package/lib/esm/react/hooks/useMapEvents/index.js +3 -3
  110. package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
  111. package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
  112. package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
  113. package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
  114. package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
  115. package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
  116. package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
  117. package/lib/esm/react/hooks/useRouting/index.js +2 -2
  118. package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
  119. package/lib/esm/react/hooks/useSearch/index.js +2 -2
  120. package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
  121. package/lib/esm/react/hooks/useStampRally/index.js +8 -7
  122. package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
  123. package/lib/esm/react/index.js +11 -15
  124. package/lib/esm/react/index.js.map +1 -1
  125. package/package.json +9 -6
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_useMetaAtlas2","require","_useMetaAtlasStore","useFocus","_useMetaAtlas","useMetaAtlas","focusTo","getCurrentFocus","getCurrentFocusBuilding","getCurrentFocusFloor","getFocusTree","mapCoreReady","useMetaAtlasStore","state","getBuildingList","focusTree","site","buildings","buildingsObj","Array","isArray","map","building","name","whereTaxonomy","taxonomyPath","key","push","getLevelList","buildingTaxonomy","levels","targetBuilding","find","floors","floorsObj","floor","getRootSiteCameraProps","platform","arguments","length","undefined","cameraConfigs","config","web","mobile","center","longitude","latitude","zoom","bearing","pitch","isReady"],"sources":["../../../../../src/react/hooks/useFocus/index.ts"],"sourcesContent":["import { useMetaAtlas } from '../useMetaAtlas';\nimport { useMetaAtlasStore } from '../../stores/useMetaAtlasStore';\nimport { UseFocusReturn, BuildingInfo, LevelInfo, CameraProps } from './types';\n\nexport function useFocus(): UseFocusReturn {\n const { focusTo, getCurrentFocus, getCurrentFocusBuilding, getCurrentFocusFloor, getFocusTree } = useMetaAtlas();\n const mapCoreReady = useMetaAtlasStore((state) => state.mapCoreReady);\n\n const getBuildingList = (): BuildingInfo[] => {\n if (!mapCoreReady) {\n return [];\n }\n const focusTree = getFocusTree();\n if (!focusTree || !focusTree.site || !focusTree.site.buildings) {\n return [];\n }\n\n const buildings: BuildingInfo[] = [];\n const buildingsObj: any = focusTree.site.buildings;\n \n // Handle both array and object formats\n if (Array.isArray(buildingsObj)) {\n return buildingsObj.map((building: any) => ({\n name: building.name || '',\n whereTaxonomy: building.taxonomyPath || '',\n }));\n } else {\n // Object format (key-value pairs)\n for (const key in buildingsObj) {\n const building: any = buildingsObj[key];\n if (building && building.taxonomyPath) {\n buildings.push({\n name: building.name || '',\n whereTaxonomy: building.taxonomyPath || '',\n });\n }\n }\n }\n\n return buildings;\n };\n\n const getLevelList = (buildingTaxonomy: string): LevelInfo[] => {\n if (!mapCoreReady) {\n return [];\n }\n const focusTree = getFocusTree();\n if (!focusTree || !focusTree.site || !focusTree.site.buildings) {\n return [];\n }\n\n const levels: LevelInfo[] = [];\n const buildingsObj: any = focusTree.site.buildings;\n \n // Find the building by taxonomy path\n let targetBuilding: any = null;\n \n if (Array.isArray(buildingsObj)) {\n targetBuilding = buildingsObj.find((building: any) => \n building.taxonomyPath === buildingTaxonomy\n );\n } else {\n // Object format (key-value pairs)\n for (const key in buildingsObj) {\n const building: any = buildingsObj[key];\n if (building && building.taxonomyPath === buildingTaxonomy) {\n targetBuilding = building;\n break;\n }\n }\n }\n\n if (!targetBuilding || !targetBuilding.floors) {\n return [];\n }\n\n const floorsObj: any = targetBuilding.floors;\n \n // Handle both array and object formats for floors\n if (Array.isArray(floorsObj)) {\n return floorsObj.map((floor: any) => ({\n name: floor.name || '',\n whereTaxonomy: floor.taxonomyPath || '',\n }));\n } else {\n // Object format (key-value pairs)\n for (const key in floorsObj) {\n const floor: any = floorsObj[key];\n if (floor && floor.taxonomyPath) {\n levels.push({\n name: floor.name || '',\n whereTaxonomy: floor.taxonomyPath || '',\n });\n }\n }\n }\n\n return levels;\n };\n\n const getRootSiteCameraProps = (platform: 'web' | 'mobile' = 'web'): CameraProps | null => {\n const focusTree = getFocusTree();\n if (!focusTree || !focusTree.site || !focusTree.site.cameraConfigs) {\n return null;\n }\n\n const cameraConfigs: any = focusTree.site.cameraConfigs;\n const config = cameraConfigs[platform] || cameraConfigs.web || cameraConfigs.mobile;\n \n if (!config || !config.center || !Array.isArray(config.center) || config.center.length < 2) {\n return null;\n }\n\n return {\n longitude: config.center[0],\n latitude: config.center[1],\n zoom: config.zoom || 0,\n bearing: config.bearing,\n pitch: config.pitch,\n };\n };\n\n return {\n focusTo,\n getCurrentFocus,\n getCurrentFocusBuilding,\n getCurrentFocusFloor,\n getFocusTree,\n getBuildingList,\n getLevelList,\n getRootSiteCameraProps,\n isReady: mapCoreReady, // Use mapCoreReady flag\n };\n}\n\n"],"mappings":";;;;;;AAAA,IA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C1F,OAAO,IAAI;IACb;IAEA,OAAO;MACLO,SAAS,EAAEJ,MAAM,CAACG,MAAM,CAAC,CAAC,CAAC;MAC3BE,QAAQ,EAAEL,MAAM,CAACG,MAAM,CAAC,CAAC,CAAC;MAC1BG,IAAI,EAAEN,MAAM,CAACM,IAAI,IAAI,CAAC;MACtBC,OAAO,EAAEP,MAAM,CAACO,OAAO;MACvBC,KAAK,EAAER,MAAM,CAACQ;IAChB,CAAC;EACH,CAAC;EAED,OAAO;IACL5C,OAAO,EAAPA,OAAO;IACPC,eAAe,EAAfA,eAAe;IACfC,uBAAuB,EAAvBA,uBAAuB;IACvBC,oBAAoB,EAApBA,oBAAoB;IACpBC,YAAY,EAAZA,YAAY;IACZI,eAAe,EAAfA,eAAe;IACfc,YAAY,EAAZA,YAAY;IACZQ,sBAAsB,EAAtBA,sBAAsB;IACtBe,OAAO,EAAExC,YAAY,CAAE;EACzB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useFocus","focusTo","getCurrentFocus","getCurrentFocusBuilding","getCurrentFocusFloor","getFocusTree","useMetaAtlas","mapCoreReady","useMetaAtlasStore","state","getBuildingList","focusTree","site","buildings","buildingsObj","Array","isArray","map","building","name","whereTaxonomy","taxonomyPath","key","push","getLevelList","buildingTaxonomy","levels","targetBuilding","find","floors","floorsObj","floor","getRootSiteCameraProps","platform","arguments","length","undefined","cameraConfigs","config","web","mobile","center","longitude","latitude","zoom","bearing","pitch","isReady"],"sources":["../../../../../src/react/hooks/useFocus/index.ts"],"sourcesContent":["import { useMetaAtlas } from '../useMetaAtlas';\nimport { useMetaAtlasStore } from '../../stores/useMetaAtlasStore';\nimport { UseFocusReturn, BuildingInfo, LevelInfo, CameraProps } from './types';\n\nexport function useFocus(): UseFocusReturn {\n const { focusTo, getCurrentFocus, getCurrentFocusBuilding, getCurrentFocusFloor, getFocusTree } = useMetaAtlas();\n const mapCoreReady = useMetaAtlasStore((state) => state.mapCoreReady);\n\n const getBuildingList = (): BuildingInfo[] => {\n if (!mapCoreReady) {\n return [];\n }\n const focusTree = getFocusTree();\n if (!focusTree || !focusTree.site || !focusTree.site.buildings) {\n return [];\n }\n\n const buildings: BuildingInfo[] = [];\n const buildingsObj: any = focusTree.site.buildings;\n \n // Handle both array and object formats\n if (Array.isArray(buildingsObj)) {\n return buildingsObj.map((building: any) => ({\n name: building.name || '',\n whereTaxonomy: building.taxonomyPath || '',\n }));\n } else {\n // Object format (key-value pairs)\n for (const key in buildingsObj) {\n const building: any = buildingsObj[key];\n if (building && building.taxonomyPath) {\n buildings.push({\n name: building.name || '',\n whereTaxonomy: building.taxonomyPath || '',\n });\n }\n }\n }\n\n return buildings;\n };\n\n const getLevelList = (buildingTaxonomy: string): LevelInfo[] => {\n if (!mapCoreReady) {\n return [];\n }\n const focusTree = getFocusTree();\n if (!focusTree || !focusTree.site || !focusTree.site.buildings) {\n return [];\n }\n\n const levels: LevelInfo[] = [];\n const buildingsObj: any = focusTree.site.buildings;\n \n // Find the building by taxonomy path\n let targetBuilding: any = null;\n \n if (Array.isArray(buildingsObj)) {\n targetBuilding = buildingsObj.find((building: any) => \n building.taxonomyPath === buildingTaxonomy\n );\n } else {\n // Object format (key-value pairs)\n for (const key in buildingsObj) {\n const building: any = buildingsObj[key];\n if (building && building.taxonomyPath === buildingTaxonomy) {\n targetBuilding = building;\n break;\n }\n }\n }\n\n if (!targetBuilding || !targetBuilding.floors) {\n return [];\n }\n\n const floorsObj: any = targetBuilding.floors;\n \n // Handle both array and object formats for floors\n if (Array.isArray(floorsObj)) {\n return floorsObj.map((floor: any) => ({\n name: floor.name || '',\n whereTaxonomy: floor.taxonomyPath || '',\n }));\n } else {\n // Object format (key-value pairs)\n for (const key in floorsObj) {\n const floor: any = floorsObj[key];\n if (floor && floor.taxonomyPath) {\n levels.push({\n name: floor.name || '',\n whereTaxonomy: floor.taxonomyPath || '',\n });\n }\n }\n }\n\n return levels;\n };\n\n const getRootSiteCameraProps = (platform: 'web' | 'mobile' = 'web'): CameraProps | null => {\n const focusTree = getFocusTree();\n if (!focusTree || !focusTree.site || !focusTree.site.cameraConfigs) {\n return null;\n }\n\n const cameraConfigs: any = focusTree.site.cameraConfigs;\n const config = cameraConfigs[platform] || cameraConfigs.web || cameraConfigs.mobile;\n \n if (!config || !config.center || !Array.isArray(config.center) || config.center.length < 2) {\n return null;\n }\n\n return {\n longitude: config.center[0],\n latitude: config.center[1],\n zoom: config.zoom || 0,\n bearing: config.bearing,\n pitch: config.pitch,\n };\n };\n\n return {\n focusTo,\n getCurrentFocus,\n getCurrentFocusBuilding,\n getCurrentFocusFloor,\n getFocusTree,\n getBuildingList,\n getLevelList,\n getRootSiteCameraProps,\n isReady: mapCoreReady, // Use mapCoreReady flag\n };\n}\n\n"],"mappings":";;;;;;;;AAIO,SAASA,QAAQA,CAAA,EAAmB;EACzC,MAAM;IAAEC,OAAO;IAAEC,eAAe;IAAEC,uBAAuB;IAAEC,oBAAoB;IAAEC;EAAa,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EAChH,MAAMC,YAAY,GAAG,IAAAC,oCAAiB,EAAEC,KAAK,IAAKA,KAAK,CAACF,YAAY,CAAC;EAErE,MAAMG,eAAe,GAAGA,CAAA,KAAsB;IAC5C,IAAI,CAACH,YAAY,EAAE;MACjB,OAAO,EAAE;IACX;IACA,MAAMI,SAAS,GAAGN,YAAY,CAAC,CAAC;IAChC,IAAI,CAACM,SAAS,IAAI,CAACA,SAAS,CAACC,IAAI,IAAI,CAACD,SAAS,CAACC,IAAI,CAACC,SAAS,EAAE;MAC9D,OAAO,EAAE;IACX;IAEA,MAAMA,SAAyB,GAAG,EAAE;IACpC,MAAMC,YAAiB,GAAGH,SAAS,CAACC,IAAI,CAACC,SAAS;;IAElD;IACA,IAAIE,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,EAAE;MAC/B,OAAOA,YAAY,CAACG,GAAG,CAAEC,QAAa,KAAM;QAC1CC,IAAI,EAAED,QAAQ,CAACC,IAAI,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,CAACF,MAAM,IAAI,CAACA,MAAM,CAACG,MAAM,IAAI,CAAC1B,KAAK,CAACC,OAAO,CAACsB,MAAM,CAACG,MAAM,CAAC,IAAIH,MAAM,CAACG,MAAM,CAACN,MAAM,GAAG,CAAC,EAAE;MAC1F,OAAO,IAAI;IACb;IAEA,OAAO;MACLO,SAAS,EAAEJ,MAAM,CAACG,MAAM,CAAC,CAAC,CAAC;MAC3BE,QAAQ,EAAEL,MAAM,CAACG,MAAM,CAAC,CAAC,CAAC;MAC1BG,IAAI,EAAEN,MAAM,CAACM,IAAI,IAAI,CAAC;MACtBC,OAAO,EAAEP,MAAM,CAACO,OAAO;MACvBC,KAAK,EAAER,MAAM,CAACQ;IAChB,CAAC;EACH,CAAC;EAED,OAAO;IACL7C,OAAO;IACPC,eAAe;IACfC,uBAAuB;IACvBC,oBAAoB;IACpBC,YAAY;IACZK,eAAe;IACfc,YAAY;IACZQ,sBAAsB;IACtBe,OAAO,EAAExC,YAAY,CAAE;EACzB,CAAC;AACH","ignoreList":[]}
@@ -5,107 +5,97 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useMapEvents = useMapEvents;
7
7
  var _react = require("react");
8
- var _useMetaAtlas2 = require("../useMetaAtlas");
9
- var _useMetaAtlasStore = require("../../stores/useMetaAtlasStore");
10
- var _useMapDataStore = require("../../stores/useMapDataStore");
11
- var _excluded = ["clickEvent"];
12
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
13
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
8
+ var _index = require("../useMetaAtlas/index.js");
9
+ var _useMetaAtlasStore = require("../../stores/useMetaAtlasStore.js");
10
+ var _useMapDataStore = require("../../stores/useMapDataStore.js");
14
11
  function useMapEvents() {
15
- var _useMetaAtlas = (0, _useMetaAtlas2.useMetaAtlas)(),
16
- map = _useMetaAtlas.map,
17
- getLastClickedFeature = _useMetaAtlas.getLastClickedFeature;
18
- var mapCoreReady = (0, _useMetaAtlasStore.useMetaAtlasStore)(function (state) {
19
- return state.mapCoreReady;
20
- });
21
- var clickHandlersRef = (0, _react.useRef)(new Set());
22
- var loadHandlersRef = (0, _react.useRef)(new Set());
23
- var moveEndHandlersRef = (0, _react.useRef)(new Set());
12
+ const {
13
+ map,
14
+ getLastClickedFeature
15
+ } = (0, _index.useMetaAtlas)();
16
+ const mapCoreReady = (0, _useMetaAtlasStore.useMetaAtlasStore)(state => state.mapCoreReady);
17
+ const clickHandlersRef = (0, _react.useRef)(new Set());
18
+ const loadHandlersRef = (0, _react.useRef)(new Set());
19
+ const moveEndHandlersRef = (0, _react.useRef)(new Set());
24
20
 
25
21
  // ONCE handlers
26
- var clickOnceHandlersRef = (0, _react.useRef)(new Set());
22
+ const clickOnceHandlersRef = (0, _react.useRef)(new Set());
27
23
 
28
24
  // Attach event listeners when map is ready
29
- (0, _react.useEffect)(function () {
25
+ (0, _react.useEffect)(() => {
30
26
  if (!map || !mapCoreReady) return;
31
27
 
32
28
  // Click event - get clickedMetaFeature from SDK (includes metaFeature + raw click event)
33
- var clickHandler = function clickHandler(e) {
29
+ const clickHandler = e => {
34
30
  // Get the clickedMetaFeature from SDK's getLastClickedFeature
35
31
  // This includes both the metaFeature data and the raw click event
36
- var clickedFeature = getLastClickedFeature();
32
+ const clickedFeature = getLastClickedFeature();
37
33
  if (!clickedFeature.clickEvent) clickedFeature.clickEvent = e;
38
34
 
39
35
  // Extract metaFeature part (without clickEvent) and update store
40
- var clickEvent = clickedFeature.clickEvent,
41
- metaFeaturePart = _objectWithoutProperties(clickedFeature, _excluded);
36
+ const {
37
+ clickEvent,
38
+ ...metaFeaturePart
39
+ } = clickedFeature;
42
40
  _useMapDataStore.useMapDataStore.getState().setActiveObject(metaFeaturePart);
43
41
  console.log('clickHandler clickedMetaFeature: ', clickedFeature);
44
42
 
45
43
  // normal handlers
46
- clickHandlersRef.current.forEach(function (handler) {
47
- return handler(clickedFeature);
48
- });
44
+ clickHandlersRef.current.forEach(handler => handler(clickedFeature));
49
45
 
50
46
  // --- ONCE handlers ---
51
47
  if (clickOnceHandlersRef.current.size > 0) {
52
- clickOnceHandlersRef.current.forEach(function (handler) {
53
- return handler(clickedFeature);
54
- });
48
+ clickOnceHandlersRef.current.forEach(handler => handler(clickedFeature));
55
49
  clickOnceHandlersRef.current.clear();
56
50
  }
57
51
  };
58
52
  map.on('click', clickHandler);
59
53
 
60
54
  // Load event
61
- var loadHandler = function loadHandler() {
62
- loadHandlersRef.current.forEach(function (handler) {
63
- return handler();
64
- });
55
+ const loadHandler = () => {
56
+ loadHandlersRef.current.forEach(handler => handler());
65
57
  };
66
58
  map.on('load', loadHandler);
67
59
 
68
60
  // MoveEnd event
69
- var moveEndHandler = function moveEndHandler() {
70
- moveEndHandlersRef.current.forEach(function (handler) {
71
- return handler();
72
- });
61
+ const moveEndHandler = () => {
62
+ moveEndHandlersRef.current.forEach(handler => handler());
73
63
  };
74
64
  map.on('moveend', moveEndHandler);
75
- return function () {
65
+ return () => {
76
66
  map.off('click', clickHandler);
77
67
  map.off('load', loadHandler);
78
68
  map.off('moveend', moveEndHandler);
79
69
  };
80
70
  }, [map, mapCoreReady]);
81
- var onMapClick = function onMapClick(handler) {
71
+ const onMapClick = handler => {
82
72
  clickHandlersRef.current.add(handler);
83
- return function () {
84
- clickHandlersRef.current["delete"](handler);
73
+ return () => {
74
+ clickHandlersRef.current.delete(handler);
85
75
  };
86
76
  };
87
- var onMapLoad = function onMapLoad(handler) {
77
+ const onMapLoad = handler => {
88
78
  loadHandlersRef.current.add(handler);
89
- return function () {
90
- loadHandlersRef.current["delete"](handler);
79
+ return () => {
80
+ loadHandlersRef.current.delete(handler);
91
81
  };
92
82
  };
93
- var onMapMoveEnd = function onMapMoveEnd(handler) {
83
+ const onMapMoveEnd = handler => {
94
84
  moveEndHandlersRef.current.add(handler);
95
- return function () {
96
- moveEndHandlersRef.current["delete"](handler);
85
+ return () => {
86
+ moveEndHandlersRef.current.delete(handler);
97
87
  };
98
88
  };
99
89
 
100
90
  // ONCE registration methods
101
- var onceMapClick = function onceMapClick(handler) {
91
+ const onceMapClick = handler => {
102
92
  clickOnceHandlersRef.current.add(handler);
103
93
  };
104
94
  return {
105
- onMapClick: onMapClick,
106
- onMapLoad: onMapLoad,
107
- onMapMoveEnd: onMapMoveEnd,
108
- onceMapClick: onceMapClick,
95
+ onMapClick,
96
+ onMapLoad,
97
+ onMapMoveEnd,
98
+ onceMapClick,
109
99
  isReady: mapCoreReady
110
100
  };
111
101
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","require","_useMetaAtlas2","_useMetaAtlasStore","_useMapDataStore","_excluded","_objectWithoutProperties","e","t","o","r","i","_objectWithoutPropertiesLoose","Object","getOwnPropertySymbols","n","length","indexOf","propertyIsEnumerable","call","hasOwnProperty","useMapEvents","_useMetaAtlas","useMetaAtlas","map","getLastClickedFeature","mapCoreReady","useMetaAtlasStore","state","clickHandlersRef","useRef","Set","loadHandlersRef","moveEndHandlersRef","clickOnceHandlersRef","useEffect","clickHandler","clickedFeature","clickEvent","metaFeaturePart","useMapDataStore","getState","setActiveObject","console","log","current","forEach","handler","size","clear","on","loadHandler","moveEndHandler","off","onMapClick","add","onMapLoad","onMapMoveEnd","onceMapClick","isReady"],"sources":["../../../../../src/react/hooks/useMapEvents/index.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { useMetaAtlas } from '../useMetaAtlas';\nimport { UseMapEventsReturn } from './types';\nimport * as maplibregl from 'maplibre-gl';\nimport { useMetaAtlasStore } from '../../stores/useMetaAtlasStore';\nimport { clickedMetaFeature } from '../../../meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core';\nimport { useMapDataStore } from '../../stores/useMapDataStore';\n\nexport function useMapEvents(): UseMapEventsReturn {\n const { map, getLastClickedFeature } = useMetaAtlas();\n const mapCoreReady = useMetaAtlasStore((state) => state.mapCoreReady);\n const clickHandlersRef = useRef<Set<(feature: clickedMetaFeature) => void>>(new Set());\n const loadHandlersRef = useRef<Set<() => void>>(new Set());\n const moveEndHandlersRef = useRef<Set<() => void>>(new Set());\n\n // ONCE handlers\n const clickOnceHandlersRef = useRef<Set<(feature: clickedMetaFeature) => void>>(new Set());\n\n // Attach event listeners when map is ready\n useEffect(() => {\n if (!map || !mapCoreReady) return;\n\n // Click event - get clickedMetaFeature from SDK (includes metaFeature + raw click event)\n const clickHandler = (e: maplibregl.MapMouseEvent) => {\n // Get the clickedMetaFeature from SDK's getLastClickedFeature\n // This includes both the metaFeature data and the raw click event\n const clickedFeature = getLastClickedFeature();\n if (!clickedFeature.clickEvent) clickedFeature.clickEvent = e;\n \n // Extract metaFeature part (without clickEvent) and update store\n const { clickEvent, ...metaFeaturePart } = clickedFeature;\n useMapDataStore.getState().setActiveObject(metaFeaturePart);\n \n console.log('clickHandler clickedMetaFeature: ', clickedFeature);\n\n // normal handlers\n clickHandlersRef.current.forEach(handler => handler(clickedFeature));\n\n // --- ONCE handlers ---\n if (clickOnceHandlersRef.current.size > 0) {\n clickOnceHandlersRef.current.forEach(handler => handler(clickedFeature));\n clickOnceHandlersRef.current.clear();\n }\n };\n map.on('click', clickHandler);\n\n // Load event\n const loadHandler = () => {\n loadHandlersRef.current.forEach(handler => handler());\n };\n map.on('load', loadHandler);\n\n // MoveEnd event\n const moveEndHandler = () => {\n moveEndHandlersRef.current.forEach(handler => handler());\n };\n map.on('moveend', moveEndHandler);\n\n return () => {\n map.off('click', clickHandler);\n map.off('load', loadHandler);\n map.off('moveend', moveEndHandler);\n };\n }, [map, mapCoreReady]);\n\n const onMapClick = (handler: (feature: clickedMetaFeature) => void) => {\n clickHandlersRef.current.add(handler);\n return () => {\n clickHandlersRef.current.delete(handler);\n };\n };\n\n const onMapLoad = (handler: () => void) => {\n loadHandlersRef.current.add(handler);\n return () => {\n loadHandlersRef.current.delete(handler);\n };\n };\n\n const onMapMoveEnd = (handler: () => void) => {\n moveEndHandlersRef.current.add(handler);\n return () => {\n moveEndHandlersRef.current.delete(handler);\n };\n };\n\n // ONCE registration methods\n const onceMapClick = (handler: (feature: clickedMetaFeature) => void) => {\n clickOnceHandlersRef.current.add(handler);\n };\n\n\n return {\n onMapClick,\n onMapLoad,\n onMapMoveEnd,\n onceMapClick,\n isReady: mapCoreReady,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,kBAAA,GAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAH,OAAA;AAA+D,IAAAI,SAAA;AAAA,SAAAC,yBAAAC,CAAA,EAAAC,CAAA,gBAAAD,CAAA,iBAAAE,CAAA,EAAAC,CAAA,EAAAC,CAAA,GAAAC,6BAAA,CAAAL,CAAA,EAAAC,CAAA,OAAAK,MAAA,CAAAC,qBAAA,QAAAC,CAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAP,CAAA,QAAAG,CAAA,MAAAA,CAAA,GAAAK,CAAA,CAAAC,MAAA,EAAAN,CAAA,IAAAD,CAAA,GAAAM,CAAA,CAAAL,CAAA,UAAAF,CAAA,CAAAS,OAAA,CAAAR,CAAA,QAAAS,oBAAA,CAAAC,IAAA,CAAAZ,CAAA,EAAAE,CAAA,MAAAE,CAAA,CAAAF,CAAA,IAAAF,CAAA,CAAAE,CAAA,aAAAE,CAAA;AAAA,SAAAC,8BAAAF,CAAA,EAAAH,CAAA,gBAAAG,CAAA,iBAAAF,CAAA,gBAAAO,CAAA,IAAAL,CAAA,SAAAU,cAAA,CAAAD,IAAA,CAAAT,CAAA,EAAAK,CAAA,gBAAAR,CAAA,CAAA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gB,OAAO,CAACU,GAAG,CAACR,OAAO,CAAC;IACrC,OAAO,YAAM;MACXlB,gBAAgB,CAACgB,OAAO,UAAO,CAACE,OAAO,CAAC;IAC1C,CAAC;EACH,CAAC;EAED,IAAMS,SAAS,GAAG,SAAZA,SAASA,CAAIT,OAAmB,EAAK;IACzCf,eAAe,CAACa,OAAO,CAACU,GAAG,CAACR,OAAO,CAAC;IACpC,OAAO,YAAM;MACXf,eAAe,CAACa,OAAO,UAAO,CAACE,OAAO,CAAC;IACzC,CAAC;EACH,CAAC;EAED,IAAMU,YAAY,GAAG,SAAfA,YAAYA,CAAIV,OAAmB,EAAK;IAC5Cd,kBAAkB,CAACY,OAAO,CAACU,GAAG,CAACR,OAAO,CAAC;IACvC,OAAO,YAAM;MACXd,kBAAkB,CAACY,OAAO,UAAO,CAACE,OAAO,CAAC;IAC5C,CAAC;EACH,CAAC;;EAED;EACA,IAAMW,YAAY,GAAG,SAAfA,YAAYA,CAAIX,OAA8C,EAAK;IACvEb,oBAAoB,CAACW,OAAO,CAACU,GAAG,CAACR,OAAO,CAAC;EAC3C,CAAC;EAGD,OAAO;IACLO,UAAU,EAAVA,UAAU;IACVE,SAAS,EAATA,SAAS;IACTC,YAAY,EAAZA,YAAY;IACZC,YAAY,EAAZA,YAAY;IACZC,OAAO,EAAEjC;EACX,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_react","require","_index","_useMetaAtlasStore","_useMapDataStore","useMapEvents","map","getLastClickedFeature","useMetaAtlas","mapCoreReady","useMetaAtlasStore","state","clickHandlersRef","useRef","Set","loadHandlersRef","moveEndHandlersRef","clickOnceHandlersRef","useEffect","clickHandler","e","clickedFeature","clickEvent","metaFeaturePart","useMapDataStore","getState","setActiveObject","console","log","current","forEach","handler","size","clear","on","loadHandler","moveEndHandler","off","onMapClick","add","delete","onMapLoad","onMapMoveEnd","onceMapClick","isReady"],"sources":["../../../../../src/react/hooks/useMapEvents/index.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { useMetaAtlas } from '../useMetaAtlas';\nimport { UseMapEventsReturn } from './types';\nimport * as maplibregl from 'maplibre-gl';\nimport { useMetaAtlasStore } from '../../stores/useMetaAtlasStore';\nimport { clickedMetaFeature } from '../../../meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core';\nimport { useMapDataStore } from '../../stores/useMapDataStore';\n\nexport function useMapEvents(): UseMapEventsReturn {\n const { map, getLastClickedFeature } = useMetaAtlas();\n const mapCoreReady = useMetaAtlasStore((state) => state.mapCoreReady);\n const clickHandlersRef = useRef<Set<(feature: clickedMetaFeature) => void>>(new Set());\n const loadHandlersRef = useRef<Set<() => void>>(new Set());\n const moveEndHandlersRef = useRef<Set<() => void>>(new Set());\n\n // ONCE handlers\n const clickOnceHandlersRef = useRef<Set<(feature: clickedMetaFeature) => void>>(new Set());\n\n // Attach event listeners when map is ready\n useEffect(() => {\n if (!map || !mapCoreReady) return;\n\n // Click event - get clickedMetaFeature from SDK (includes metaFeature + raw click event)\n const clickHandler = (e: maplibregl.MapMouseEvent) => {\n // Get the clickedMetaFeature from SDK's getLastClickedFeature\n // This includes both the metaFeature data and the raw click event\n const clickedFeature = getLastClickedFeature();\n if (!clickedFeature.clickEvent) clickedFeature.clickEvent = e;\n \n // Extract metaFeature part (without clickEvent) and update store\n const { clickEvent, ...metaFeaturePart } = clickedFeature;\n useMapDataStore.getState().setActiveObject(metaFeaturePart);\n \n console.log('clickHandler clickedMetaFeature: ', clickedFeature);\n\n // normal handlers\n clickHandlersRef.current.forEach(handler => handler(clickedFeature));\n\n // --- ONCE handlers ---\n if (clickOnceHandlersRef.current.size > 0) {\n clickOnceHandlersRef.current.forEach(handler => handler(clickedFeature));\n clickOnceHandlersRef.current.clear();\n }\n };\n map.on('click', clickHandler);\n\n // Load event\n const loadHandler = () => {\n loadHandlersRef.current.forEach(handler => handler());\n };\n map.on('load', loadHandler);\n\n // MoveEnd event\n const moveEndHandler = () => {\n moveEndHandlersRef.current.forEach(handler => handler());\n };\n map.on('moveend', moveEndHandler);\n\n return () => {\n map.off('click', clickHandler);\n map.off('load', loadHandler);\n map.off('moveend', moveEndHandler);\n };\n }, [map, mapCoreReady]);\n\n const onMapClick = (handler: (feature: clickedMetaFeature) => void) => {\n clickHandlersRef.current.add(handler);\n return () => {\n clickHandlersRef.current.delete(handler);\n };\n };\n\n const onMapLoad = (handler: () => void) => {\n loadHandlersRef.current.add(handler);\n return () => {\n loadHandlersRef.current.delete(handler);\n };\n };\n\n const onMapMoveEnd = (handler: () => void) => {\n moveEndHandlersRef.current.add(handler);\n return () => {\n moveEndHandlersRef.current.delete(handler);\n };\n };\n\n // ONCE registration methods\n const onceMapClick = (handler: (feature: clickedMetaFeature) => void) => {\n clickOnceHandlersRef.current.add(handler);\n };\n\n\n return {\n onMapClick,\n onMapLoad,\n onMapMoveEnd,\n onceMapClick,\n isReady: mapCoreReady,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAoD,IAAAC,MAAA,GAAAD,OAAA;AAAA,IAAAE,kBAAA,GAAAF,OAAA;AAAA,IAAAG,gBAAA,GAAAH,OAAA;AAQ7C,SAASI,YAAYA,CAAA,EAAuB;EACjD,MAAM;IAAEC,GAAG;IAAEC;EAAsB,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EACrD,MAAMC,YAAY,GAAG,IAAAC,oCAAiB,EAAEC,KAAK,IAAKA,KAAK,CAACF,YAAY,CAAC;EACrE,MAAMG,gBAAgB,GAAG,IAAAC,aAAM,EAA6C,IAAIC,GAAG,CAAC,CAAC,CAAC;EACtF,MAAMC,eAAe,GAAG,IAAAF,aAAM,EAAkB,IAAIC,GAAG,CAAC,CAAC,CAAC;EAC1D,MAAME,kBAAkB,GAAG,IAAAH,aAAM,EAAkB,IAAIC,GAAG,CAAC,CAAC,CAAC;;EAE7D;EACA,MAAMG,oBAAoB,GAAG,IAAAJ,aAAM,EAA6C,IAAIC,GAAG,CAAC,CA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AAE,CAAC,SAAS,EAAEE,cAAc,CAAC;IAEjC,OAAO,MAAM;MACX9B,GAAG,CAAC+B,GAAG,CAAC,OAAO,EAAElB,YAAY,CAAC;MAC9Bb,GAAG,CAAC+B,GAAG,CAAC,MAAM,EAAEF,WAAW,CAAC;MAC5B7B,GAAG,CAAC+B,GAAG,CAAC,SAAS,EAAED,cAAc,CAAC;IACpC,CAAC;EACH,CAAC,EAAE,CAAC9B,GAAG,EAAEG,YAAY,CAAC,CAAC;EAEvB,MAAM6B,UAAU,GAAIP,OAA8C,IAAK;IACrEnB,gBAAgB,CAACiB,OAAO,CAACU,GAAG,CAACR,OAAO,CAAC;IACrC,OAAO,MAAM;MACXnB,gBAAgB,CAACiB,OAAO,CAACW,MAAM,CAACT,OAAO,CAAC;IAC1C,CAAC;EACH,CAAC;EAED,MAAMU,SAAS,GAAIV,OAAmB,IAAK;IACzChB,eAAe,CAACc,OAAO,CAACU,GAAG,CAACR,OAAO,CAAC;IACpC,OAAO,MAAM;MACXhB,eAAe,CAACc,OAAO,CAACW,MAAM,CAACT,OAAO,CAAC;IACzC,CAAC;EACH,CAAC;EAED,MAAMW,YAAY,GAAIX,OAAmB,IAAK;IAC5Cf,kBAAkB,CAACa,OAAO,CAACU,GAAG,CAACR,OAAO,CAAC;IACvC,OAAO,MAAM;MACXf,kBAAkB,CAACa,OAAO,CAACW,MAAM,CAACT,OAAO,CAAC;IAC5C,CAAC;EACH,CAAC;;EAED;EACA,MAAMY,YAAY,GAAIZ,OAA8C,IAAK;IACvEd,oBAAoB,CAACY,OAAO,CAACU,GAAG,CAACR,OAAO,CAAC;EAC3C,CAAC;EAGD,OAAO;IACLO,UAAU;IACVG,SAAS;IACTC,YAAY;IACZC,YAAY;IACZC,OAAO,EAAEnC;EACX,CAAC;AACH","ignoreList":[]}
@@ -6,51 +6,50 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useMapOverlays = useMapOverlays;
7
7
  var _client = require("react-dom/client");
8
8
  var _maplibreGl = require("maplibre-gl");
9
- var _useMetaAtlas2 = require("../useMetaAtlas");
10
- var _useMetaAtlasStore = require("../../stores/useMetaAtlasStore");
9
+ var _index = require("../useMetaAtlas/index.js");
10
+ var _useMetaAtlasStore = require("../../stores/useMetaAtlasStore.js");
11
11
  /**
12
12
  * Hook for managing React-based map overlays (popups) on the MapLibre map.
13
13
  * Provides a function to create popups with React components that automatically
14
14
  * handle lifecycle and cleanup.
15
15
  */
16
16
  function useMapOverlays() {
17
- var _useMetaAtlas = (0, _useMetaAtlas2.useMetaAtlas)(),
18
- map = _useMetaAtlas.map,
19
- addUserLayer = _useMetaAtlas.addUserLayer;
20
- var mapCoreReady = (0, _useMetaAtlasStore.useMetaAtlasStore)(function (state) {
21
- return state.mapCoreReady;
22
- });
17
+ const {
18
+ map,
19
+ addUserLayer
20
+ } = (0, _index.useMetaAtlas)();
21
+ const mapCoreReady = (0, _useMetaAtlasStore.useMetaAtlasStore)(state => state.mapCoreReady);
23
22
 
24
23
  /**
25
24
  * Creates a React popup on the map at the specified location.
26
25
  * Uses React's createRoot to render the component and automatically
27
26
  * cleans up when the popup is closed.
28
27
  */
29
- var createReactPopup = function createReactPopup(lngLat, component, options) {
28
+ const createReactPopup = (lngLat, component, options) => {
30
29
  if (!map || !mapCoreReady) {
31
30
  console.warn('Map is not ready. Cannot create popup.');
32
31
  return null;
33
32
  }
34
33
 
35
34
  // Create a container div for React
36
- var container = document.createElement('div');
35
+ const container = document.createElement('div');
37
36
 
38
37
  // Create React root and render component
39
- var root = (0, _client.createRoot)(container);
38
+ const root = (0, _client.createRoot)(container);
40
39
  root.render(component);
41
40
 
42
41
  // Create popup and set the DOM content
43
- var popup = new _maplibreGl.Popup(options).setLngLat(lngLat).setDOMContent(container) // Pass the container, not the React element
42
+ const popup = new _maplibreGl.Popup(options).setLngLat(lngLat).setDOMContent(container) // Pass the container, not the React element
44
43
  .addTo(map);
45
44
 
46
45
  // Cleanup function
47
- var _cleanup = function cleanup() {
46
+ const cleanup = () => {
48
47
  root.unmount(); // Clean up React root
49
- popup.off('close', _cleanup); // Remove event listener
48
+ popup.off('close', cleanup); // Remove event listener
50
49
  };
51
50
 
52
51
  // Cleanup when popup is removed
53
- popup.on('close', _cleanup);
52
+ popup.on('close', cleanup);
54
53
  return popup;
55
54
  };
56
55
 
@@ -61,7 +60,7 @@ function useMapOverlays() {
61
60
  *
62
61
  * @param layer - The layer configuration object to add to the map
63
62
  */
64
- var addLayer = function addLayer(layer) {
63
+ const addLayer = layer => {
65
64
  if (!mapCoreReady) {
66
65
  console.warn('Map is not ready. Cannot add layer.');
67
66
  return;
@@ -95,12 +94,12 @@ function useMapOverlays() {
95
94
  * );
96
95
  * ```
97
96
  */
98
- var createMarker = function createMarker(lngLat, options, popup) {
97
+ const createMarker = (lngLat, options, popup) => {
99
98
  if (!map || !mapCoreReady) {
100
99
  console.warn('Map is not ready. Cannot create marker.');
101
100
  return null;
102
101
  }
103
- var marker = new _maplibreGl.Marker(options).setLngLat(lngLat).addTo(map);
102
+ const marker = new _maplibreGl.Marker(options).setLngLat(lngLat).addTo(map);
104
103
 
105
104
  // Set popup if provided
106
105
  if (popup) {
@@ -110,9 +109,9 @@ function useMapOverlays() {
110
109
  return marker;
111
110
  };
112
111
  return {
113
- createReactPopup: createReactPopup,
114
- addLayer: addLayer,
115
- createMarker: createMarker,
112
+ createReactPopup,
113
+ addLayer,
114
+ createMarker,
116
115
  isReady: mapCoreReady
117
116
  };
118
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_client","require","_maplibreGl","_useMetaAtlas2","_useMetaAtlasStore","useMapOverlays","_useMetaAtlas","useMetaAtlas","map","addUserLayer","mapCoreReady","useMetaAtlasStore","state","createReactPopup","lngLat","component","options","console","warn","container","document","createElement","root","createRoot","render","popup","Popup","setLngLat","setDOMContent","addTo","cleanup","unmount","off","on","addLayer","layer","createMarker","marker","Marker","setPopup","togglePopup","isReady"],"sources":["../../../../../src/react/hooks/useMapOverlays/index.ts"],"sourcesContent":["import { createRoot, Root } from 'react-dom/client';\nimport { ReactElement } from 'react';\nimport { Popup, PopupOptions, LngLatLike, Marker, MarkerOptions } from 'maplibre-gl';\nimport { useMetaAtlas } from '../useMetaAtlas';\nimport { useMetaAtlasStore } from '../../stores/useMetaAtlasStore';\nimport { UseMapOverlaysReturn } from './types';\n\n/**\n * Hook for managing React-based map overlays (popups) on the MapLibre map.\n * Provides a function to create popups with React components that automatically\n * handle lifecycle and cleanup.\n */\nexport function useMapOverlays(): UseMapOverlaysReturn {\n const { map, addUserLayer } = useMetaAtlas();\n const mapCoreReady = useMetaAtlasStore((state) => state.mapCoreReady);\n \n /**\n * Creates a React popup on the map at the specified location.\n * Uses React's createRoot to render the component and automatically\n * cleans up when the popup is closed.\n */\n const createReactPopup = (\n lngLat: LngLatLike,\n component: ReactElement,\n options?: PopupOptions\n ): Popup | null => {\n if (!map || !mapCoreReady) {\n console.warn('Map is not ready. Cannot create popup.');\n return null;\n }\n\n // Create a container div for React\n const container = document.createElement('div');\n \n // Create React root and render component\n const root: Root = createRoot(container);\n root.render(component);\n \n // Create popup and set the DOM content\n const popup = new Popup(options)\n .setLngLat(lngLat)\n .setDOMContent(container) // Pass the container, not the React element\n .addTo(map);\n \n // Cleanup function\n const cleanup = () => {\n root.unmount(); // Clean up React root\n popup.off('close', cleanup); // Remove event listener\n };\n \n // Cleanup when popup is removed\n popup.on('close', cleanup);\n \n return popup;\n };\n\n /**\n * Adds a user layer to the map.\n * Internally uses addUserLayer from the SDK, which also sets up click handlers\n * to update the last clicked feature.\n * \n * @param layer - The layer configuration object to add to the map\n */\n const addLayer = (layer: any): void => {\n if (!mapCoreReady) {\n console.warn('Map is not ready. Cannot add layer.');\n return;\n }\n addUserLayer(layer);\n };\n\n /**\n * Creates a marker on the map at the specified location.\n * Can optionally attach a popup to the marker.\n * \n * @param lngLat - The geographical location [longitude, latitude] or LngLat object\n * @param options - Optional marker configuration (element, etc.)\n * @param popup - Optional popup to attach to the marker\n * @returns The marker instance, or null if map is not ready\n * \n * @example\n * ```tsx\n * const { createMarker, createReactPopup } = useMapOverlays();\n * \n * const el = document.createElement('img');\n * el.src = '/icons/marker.png';\n * el.style.width = '40px';\n * el.style.height = '40px';\n * \n * const popup = createReactPopup([lng, lat], <MyComponent />);\n * const marker = createMarker(\n * [lng, lat],\n * { element: el },\n * popup\n * );\n * ```\n */\n const createMarker = (\n lngLat: LngLatLike,\n options?: MarkerOptions,\n popup?: Popup | null\n ): Marker | null => {\n if (!map || !mapCoreReady) {\n console.warn('Map is not ready. Cannot create marker.');\n return null;\n }\n\n const marker = new Marker(options)\n .setLngLat(lngLat)\n .addTo(map);\n\n // Set popup if provided\n if (popup) {\n marker.setPopup(popup);\n marker.togglePopup();\n }\n\n return marker;\n };\n\n return {\n createReactPopup,\n addLayer,\n createMarker,\n isReady: mapCoreReady,\n };\n}\n\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AAGA;AACA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAAA,EAAyB;EACrD,IAAAC,aAAA,GAA8B,IAAAC,2BAAY,EAAC,CAAC;IAApCC,GAAG,GAAAF,aAAA,CAAHE,GAAG;IAAEC,YAAY,GAAAH,aAAA,CAAZG,YAAY;EACzB,IAAMC,YAAY,GAAG,IAAAC,oCAAiB,EAAC,UAACC,KAAK;IAAA,OAAKA,KAAK,CAACF,YAAY;EAAA,EAAC;;EAErE;AACF;AACA;AACA;AACA;EACE,IAAMG,gBAAgB,GAAG,SAAnBA,gBAAgBA,CACpBC,MAAkB,EAClBC,SAAuB,EACvBC,OAAsB,EACL;IACjB,IAAI,CAACR,GAAG,IAAI,CAACE,YAAY,EAAE;MACzBO,OAAO,CAACC,IAAI,CAAC,wCAAwC,CAAC;MACtD,OAAO,IAAI;IACb;;IAEA;IACA,IAAMC,SAAS,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C/BW,SAAS,CAACb,MAAM,CAAC,CACjBe,KAAK,CAACrB,GAAG,CAAC;;IAEb;IACA,IAAIiB,KAAK,EAAE;MACTY,MAAM,CAACE,QAAQ,CAACd,KAAK,CAAC;MACtBY,MAAM,CAACG,WAAW,CAAC,CAAC;IACtB;IAEA,OAAOH,MAAM;EACf,CAAC;EAED,OAAO;IACLxB,gBAAgB,EAAhBA,gBAAgB;IAChBqB,QAAQ,EAARA,QAAQ;IACRE,YAAY,EAAZA,YAAY;IACZK,OAAO,EAAE/B;EACX,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_client","require","_maplibreGl","_index","_useMetaAtlasStore","useMapOverlays","map","addUserLayer","useMetaAtlas","mapCoreReady","useMetaAtlasStore","state","createReactPopup","lngLat","component","options","console","warn","container","document","createElement","root","createRoot","render","popup","Popup","setLngLat","setDOMContent","addTo","cleanup","unmount","off","on","addLayer","layer","createMarker","marker","Marker","setPopup","togglePopup","isReady"],"sources":["../../../../../src/react/hooks/useMapOverlays/index.ts"],"sourcesContent":["import { createRoot, Root } from 'react-dom/client';\nimport { ReactElement } from 'react';\nimport { Popup, PopupOptions, LngLatLike, Marker, MarkerOptions } from 'maplibre-gl';\nimport { useMetaAtlas } from '../useMetaAtlas';\nimport { useMetaAtlasStore } from '../../stores/useMetaAtlasStore';\nimport { UseMapOverlaysReturn } from './types';\n\n/**\n * Hook for managing React-based map overlays (popups) on the MapLibre map.\n * Provides a function to create popups with React components that automatically\n * handle lifecycle and cleanup.\n */\nexport function useMapOverlays(): UseMapOverlaysReturn {\n const { map, addUserLayer } = useMetaAtlas();\n const mapCoreReady = useMetaAtlasStore((state) => state.mapCoreReady);\n \n /**\n * Creates a React popup on the map at the specified location.\n * Uses React's createRoot to render the component and automatically\n * cleans up when the popup is closed.\n */\n const createReactPopup = (\n lngLat: LngLatLike,\n component: ReactElement,\n options?: PopupOptions\n ): Popup | null => {\n if (!map || !mapCoreReady) {\n console.warn('Map is not ready. Cannot create popup.');\n return null;\n }\n\n // Create a container div for React\n const container = document.createElement('div');\n \n // Create React root and render component\n const root: Root = createRoot(container);\n root.render(component);\n \n // Create popup and set the DOM content\n const popup = new Popup(options)\n .setLngLat(lngLat)\n .setDOMContent(container) // Pass the container, not the React element\n .addTo(map);\n \n // Cleanup function\n const cleanup = () => {\n root.unmount(); // Clean up React root\n popup.off('close', cleanup); // Remove event listener\n };\n \n // Cleanup when popup is removed\n popup.on('close', cleanup);\n \n return popup;\n };\n\n /**\n * Adds a user layer to the map.\n * Internally uses addUserLayer from the SDK, which also sets up click handlers\n * to update the last clicked feature.\n * \n * @param layer - The layer configuration object to add to the map\n */\n const addLayer = (layer: any): void => {\n if (!mapCoreReady) {\n console.warn('Map is not ready. Cannot add layer.');\n return;\n }\n addUserLayer(layer);\n };\n\n /**\n * Creates a marker on the map at the specified location.\n * Can optionally attach a popup to the marker.\n * \n * @param lngLat - The geographical location [longitude, latitude] or LngLat object\n * @param options - Optional marker configuration (element, etc.)\n * @param popup - Optional popup to attach to the marker\n * @returns The marker instance, or null if map is not ready\n * \n * @example\n * ```tsx\n * const { createMarker, createReactPopup } = useMapOverlays();\n * \n * const el = document.createElement('img');\n * el.src = '/icons/marker.png';\n * el.style.width = '40px';\n * el.style.height = '40px';\n * \n * const popup = createReactPopup([lng, lat], <MyComponent />);\n * const marker = createMarker(\n * [lng, lat],\n * { element: el },\n * popup\n * );\n * ```\n */\n const createMarker = (\n lngLat: LngLatLike,\n options?: MarkerOptions,\n popup?: Popup | null\n ): Marker | null => {\n if (!map || !mapCoreReady) {\n console.warn('Map is not ready. Cannot create marker.');\n return null;\n }\n\n const marker = new Marker(options)\n .setLngLat(lngLat)\n .addTo(map);\n\n // Set popup if provided\n if (popup) {\n marker.setPopup(popup);\n marker.togglePopup();\n }\n\n return marker;\n };\n\n return {\n createReactPopup,\n addLayer,\n createMarker,\n isReady: mapCoreReady,\n };\n}\n\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA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