@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":"MainMap.js","names":["_CustomThreeJsWrapper","_interopRequireDefault","require","_troikaThreeText","turf","_interopRequireWildcard","THREE","_utils","_threeSpritetext","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Symbol","iterator","constructor","prototype","_regenerator","toStringTag","c","Generator","u","create","_regeneratorDefine2","p","y","G","v","a","d","bind","length","l","TypeError","done","value","GeneratorFunction","GeneratorFunctionPrototype","getPrototypeOf","setPrototypeOf","displayName","w","m","_regeneratorDefine","_invoke","enumerable","configurable","writable","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","ownKeys","keys","getOwnPropertySymbols","filter","push","_objectSpread","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","_classCallCheck","_defineProperties","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","String","Number","MainMap","exports","metaAtlasCore","_this","map","polygonFeatures","source","getSource","features","querySourceFeatures","sourceLayer","feature","geometry","type","properties","dimension_what","_feature$properties","id","mapObjectId","name","title","coordinates","hasImage","Math","round","random","_ref","_callee","polygon","centroid","myText","text","textPosition","_context","dimension_where","SpriteText","color","addNewLine","textHeight","projectToWorld","rotation","x","PI","scale","position","threebox","add","_x","logo","textureLoader","TextureLoader","texture","load","width","height","depth","BoxGeometry","sideMaterial","MeshBasicMaterial","Color","topMaterial","MeshStandardMaterial","side","DoubleSide","transparent","materials","logoMesh","Mesh","z","textMesh","Text","fontSize","anchorX","anchorY","fontWeight","textAlign","sync","mainInstance","init","map2D","initThreebox","wrapper","CustomThreeJSWrapper","setEnvironment","addLayer","renderingMode","onAdd","console","log","render","update","getThreebox","input","replace"],"sources":["../../../../src/meta-atlas-sdk/3DMap/MainMap.ts"],"sourcesContent":["import { Map as MaplibreMap } from 'maplibre-gl';\n\nimport CustomThreeJSWrapper from './CustomThreeJsWrapper/CustomThreeJsWrapper';\nimport { Text } from 'troika-three-text';\n\nimport { EquirectangularReflectionMapping } from 'three';\nimport { MetaAtlasCore } from '../MetaAtlasCore/meta-atlas-sdk-core';\nimport * as turf from '@turf/turf';\nimport * as THREE from 'three';\nimport { projectToWorld } from './CustomThreeJsWrapper/utility/utils';\nimport SpriteText from 'three-spritetext';\nimport { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader';\n\nexport default class MainMap {\n public static mainInstance: MainMap | null = null;\n public map!: MaplibreMap;\n public threebox!: CustomThreeJSWrapper;\n public metaAtlasCore!: MetaAtlasCore;\n\n constructor(metaAtlasCore: MetaAtlasCore) {\n if (MainMap.mainInstance) {\n return MainMap.mainInstance;\n }\n\n MainMap.mainInstance = this;\n\n this.metaAtlasCore = metaAtlasCore;\n }\n\n public init(map2D: MaplibreMap) {\n this.map = map2D;\n this.initThreebox();\n }\n\n /**\n * Creates a Threebox instance of the class.\n * @param map Maplibre instance to initialize threebox\n * @returns Threebox class instance created\n */\n private initThreebox() {\n const map = this.map;\n const wrapper = new CustomThreeJSWrapper(map);\n wrapper.setEnvironment();\n // const hdrLoader = new HDRLoader();\n // hdrLoader.load('./golden_gate_hills_1k.hdr', texture => {\n // texture.mapping = EquirectangularReflectionMapping;\n // wrapper.scene.environment = texture;\n // });\n\n map.addLayer({\n id: '3d-model-layer',\n type: 'custom',\n renderingMode: '3d',\n onAdd: () => {\n console.log('onAdd _initThreebox');\n },\n render: () => {\n wrapper.update();\n }\n });\n\n this.threebox = wrapper;\n return wrapper;\n }\n\n /**\n * Get the threebox instance for 3D model operations\n */\n getThreebox() {\n return this.threebox;\n }\n\n getAllPolygonCoordinates = () => {\n const map = this.map;\n\n if (!map) return [];\n\n const polygonFeatures: any[] = [];\n const source = map.getSource('custom');\n if (source) {\n const features = map.querySourceFeatures('custom', {\n sourceLayer: 'geojson',\n filter: ['==', ['geometry-type'], 'Polygon']\n });\n\n if (features && features.length > 0) {\n features.forEach(feature => {\n if (\n (feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') &&\n feature.properties.dimension_what === 'what.booth'\n ) {\n polygonFeatures.push({\n id: feature.properties.mapObjectId,\n name: feature.properties?.title || 'Unnamed Polygon',\n coordinates: feature.geometry.coordinates,\n properties: {\n ...feature.properties,\n hasImage: !!Math.round(Math.random())\n }\n });\n }\n });\n }\n }\n\n return polygonFeatures;\n };\n\n addNewLine(input: string): string {\n return input.replace(/ /g, '\\r\\n');\n }\n\n updatePolygons = (features: any[]) => {\n features.map(async (feature: any) => {\n const coordinates = feature.geometry.coordinates;\n // const centroid = feature.properties.center;\n const polygon = turf.polygon(coordinates);\n const centroid = turf.centroid(polygon).geometry.coordinates;\n // const modelPosition = projectToWorld(centroid);\n\n // const vertex1 = projectToWorld(coordinates[0][0]);\n // const vertex2 = projectToWorld(coordinates[0][1]);\n // const angle = vertex1.angleTo(vertex2);\n // console.log(angle);\n\n // await modelLoader.loadModel({\n // modelPath: feature.properties.modelPath,\n // feature,\n // wrapper: wrapper.current!,\n // onProgress: (progress) => {\n // setLoadingProgress((prev) => ({\n // ...prev,\n // [feature.properties.id]: progress,\n // }));\n // },\n // onError: (error) => {\n // console.error(\n // `Failed to load model ${feature.properties.id}:`,\n // error\n // );\n // },\n // });\n\n if (\n !feature.properties.hasImage &&\n feature.properties.dimension_where &&\n feature.properties.dimension_where === 'where.lima.mahsuri_center.exhibition_floor'\n ) {\n const myText = new SpriteText();\n myText.color = 'black';\n let text = feature.properties.title;\n text = this.addNewLine(text);\n\n // Set properties to configure:\n myText.text = text;\n myText.textHeight = 100;\n // myText.textHeight = 1;\n // myText.backgroundColor = '';\n const textPosition = projectToWorld(centroid);\n myText.rotation.x = Math.PI;\n myText.rotation.y = Math.PI;\n myText.scale.set(0.1, 0.1, 0.01);\n\n myText.position.set(\n textPosition.x,\n textPosition.y,\n // feature.properties.height > 0 ? 0.4 : 0.25\n 0.1\n );\n this.threebox.add(myText);\n } else {\n // Load Texture\n // const textureLoader = new THREE.TextureLoader();\n // textureLoader.load('/sk.png', (texture: THREE.Texture) => {\n // // Create a plane geometry and material with the loaded texture\n // const geometry = new THREE.PlaneGeometry(\n // texture.image.width,\n // texture.image.height\n // );\n // geometry.computeBoundingBox();\n // const material = new THREE.MeshStandardMaterial({\n // map: texture,\n // transparent: true, // Enable transparency\n // opacity: 1,\n // });\n // const plane = new THREE.Mesh(geometry, material);\n // const group = new THREE.Group();\n // const childContainer = new THREE.Group();\n // childContainer.add(plane);\n // childContainer.rotateZ(Math.PI / 2);\n // childContainer.rotateZ(1);\n // childContainer.updateMatrixWorld();\n // group.add(childContainer);\n // const geojsonbbox = turf.bbox(polygon);\n // const bbox1 = new THREE.Box3(\n // projectToWorld([geojsonbbox[2], geojsonbbox[3]]),\n // projectToWorld([geojsonbbox[0], geojsonbbox[1]])\n // );\n // const bbox2 = new THREE.Box3().setFromObject(plane);\n // const size1 = new THREE.Vector3();\n // bbox1.getSize(size1);\n // size1.setZ(1);\n // const size2 = new THREE.Vector3();\n // bbox2.getSize(size2);\n // size2.setZ(1);\n // const ratio = size1.divide(size2);\n // const ratioCopy = ratio.clone().multiplyScalar(0.85);\n // plane.scale.set(\n // plane.scale.x * ratioCopy.x,\n // plane.scale.y * ratioCopy.y,\n // plane.scale.z * ratioCopy.z\n // );\n // // // Set the position of the plane to the centroid\n // group.position.set(modelPosition.x, modelPosition.y, 0.11);\n // this.threebox.add(group);\n // });\n }\n });\n };\n\n addLogo = (logo: string, position: THREE.Vector3) => {\n const textureLoader = new THREE.TextureLoader();\n const texture = textureLoader.load(logo);\n\n // Define rectangle dimensions\n const width = 4;\n const height = 0;\n const depth = 2;\n\n // Create a box geometry instead of cylinder\n const geometry = new THREE.BoxGeometry(width, height, depth);\n\n // Create materials: [right, left, top, bottom, front, back]\n const sideMaterial = new THREE.MeshBasicMaterial({ color: new THREE.Color(0xffffff) });\n const topMaterial = new THREE.MeshStandardMaterial({\n map: texture,\n side: THREE.DoubleSide,\n transparent: true\n });\n\n // Create an array of materials for each face of the box\n const materials = [\n sideMaterial, // right\n sideMaterial, // left\n topMaterial, // top (with logo texture)\n sideMaterial, // bottom\n sideMaterial, // front\n sideMaterial // back\n ];\n\n // Create the mesh with geometry and materials\n const logoMesh = new THREE.Mesh(geometry, materials);\n\n // Adjust rotation to match your previous orientation\n logoMesh.rotation.x = Math.PI / 2;\n logoMesh.rotation.y = -Math.PI / 1.45;\n logoMesh.position.set(position.x + 0.5, position.y - 0.3, position.z);\n\n this.threebox.add(logoMesh);\n\n return logoMesh;\n };\n\n // Function to add text using Troika Text library at a specified position\n addTitle = (title: string, position: THREE.Vector3) => {\n // Create a new Text instance\n const textMesh = new Text();\n\n // Configure text properties\n textMesh.text = title;\n textMesh.fontSize = 0.2;\n textMesh.color = 0x000000;\n textMesh.anchorX = '50%';\n textMesh.anchorY = 'bottom-baseline';\n textMesh.fontWeight = 'bold';\n textMesh.textAlign = 'center';\n\n textMesh.position.set(position.x, position.y, position.z);\n textMesh.rotation.z = -Math.PI / 1.45;\n\n // Add text to the scene\n this.threebox.add(textMesh);\n\n // Update the text rendering\n textMesh.sync();\n\n return textMesh;\n };\n}\n"],"mappings":";;;;;;AAEA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAIA,IAAAE,IAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,KAAA,GAAAD,uBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAP,sBAAA,CAAAC,OAAA;AAA0C,SAAAG,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,wBAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EA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GAAA;IAAAnC,KAAA,EAGA,SAAAoI,WAAWA,CAAA,EAAG;MACZ,OAAO,IAAI,CAAC9C,QAAQ;IACtB;EAAC;IAAAnD,GAAA;IAAAnC,KAAA,EAsCD,SAAA8E,UAAUA,CAACuD,KAAa,EAAU;MAChC,OAAOA,KAAK,CAACC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;IACpC;EAAC;AAAA;AAAAzG,eAAA,CAjGkBY,OAAO,kBACmB,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"MainMap.js","names":["_troikaThreeText","require","turf","_interopRequireWildcard","THREE","_utils","_threeSpritetext","_interopRequireDefault","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MainMap","mainInstance","constructor","metaAtlasCore","init","map2D","map","initThreebox","wrapper","CustomThreeJSWrapper","setEnvironment","addLayer","id","type","renderingMode","onAdd","console","log","render","update","threebox","getThreebox","getAllPolygonCoordinates","polygonFeatures","source","getSource","features","querySourceFeatures","sourceLayer","filter","length","forEach","feature","geometry","properties","dimension_what","push","mapObjectId","name","title","coordinates","hasImage","Math","round","random","addNewLine","input","replace","updatePolygons","polygon","centroid","dimension_where","myText","SpriteText","color","text","textHeight","textPosition","projectToWorld","rotation","x","PI","y","scale","position","add","addLogo","logo","textureLoader","TextureLoader","texture","load","width","height","depth","BoxGeometry","sideMaterial","MeshBasicMaterial","Color","topMaterial","MeshStandardMaterial","side","DoubleSide","transparent","materials","logoMesh","Mesh","z","addTitle","textMesh","Text","fontSize","anchorX","anchorY","fontWeight","textAlign","sync","exports"],"sources":["../../../../src/meta-atlas-sdk/3DMap/MainMap.ts"],"sourcesContent":["import { Map as MaplibreMap } from 'maplibre-gl';\n\nimport CustomThreeJSWrapper from './CustomThreeJsWrapper/CustomThreeJsWrapper';\nimport { Text } from 'troika-three-text';\n\nimport { EquirectangularReflectionMapping } from 'three';\nimport { MetaAtlasCore } from '../MetaAtlasCore/meta-atlas-sdk-core';\nimport * as turf from '@turf/turf';\nimport * as THREE from 'three';\nimport { projectToWorld } from './CustomThreeJsWrapper/utility/utils';\nimport SpriteText from 'three-spritetext';\nimport { HDRLoader } from 'three/examples/jsm/loaders/HDRLoader';\n\nexport default class MainMap {\n public static mainInstance: MainMap | null = null;\n public map!: MaplibreMap;\n public threebox!: CustomThreeJSWrapper;\n public metaAtlasCore!: MetaAtlasCore;\n\n constructor(metaAtlasCore: MetaAtlasCore) {\n if (MainMap.mainInstance) {\n return MainMap.mainInstance;\n }\n\n MainMap.mainInstance = this;\n\n this.metaAtlasCore = metaAtlasCore;\n }\n\n public init(map2D: MaplibreMap) {\n this.map = map2D;\n this.initThreebox();\n }\n\n /**\n * Creates a Threebox instance of the class.\n * @param map Maplibre instance to initialize threebox\n * @returns Threebox class instance created\n */\n private initThreebox() {\n const map = this.map;\n const wrapper = new CustomThreeJSWrapper(map);\n wrapper.setEnvironment();\n // const hdrLoader = new HDRLoader();\n // hdrLoader.load('./golden_gate_hills_1k.hdr', texture => {\n // texture.mapping = EquirectangularReflectionMapping;\n // wrapper.scene.environment = texture;\n // });\n\n map.addLayer({\n id: '3d-model-layer',\n type: 'custom',\n renderingMode: '3d',\n onAdd: () => {\n console.log('onAdd _initThreebox');\n },\n render: () => {\n wrapper.update();\n }\n });\n\n this.threebox = wrapper;\n return wrapper;\n }\n\n /**\n * Get the threebox instance for 3D model operations\n */\n getThreebox() {\n return this.threebox;\n }\n\n getAllPolygonCoordinates = () => {\n const map = this.map;\n\n if (!map) return [];\n\n const polygonFeatures: any[] = [];\n const source = map.getSource('custom');\n if (source) {\n const features = map.querySourceFeatures('custom', {\n sourceLayer: 'geojson',\n filter: ['==', ['geometry-type'], 'Polygon']\n });\n\n if (features && features.length > 0) {\n features.forEach(feature => {\n if (\n (feature.geometry.type === 'Polygon' || feature.geometry.type === 'MultiPolygon') &&\n feature.properties.dimension_what === 'what.booth'\n ) {\n polygonFeatures.push({\n id: feature.properties.mapObjectId,\n name: feature.properties?.title || 'Unnamed Polygon',\n coordinates: feature.geometry.coordinates,\n properties: {\n ...feature.properties,\n hasImage: !!Math.round(Math.random())\n }\n });\n }\n });\n }\n }\n\n return polygonFeatures;\n };\n\n addNewLine(input: string): string {\n return input.replace(/ /g, '\\r\\n');\n }\n\n updatePolygons = (features: any[]) => {\n features.map(async (feature: any) => {\n const coordinates = feature.geometry.coordinates;\n // const centroid = feature.properties.center;\n const polygon = turf.polygon(coordinates);\n const centroid = turf.centroid(polygon).geometry.coordinates;\n // const modelPosition = projectToWorld(centroid);\n\n // const vertex1 = projectToWorld(coordinates[0][0]);\n // const vertex2 = projectToWorld(coordinates[0][1]);\n // const angle = vertex1.angleTo(vertex2);\n // console.log(angle);\n\n // await modelLoader.loadModel({\n // modelPath: feature.properties.modelPath,\n // feature,\n // wrapper: wrapper.current!,\n // onProgress: (progress) => {\n // setLoadingProgress((prev) => ({\n // ...prev,\n // [feature.properties.id]: progress,\n // }));\n // },\n // onError: (error) => {\n // console.error(\n // `Failed to load model ${feature.properties.id}:`,\n // error\n // );\n // },\n // });\n\n if (\n !feature.properties.hasImage &&\n feature.properties.dimension_where &&\n feature.properties.dimension_where === 'where.lima.mahsuri_center.exhibition_floor'\n ) {\n const myText = new SpriteText();\n myText.color = 'black';\n let text = feature.properties.title;\n text = this.addNewLine(text);\n\n // Set properties to configure:\n myText.text = text;\n myText.textHeight = 100;\n // myText.textHeight = 1;\n // myText.backgroundColor = '';\n const textPosition = projectToWorld(centroid);\n myText.rotation.x = Math.PI;\n myText.rotation.y = Math.PI;\n myText.scale.set(0.1, 0.1, 0.01);\n\n myText.position.set(\n textPosition.x,\n textPosition.y,\n // feature.properties.height > 0 ? 0.4 : 0.25\n 0.1\n );\n this.threebox.add(myText);\n } else {\n // Load Texture\n // const textureLoader = new THREE.TextureLoader();\n // textureLoader.load('/sk.png', (texture: THREE.Texture) => {\n // // Create a plane geometry and material with the loaded texture\n // const geometry = new THREE.PlaneGeometry(\n // texture.image.width,\n // texture.image.height\n // );\n // geometry.computeBoundingBox();\n // const material = new THREE.MeshStandardMaterial({\n // map: texture,\n // transparent: true, // Enable transparency\n // opacity: 1,\n // });\n // const plane = new THREE.Mesh(geometry, material);\n // const group = new THREE.Group();\n // const childContainer = new THREE.Group();\n // childContainer.add(plane);\n // childContainer.rotateZ(Math.PI / 2);\n // childContainer.rotateZ(1);\n // childContainer.updateMatrixWorld();\n // group.add(childContainer);\n // const geojsonbbox = turf.bbox(polygon);\n // const bbox1 = new THREE.Box3(\n // projectToWorld([geojsonbbox[2], geojsonbbox[3]]),\n // projectToWorld([geojsonbbox[0], geojsonbbox[1]])\n // );\n // const bbox2 = new THREE.Box3().setFromObject(plane);\n // const size1 = new THREE.Vector3();\n // bbox1.getSize(size1);\n // size1.setZ(1);\n // const size2 = new THREE.Vector3();\n // bbox2.getSize(size2);\n // size2.setZ(1);\n // const ratio = size1.divide(size2);\n // const ratioCopy = ratio.clone().multiplyScalar(0.85);\n // plane.scale.set(\n // plane.scale.x * ratioCopy.x,\n // plane.scale.y * ratioCopy.y,\n // plane.scale.z * ratioCopy.z\n // );\n // // // Set the position of the plane to the centroid\n // group.position.set(modelPosition.x, modelPosition.y, 0.11);\n // this.threebox.add(group);\n // });\n }\n });\n };\n\n addLogo = (logo: string, position: THREE.Vector3) => {\n const textureLoader = new THREE.TextureLoader();\n const texture = textureLoader.load(logo);\n\n // Define rectangle dimensions\n const width = 4;\n const height = 0;\n const depth = 2;\n\n // Create a box geometry instead of cylinder\n const geometry = new THREE.BoxGeometry(width, height, depth);\n\n // Create materials: [right, left, top, bottom, front, back]\n const sideMaterial = new THREE.MeshBasicMaterial({ color: new THREE.Color(0xffffff) });\n const topMaterial = new THREE.MeshStandardMaterial({\n map: texture,\n side: THREE.DoubleSide,\n transparent: true\n });\n\n // Create an array of materials for each face of the box\n const materials = [\n sideMaterial, // right\n sideMaterial, // left\n topMaterial, // top (with logo texture)\n sideMaterial, // bottom\n sideMaterial, // front\n sideMaterial // back\n ];\n\n // Create the mesh with geometry and materials\n const logoMesh = new THREE.Mesh(geometry, materials);\n\n // Adjust rotation to match your previous orientation\n logoMesh.rotation.x = Math.PI / 2;\n logoMesh.rotation.y = -Math.PI / 1.45;\n logoMesh.position.set(position.x + 0.5, position.y - 0.3, position.z);\n\n this.threebox.add(logoMesh);\n\n return logoMesh;\n };\n\n // Function to add text using Troika Text library at a specified position\n addTitle = (title: string, position: THREE.Vector3) => {\n // Create a new Text instance\n const textMesh = new Text();\n\n // Configure text properties\n textMesh.text = title;\n textMesh.fontSize = 0.2;\n textMesh.color = 0x000000;\n textMesh.anchorX = '50%';\n textMesh.anchorY = 'bottom-baseline';\n textMesh.fontWeight = 'bold';\n textMesh.textAlign = 'center';\n\n textMesh.position.set(position.x, position.y, position.z);\n textMesh.rotation.z = -Math.PI / 1.45;\n\n // Add text to the scene\n this.threebox.add(textMesh);\n\n // Update the text rendering\n textMesh.sync();\n\n return textMesh;\n };\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAIA,IAAAC,IAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAD,uBAAA,CAAAF,OAAA;AAA+B,IAAAI,MAAA,GAAAJ,OAAA;AAE/B,IAAAK,gBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAA0C,SAAAE,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAA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AAK;IACxBH,QAAQ,CAACI,OAAO,GAAG,iBAAiB;IACpCJ,QAAQ,CAACK,UAAU,GAAG,MAAM;IAC5BL,QAAQ,CAACM,SAAS,GAAG,QAAQ;IAE7BN,QAAQ,CAACzB,QAAQ,CAACtE,GAAG,CAACsE,QAAQ,CAACJ,CAAC,EAAEI,QAAQ,CAACF,CAAC,EAAEE,QAAQ,CAACuB,CAAC,CAAC;IACzDE,QAAQ,CAAC9B,QAAQ,CAAC4B,CAAC,GAAG,CAAC7C,IAAI,CAACmB,EAAE,GAAG,IAAI;;IAErC;IACA,IAAI,CAACzC,QAAQ,CAAC6C,GAAG,CAACwB,QAAQ,CAAC;;IAE3B;IACAA,QAAQ,CAACO,IAAI,CAAC,CAAC;IAEf,OAAOP,QAAQ;EACjB,CAAC;AACH;AAACQ,OAAA,CAAA1G,OAAA,GAAAS,OAAA","ignoreList":[]}
@@ -6,20 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Status = exports.PublishedDataType = void 0;
7
7
  exports.getPublishedData = getPublishedData;
8
8
  var _axios = _interopRequireDefault(require("axios"));
9
- var _helpers = require("../utils/helpers");
10
- var _routingStore = _interopRequireDefault(require("../utils/routing-store"));
11
- var _mapobjectsStore = _interopRequireDefault(require("../utils/mapobjects-store"));
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
14
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
15
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
16
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
17
- var PublishedDataType = exports.PublishedDataType = /*#__PURE__*/function (PublishedDataType) {
9
+ var _helpers = require("../utils/helpers.js");
10
+ var _routingStore = _interopRequireDefault(require("../utils/routing-store.js"));
11
+ var _mapobjectsStore = _interopRequireDefault(require("../utils/mapobjects-store.js"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ let PublishedDataType = exports.PublishedDataType = /*#__PURE__*/function (PublishedDataType) {
18
14
  PublishedDataType["Routing"] = "routing";
19
15
  PublishedDataType["MapObjects"] = "mapObjects";
20
16
  return PublishedDataType;
21
17
  }({});
22
- var Status = exports.Status = /*#__PURE__*/function (Status) {
18
+ let Status = exports.Status = /*#__PURE__*/function (Status) {
23
19
  Status["Ready"] = "Ready";
24
20
  Status["Awaiting"] = "Awaiting";
25
21
  Status["DownloadingResources"] = "DownloadingResources";
@@ -37,8 +33,8 @@ function getDataType(publishedDataType) {
37
33
  function getLocalStorageKey(param, publishedDataType) {
38
34
  return publishedDataType.valueOf() + param;
39
35
  }
40
- var setRouteData = _routingStore["default"].setState;
41
- var setMapObjectsData = _mapobjectsStore["default"].setState;
36
+ const setRouteData = _routingStore.default.setState;
37
+ const setMapObjectsData = _mapobjectsStore.default.setState;
42
38
  function getRunTimeStore(publishedDataType) {
43
39
  if (publishedDataType === PublishedDataType.Routing) {
44
40
  return setRouteData;
@@ -47,213 +43,169 @@ function getRunTimeStore(publishedDataType) {
47
43
  return setMapObjectsData;
48
44
  }
49
45
  }
50
- function getPublishedData(_x, _x2) {
51
- return _getPublishedData.apply(this, arguments);
52
- }
53
- function _getPublishedData() {
54
- _getPublishedData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(serverAPIInfo, localStorage) {
55
- var publishedDataType, localStorageVersionKey, status, setRunTimeStoreData, fetchInfo, storeFileToLocalStorage, loadFileFromStore, onError, info, response, responseData, data, tag, decryptedJson, storedSuccessfully, _tag, _decryptedJson, _t, _t2;
56
- return _regenerator().w(function (_context2) {
57
- while (1) switch (_context2.p = _context2.n) {
58
- case 0:
59
- publishedDataType = serverAPIInfo.publishedDataType;
60
- localStorageVersionKey = getLocalStorageKey('version', publishedDataType);
61
- status = Status.Awaiting;
62
- setRunTimeStoreData = getRunTimeStore(publishedDataType);
63
- fetchInfo = /*#__PURE__*/function () {
64
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
65
- var currentVersion;
66
- return _regenerator().w(function (_context) {
67
- while (1) switch (_context.n) {
68
- case 0:
69
- currentVersion = localStorage.contains(localStorageVersionKey) ? localStorage.getString(localStorageVersionKey) : '0.0.0';
70
- return _context.a(2, new Promise(function (resolve, reject) {
71
- (0, _axios["default"])({
72
- url: "".concat(serverAPIInfo.URL, "/check-published-versions"),
73
- headers: {
74
- Authorization: "Bearer ".concat(serverAPIInfo.accessToken),
75
- 'Content-Type': 'application/json'
76
- },
77
- method: 'POST',
78
- data: JSON.stringify({
79
- version: currentVersion,
80
- dataType: getDataType(serverAPIInfo.publishedDataType)
81
- })
82
- }).then(function (response) {
83
- var remoteData = response.data;
84
- var publishedDataInfo = {
85
- currentVersion: undefined,
86
- remoteVersion: undefined,
87
- URL: undefined,
88
- data: undefined
89
- };
90
- var localVersion = localStorage.getString(localStorageVersionKey);
91
- var remoteVersion = localVersion;
92
- if (remoteData.hasOwnProperty('version')) {
93
- remoteVersion = remoteData.version;
94
- }
95
- publishedDataInfo.currentVersion = localVersion;
96
- publishedDataInfo.remoteVersion = remoteVersion;
97
- if (localVersion) {
98
- var currentData = localStorage.getString(getLocalStorageKey('data', publishedDataType));
99
- var tag = localStorage.getString(getLocalStorageKey('encryptionTag', publishedDataType));
46
+ async function getPublishedData(serverAPIInfo, localStorage) {
47
+ const publishedDataType = serverAPIInfo.publishedDataType;
48
+ const localStorageVersionKey = getLocalStorageKey('version', publishedDataType);
49
+ let status = Status.Awaiting;
50
+ let setRunTimeStoreData = getRunTimeStore(publishedDataType);
51
+ const fetchInfo = async () => {
52
+ const currentVersion = localStorage.contains(localStorageVersionKey) ? localStorage.getString(localStorageVersionKey) : '0.0.0';
53
+ return new Promise((resolve, reject) => {
54
+ (0, _axios.default)({
55
+ url: `${serverAPIInfo.URL}/check-published-versions`,
56
+ headers: {
57
+ Authorization: `Bearer ${serverAPIInfo.accessToken}`,
58
+ 'Content-Type': 'application/json'
59
+ },
60
+ method: 'POST',
61
+ data: JSON.stringify({
62
+ version: currentVersion,
63
+ dataType: getDataType(serverAPIInfo.publishedDataType)
64
+ })
65
+ }).then(response => {
66
+ const remoteData = response.data;
67
+ const publishedDataInfo = {
68
+ currentVersion: undefined,
69
+ remoteVersion: undefined,
70
+ URL: undefined,
71
+ data: undefined
72
+ };
73
+ const localVersion = localStorage.getString(localStorageVersionKey);
74
+ let remoteVersion = localVersion;
75
+ if (remoteData.hasOwnProperty('version')) {
76
+ remoteVersion = remoteData.version;
77
+ }
78
+ publishedDataInfo.currentVersion = localVersion;
79
+ publishedDataInfo.remoteVersion = remoteVersion;
80
+ if (localVersion) {
81
+ const currentData = localStorage.getString(getLocalStorageKey('data', publishedDataType));
82
+ const tag = localStorage.getString(getLocalStorageKey('encryptionTag', publishedDataType));
100
83
 
101
- // Check both because data is useless without tag
102
- if (tag && currentData) {
103
- publishedDataInfo.data = currentData;
104
- }
105
- }
106
- if (remoteVersion) {
107
- if (remoteData.hasOwnProperty('downloadUrl')) {
108
- publishedDataInfo.URL = remoteData.downloadUrl;
109
- }
110
- if (localVersion && remoteVersion > localVersion || !localVersion || !publishedDataInfo.data) {
111
- status = publishedDataInfo.URL ? Status.DownloadingResources : status;
112
- }
113
- }
114
- console.log('final: ', publishedDataInfo.URL, publishedDataInfo.currentVersion, publishedDataInfo.remoteVersion);
115
- resolve(publishedDataInfo);
116
- })["catch"](function (error) {
117
- console.log('error while fetching published version: ');
118
- if (error.response) {
119
- // The request was made and the server responded with a status code
120
- // that falls out of the range of 2xx
121
- console.log(error.response.data);
122
- console.log(error.response.status);
123
- console.log(error.response.headers);
124
- } else if (error.request) {
125
- // The request was made but no response was received
126
- // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
127
- // http.ClientRequest in node.js
128
- console.log(error.request);
129
- } else {
130
- // Something happened in setting up the request that triggered an Error
131
- console.log('Error', error.message);
132
- }
133
- console.log(error.config);
134
- reject(error);
135
- });
136
- }));
137
- }
138
- }, _callee);
139
- }));
140
- return function fetchInfo() {
141
- return _ref.apply(this, arguments);
142
- };
143
- }();
144
- storeFileToLocalStorage = function storeFileToLocalStorage(data, version, tag) {
145
- try {
146
- localStorage.set(getLocalStorageKey('data', publishedDataType), data);
147
- localStorage.set(localStorageVersionKey, version);
148
- localStorage.set(getLocalStorageKey('encryptionTag', publishedDataType), tag);
149
- return true;
150
- } catch (e) {
151
- console.log('error storing routing file from local storage', e);
152
- return false;
153
- }
154
- };
155
- loadFileFromStore = function loadFileFromStore() {
156
- var currentData = localStorage.getString(getLocalStorageKey('data', publishedDataType));
157
- var tag = localStorage.getString(getLocalStorageKey('encryptionTag', publishedDataType));
158
- if (currentData && tag) {
159
- var decryptedJson = (0, _helpers.decryptFile)(currentData, tag, serverAPIInfo.secretKey);
160
- // JSON.parse(storage.getString('routeData')
161
- setRunTimeStoreData({
162
- data: decryptedJson
163
- });
164
- status = Status.Ready;
165
- return true;
166
- } else {
167
- return false;
168
- }
169
- };
170
- onError = function onError() {
171
- try {
172
- var _loaded = loadFileFromStore();
173
- if (!_loaded) {
174
- console.log('failed to load data');
175
- status = Status.Unavailable;
176
- }
177
- } catch (error) {
178
- console.log('erro while loading data');
179
- status = Status.Unavailable;
180
- localStorage.clearAll();
181
- }
182
- };
183
- _context2.p = 1;
184
- _context2.n = 2;
185
- return fetchInfo();
186
- case 2:
187
- info = _context2.v;
188
- if (!(status === Status.DownloadingResources && info.URL)) {
189
- _context2.n = 10;
190
- break;
191
- }
192
- // download
193
- console.log('downloading from server');
194
- _context2.p = 3;
195
- _context2.n = 4;
196
- return fetch(info.URL);
197
- case 4:
198
- response = _context2.v;
199
- if (response.ok) {
200
- _context2.n = 5;
201
- break;
84
+ // Check both because data is useless without tag
85
+ if (tag && currentData) {
86
+ publishedDataInfo.data = currentData;
202
87
  }
203
- throw new Error("HTTP error! Status: ".concat(response.status));
204
- case 5:
205
- _context2.n = 6;
206
- return response.json();
207
- case 6:
208
- responseData = _context2.v;
209
- // const responseData = JSON.parse(fileContent);
210
- data = responseData.data, tag = responseData.tag;
211
- _context2.n = 7;
212
- return (0, _helpers.decryptFile)(data, tag, serverAPIInfo.secretKey);
213
- case 7:
214
- decryptedJson = _context2.v;
215
- storedSuccessfully = storeFileToLocalStorage(data, info.remoteVersion, tag);
216
- if (storedSuccessfully) {
217
- console.log('loaded file');
218
- setRunTimeStoreData({
219
- data: decryptedJson
220
- });
221
- status = Status.Ready;
88
+ }
89
+ if (remoteVersion) {
90
+ if (remoteData.hasOwnProperty('downloadUrl')) {
91
+ publishedDataInfo.URL = remoteData.downloadUrl;
222
92
  }
223
- _context2.n = 9;
224
- break;
225
- case 8:
226
- _context2.p = 8;
227
- _t = _context2.v;
228
- console.error('Error fetching and decrypting data:', _t);
229
- onError();
230
- case 9:
231
- _context2.n = 11;
232
- break;
233
- case 10:
234
- _tag = localStorage.getString('encryptionTag'); // set to store
235
- if (info.data && _tag) {
236
- console.log('loaded local file');
237
- _decryptedJson = (0, _helpers.decryptFile)(info.data, _tag, serverAPIInfo.secretKey);
238
- setRunTimeStoreData({
239
- data: _decryptedJson
240
- });
241
- status = Status.Ready;
242
- } else {
243
- onError();
93
+ if (localVersion && remoteVersion > localVersion || !localVersion || !publishedDataInfo.data) {
94
+ status = publishedDataInfo.URL ? Status.DownloadingResources : status;
244
95
  }
245
- case 11:
246
- _context2.n = 13;
247
- break;
248
- case 12:
249
- _context2.p = 12;
250
- _t2 = _context2.v;
251
- onError();
252
- case 13:
253
- return _context2.a(2, status);
96
+ }
97
+ console.log('final: ', publishedDataInfo.URL, publishedDataInfo.currentVersion, publishedDataInfo.remoteVersion);
98
+ resolve(publishedDataInfo);
99
+ }).catch(function (error) {
100
+ console.log('error while fetching published version: ');
101
+ if (error.response) {
102
+ // The request was made and the server responded with a status code
103
+ // that falls out of the range of 2xx
104
+ console.log(error.response.data);
105
+ console.log(error.response.status);
106
+ console.log(error.response.headers);
107
+ } else if (error.request) {
108
+ // The request was made but no response was received
109
+ // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
110
+ // http.ClientRequest in node.js
111
+ console.log(error.request);
112
+ } else {
113
+ // Something happened in setting up the request that triggered an Error
114
+ console.log('Error', error.message);
115
+ }
116
+ console.log(error.config);
117
+ reject(error);
118
+ });
119
+ });
120
+ };
121
+ const storeFileToLocalStorage = (data, version, tag) => {
122
+ try {
123
+ localStorage.set(getLocalStorageKey('data', publishedDataType), data);
124
+ localStorage.set(localStorageVersionKey, version);
125
+ localStorage.set(getLocalStorageKey('encryptionTag', publishedDataType), tag);
126
+ return true;
127
+ } catch (e) {
128
+ console.log('error storing routing file from local storage', e);
129
+ return false;
130
+ }
131
+ };
132
+ const loadFileFromStore = () => {
133
+ const currentData = localStorage.getString(getLocalStorageKey('data', publishedDataType));
134
+ const tag = localStorage.getString(getLocalStorageKey('encryptionTag', publishedDataType));
135
+ if (currentData && tag) {
136
+ const decryptedJson = (0, _helpers.decryptFile)(currentData, tag, serverAPIInfo.secretKey);
137
+ // JSON.parse(storage.getString('routeData')
138
+ setRunTimeStoreData({
139
+ data: decryptedJson
140
+ });
141
+ status = Status.Ready;
142
+ return true;
143
+ } else {
144
+ return false;
145
+ }
146
+ };
147
+ const onError = () => {
148
+ try {
149
+ const loaded = loadFileFromStore();
150
+ if (!loaded) {
151
+ console.log('failed to load data');
152
+ status = Status.Unavailable;
153
+ }
154
+ } catch (error) {
155
+ console.log('erro while loading data');
156
+ status = Status.Unavailable;
157
+ localStorage.clearAll();
158
+ }
159
+ };
160
+ try {
161
+ const info = await fetchInfo();
162
+ // @ts-ignore
163
+ if (status === Status.DownloadingResources && info.URL) {
164
+ // download
165
+ console.log('downloading from server');
166
+ try {
167
+ // Fetch encrypted data from the server
168
+ // This is the API call for getting map-objects.json
169
+ const response = await fetch(info.URL);
170
+ if (!response.ok) {
171
+ throw new Error(`HTTP error! Status: ${response.status}`);
172
+ }
173
+ const responseData = await response.json();
174
+ // const responseData = JSON.parse(fileContent);
175
+ const {
176
+ data,
177
+ tag
178
+ } = responseData;
179
+ const decryptedJson = await (0, _helpers.decryptFile)(data, tag, serverAPIInfo.secretKey);
180
+ const storedSuccessfully = storeFileToLocalStorage(data, info.remoteVersion, tag);
181
+ if (storedSuccessfully) {
182
+ console.log('loaded file');
183
+ setRunTimeStoreData({
184
+ data: decryptedJson
185
+ });
186
+ status = Status.Ready;
187
+ }
188
+ } catch (error) {
189
+ console.error('Error fetching and decrypting data:', error);
190
+ onError();
254
191
  }
255
- }, _callee2, null, [[3, 8], [1, 12]]);
256
- }));
257
- return _getPublishedData.apply(this, arguments);
192
+ } else {
193
+ const tag = localStorage.getString('encryptionTag');
194
+ // set to store
195
+ if (info.data && tag) {
196
+ console.log('loaded local file');
197
+ const decryptedJson = (0, _helpers.decryptFile)(info.data, tag, serverAPIInfo.secretKey);
198
+ setRunTimeStoreData({
199
+ data: decryptedJson
200
+ });
201
+ status = Status.Ready;
202
+ } else {
203
+ onError();
204
+ }
205
+ }
206
+ } catch (error) {
207
+ onError();
208
+ }
209
+ return status;
258
210
  }
259
211
  //# sourceMappingURL=fetch-published-json.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-published-json.js","names":["_axios","_interopRequireDefault","require","_helpers","_routingStore","_mapobjectsStore","e","__esModule","_regenerator","t","r","Symbol","n","iterator","o","toStringTag","i","c","prototype","Generator","u","Object","create","_regeneratorDefine2","f","p","y","G","v","a","d","bind","length","l","TypeError","call","done","value","GeneratorFunction","GeneratorFunctionPrototype","getPrototypeOf","setPrototypeOf","__proto__","displayName","w","m","defineProperty","_regeneratorDefine","_invoke","enumerable","configurable","writable","asyncGeneratorStep","Promise","resolve","then","_asyncToGenerator","arguments","apply","_next","_throw","PublishedDataType","exports","Status","getDataType","publishedDataType","Routing","MapObjects","getLocalStorageKey","param","valueOf","setRouteData","useRouteDataStore","setState","setMapObjectsData","useMapObjectsDataStore","getRunTimeStore","getPublishedData","_x","_x2","_getPublishedData","_callee2","serverAPIInfo","localStorage","localStorageVersionKey","status","setRunTimeStoreData","fetchInfo","storeFileToLocalStorage","loadFileFromStore","onError","info","response","responseData","data","tag","decryptedJson","storedSuccessfully","_tag","_decryptedJson","_t","_t2","_context2","Awaiting","_ref","_callee","currentVersion","_context","contains","getString","reject","axios","url","concat","URL","headers","Authorization","accessToken","method","JSON","stringify","version","dataType","remoteData","publishedDataInfo","undefined","remoteVersion","localVersion","hasOwnProperty","currentData","downloadUrl","DownloadingResources","console","log","error","request","message","config","set","decryptFile","secretKey","Ready","loaded","Unavailable","clearAll","fetch","ok","Error","json"],"sources":["../../../../src/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.ts"],"sourcesContent":["import axios from 'axios';\n\nimport { LocalStorage } from '../utils/local-storage';\nimport { decryptFile } from '../utils/helpers';\nimport useRouteDataStore from '../utils/routing-store';\nimport useMapObjectsDataStore from '../utils/mapobjects-store';\n\nexport enum PublishedDataType {\n Routing = 'routing',\n MapObjects = 'mapObjects',\n}\n\nexport enum Status {\n Ready = 'Ready',\n Awaiting = 'Awaiting',\n DownloadingResources = 'DownloadingResources',\n Unavailable = 'Unavailable',\n}\n\nexport type StatusUpdateCallbackType = (loaded: boolean) => void;\n\nexport interface ServerAPIInfo {\n URL: string;\n accessToken: string;\n secretKey: string;\n publishedDataType: PublishedDataType;\n}\n\nexport interface PublishedDataInfo {\n currentVersion: string | undefined;\n remoteVersion: string | undefined;\n URL: string | undefined;\n data: string | undefined;\n}\n\nfunction getDataType(publishedDataType: PublishedDataType) {\n if (publishedDataType === PublishedDataType.Routing) {\n return 'generate-route-json-per-role';\n }\n if (publishedDataType === PublishedDataType.MapObjects) {\n return 'generate-map-objects-per-role';\n }\n}\n\nfunction getLocalStorageKey(\n param: string,\n publishedDataType: PublishedDataType,\n): string {\n return publishedDataType.valueOf() + param;\n}\n\nconst setRouteData = useRouteDataStore.setState;\nconst setMapObjectsData = useMapObjectsDataStore.setState;\n\nfunction getRunTimeStore(publishedDataType: PublishedDataType) {\n if (publishedDataType === PublishedDataType.Routing) {\n return setRouteData;\n }\n if (publishedDataType === PublishedDataType.MapObjects) {\n return setMapObjectsData;\n }\n}\n\nexport async function getPublishedData(\n serverAPIInfo: ServerAPIInfo,\n localStorage: LocalStorage,\n) {\n const publishedDataType = serverAPIInfo.publishedDataType;\n const localStorageVersionKey = getLocalStorageKey(\n 'version',\n publishedDataType,\n );\n let status: Status = Status.Awaiting;\n let setRunTimeStoreData = getRunTimeStore(publishedDataType);\n\n const fetchInfo = async () => {\n const currentVersion = localStorage.contains(localStorageVersionKey)\n ? localStorage.getString(localStorageVersionKey)\n : '0.0.0';\n return new Promise(\n (resolve: (routingInfo: PublishedDataInfo) => void, reject) => {\n axios({\n url: `${serverAPIInfo.URL}/check-published-versions`,\n headers: {\n Authorization: `Bearer ${serverAPIInfo.accessToken}`,\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n data: JSON.stringify({\n version: currentVersion,\n dataType: getDataType(serverAPIInfo.publishedDataType),\n }),\n })\n .then(response => {\n const remoteData = response.data;\n\n const publishedDataInfo = {\n currentVersion: undefined,\n remoteVersion: undefined,\n URL: undefined,\n data: undefined,\n } as PublishedDataInfo;\n const localVersion = localStorage.getString(localStorageVersionKey);\n let remoteVersion = localVersion;\n if (remoteData.hasOwnProperty('version')) {\n remoteVersion = remoteData.version;\n }\n\n publishedDataInfo.currentVersion = localVersion;\n publishedDataInfo.remoteVersion = remoteVersion;\n if (localVersion) {\n const currentData = localStorage.getString(\n getLocalStorageKey('data', publishedDataType),\n );\n const tag = localStorage.getString(\n getLocalStorageKey('encryptionTag', publishedDataType),\n );\n\n // Check both because data is useless without tag\n if (tag && currentData) {\n publishedDataInfo.data = currentData;\n }\n }\n if (remoteVersion) {\n if (remoteData.hasOwnProperty('downloadUrl')) {\n publishedDataInfo.URL = remoteData.downloadUrl;\n }\n if (\n (localVersion && remoteVersion > localVersion) ||\n !localVersion ||\n !publishedDataInfo.data\n ) {\n status = publishedDataInfo.URL\n ? Status.DownloadingResources\n : status;\n }\n }\n\n console.log(\n 'final: ',\n publishedDataInfo.URL,\n publishedDataInfo.currentVersion,\n publishedDataInfo.remoteVersion,\n );\n resolve(publishedDataInfo);\n })\n .catch(function (error) {\n console.log('error while fetching published version: ');\n if (error.response) {\n // The request was made and the server responded with a status code\n // that falls out of the range of 2xx\n console.log(error.response.data);\n console.log(error.response.status);\n console.log(error.response.headers);\n } else if (error.request) {\n // The request was made but no response was received\n // `error.request` is an instance of XMLHttpRequest in the browser and an instance of\n // http.ClientRequest in node.js\n console.log(error.request);\n } else {\n // Something happened in setting up the request that triggered an Error\n console.log('Error', error.message);\n }\n console.log(error.config);\n reject(error);\n });\n },\n );\n };\n\n const storeFileToLocalStorage = (data: any, version: any, tag: any) => {\n try {\n localStorage.set(getLocalStorageKey('data', publishedDataType), data);\n localStorage.set(localStorageVersionKey, version);\n localStorage.set(\n getLocalStorageKey('encryptionTag', publishedDataType),\n tag,\n );\n return true;\n } catch (e) {\n console.log('error storing routing file from local storage', e);\n return false;\n }\n };\n\n const loadFileFromStore = () => {\n const currentData = localStorage.getString(\n getLocalStorageKey('data', publishedDataType),\n );\n const tag = localStorage.getString(\n getLocalStorageKey('encryptionTag', publishedDataType),\n );\n if (currentData && tag) {\n const decryptedJson = decryptFile(currentData, tag, serverAPIInfo.secretKey);\n // JSON.parse(storage.getString('routeData')\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n return true;\n } else {\n return false;\n }\n };\n\n const onError = () => {\n try {\n const loaded = loadFileFromStore();\n if (!loaded) {\n console.log('failed to load data');\n status = Status.Unavailable;\n }\n } catch (error) {\n console.log('erro while loading data');\n status = Status.Unavailable;\n localStorage.clearAll();\n }\n };\n\n try {\n const info = await fetchInfo();\n // @ts-ignore\n if (status === Status.DownloadingResources && info.URL) {\n // download\n console.log('downloading from server');\n try {\n // Fetch encrypted data from the server\n // This is the API call for getting map-objects.json\n const response = await fetch(info.URL);\n if (!response.ok) {\n throw new Error(`HTTP error! Status: ${response.status}`);\n }\n const responseData = await response.json();\n // const responseData = JSON.parse(fileContent);\n const {data, tag} = responseData;\n\n const decryptedJson = await decryptFile(data, tag, serverAPIInfo.secretKey);\n const storedSuccessfully = storeFileToLocalStorage(\n data,\n info.remoteVersion,\n tag,\n );\n if (storedSuccessfully) {\n console.log('loaded file');\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n }\n } catch (error) {\n console.error('Error fetching and decrypting data:', error);\n onError();\n }\n } else {\n const tag = localStorage.getString('encryptionTag');\n // set to store\n if (info.data && tag) {\n console.log('loaded local file');\n const decryptedJson = decryptFile(info.data, tag, serverAPIInfo.secretKey);\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n } else {\n onError();\n }\n }\n } catch (error) {\n onError();\n }\n\n return status;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,gBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAA+D,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAAA,SAAAE,aAAA,IAJ/D,uKAAAF,CAAA,EAAAG,CAAA,EAAAC,CAAA,wBAAAC,MAAA,GAAAA,MAAA,OAAAC,CAAA,GAAAF,CAAA,CAAAG,QAAA,kBAAAC,CAAA,GAAAJ,CAAA,CAAAK,WAAA,8BAAAC,EAAAN,CAAA,EAAAE,CAAA,EAAAE,CAAA,EAAAE,CAAA,QAAAC,CAAA,GAAAL,CAAA,IAAAA,CAAA,CAAAM,SAAA,YAAAC,SAAA,GAAAP,CAAA,GAAAO,SAAA,EAAAC,CAAA,GAAAC,MAAA,CAAAC,MAAA,CAAAL,CAAA,CAAAC,SAAA,UAAAK,mBAAA,CAAAH,CAAA,uBAAAV,CAAA,EAAAE,CAAA,EAAAE,CAAA,QAAAE,CAAA,EAAAC,CAAA,EAAAG,CAAA,EAAAI,CAAA,MAAAC,CAAA,GAAAX,CAAA,QAAAY,CAAA,OAAAC,CAAA,KAAAF,CAAA,KAAAb,CAAA,KAAAgB,CAAA,EAAAtB,CAAA,EAAAuB,CAAA,EAAAC,CAAA,EAAAN,CAAA,EAAAM,CAAA,CAAAC,IAAA,CAAAzB,CAAA,MAAAwB,CAAA,WAAAA,EAAArB,CAAA,EAAAC,CAAA,WAAAM,CAAA,GAAAP,CAAA,EAAAQ,CAAA,MAAA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,EAAE;YACtBmC,OAAO,CAACC,GAAG,CAAC,aAAa,CAAC;YAC1B/C,mBAAmB,CAAC;cAACQ,IAAI,EAAEE;YAAa,CAAC,CAAC;YAC1CX,MAAM,GAAGtB,MAAM,CAAC8E,KAAK;UACvB;UAACvC,SAAA,CAAA1F,CAAA;UAAA;QAAA;UAAA0F,SAAA,CAAA7E,CAAA;UAAA2E,EAAA,GAAAE,SAAA,CAAA1E,CAAA;UAEDwG,OAAO,CAACE,KAAK,CAAC,qCAAqC,EAAAlC,EAAO,CAAC;UAC3DV,OAAO,CAAC,CAAC;QAAC;UAAAY,SAAA,CAAA1F,CAAA;UAAA;QAAA;UAGNmF,IAAG,GAAGZ,YAAY,CAAC0B,SAAS,CAAC,eAAe,CAAC,EACnD;UACA,IAAIlB,IAAI,CAACG,IAAI,IAAIC,IAAG,EAAE;YACpBqC,OAAO,CAACC,GAAG,CAAC,mBAAmB,CAAC;YAC1BrC,cAAa,GAAG,IAAA2C,oBAAW,EAAChD,IAAI,CAACG,IAAI,EAAEC,IAAG,EAAEb,aAAa,CAAC0D,SAAS,CAAC;YAC1EtD,mBAAmB,CAAC;cAACQ,IAAI,EAAEE;YAAa,CAAC,CAAC;YAC1CX,MAAM,GAAGtB,MAAM,CAAC8E,KAAK;UACvB,CAAC,MAAM;YACLnD,OAAO,CAAC,CAAC;UACX;QAAC;UAAAY,SAAA,CAAA1F,CAAA;UAAA;QAAA;UAAA0F,SAAA,CAAA7E,CAAA;UAAA4E,GAAA,GAAAC,SAAA,CAAA1E,CAAA;UAGH8D,OAAO,CAAC,CAAC;QAAC;UAAA,OAAAY,SAAA,CAAAzE,CAAA,IAGLwD,MAAM;MAAA;IAAA,GAAAJ,QAAA;EAAA,CACd;EAAA,OAAAD,iBAAA,CAAAtB,KAAA,OAAAD,SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"fetch-published-json.js","names":["_axios","_interopRequireDefault","require","_helpers","_routingStore","_mapobjectsStore","e","__esModule","default","PublishedDataType","exports","Status","getDataType","publishedDataType","Routing","MapObjects","getLocalStorageKey","param","valueOf","setRouteData","useRouteDataStore","setState","setMapObjectsData","useMapObjectsDataStore","getRunTimeStore","getPublishedData","serverAPIInfo","localStorage","localStorageVersionKey","status","Awaiting","setRunTimeStoreData","fetchInfo","currentVersion","contains","getString","Promise","resolve","reject","axios","url","URL","headers","Authorization","accessToken","method","data","JSON","stringify","version","dataType","then","response","remoteData","publishedDataInfo","undefined","remoteVersion","localVersion","hasOwnProperty","currentData","tag","downloadUrl","DownloadingResources","console","log","catch","error","request","message","config","storeFileToLocalStorage","set","loadFileFromStore","decryptedJson","decryptFile","secretKey","Ready","onError","loaded","Unavailable","clearAll","info","fetch","ok","Error","responseData","json","storedSuccessfully"],"sources":["../../../../src/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.ts"],"sourcesContent":["import axios from 'axios';\n\nimport { LocalStorage } from '../utils/local-storage';\nimport { decryptFile } from '../utils/helpers';\nimport useRouteDataStore from '../utils/routing-store';\nimport useMapObjectsDataStore from '../utils/mapobjects-store';\n\nexport enum PublishedDataType {\n Routing = 'routing',\n MapObjects = 'mapObjects',\n}\n\nexport enum Status {\n Ready = 'Ready',\n Awaiting = 'Awaiting',\n DownloadingResources = 'DownloadingResources',\n Unavailable = 'Unavailable',\n}\n\nexport type StatusUpdateCallbackType = (loaded: boolean) => void;\n\nexport interface ServerAPIInfo {\n URL: string;\n accessToken: string;\n secretKey: string;\n publishedDataType: PublishedDataType;\n}\n\nexport interface PublishedDataInfo {\n currentVersion: string | undefined;\n remoteVersion: string | undefined;\n URL: string | undefined;\n data: string | undefined;\n}\n\nfunction getDataType(publishedDataType: PublishedDataType) {\n if (publishedDataType === PublishedDataType.Routing) {\n return 'generate-route-json-per-role';\n }\n if (publishedDataType === PublishedDataType.MapObjects) {\n return 'generate-map-objects-per-role';\n }\n}\n\nfunction getLocalStorageKey(\n param: string,\n publishedDataType: PublishedDataType,\n): string {\n return publishedDataType.valueOf() + param;\n}\n\nconst setRouteData = useRouteDataStore.setState;\nconst setMapObjectsData = useMapObjectsDataStore.setState;\n\nfunction getRunTimeStore(publishedDataType: PublishedDataType) {\n if (publishedDataType === PublishedDataType.Routing) {\n return setRouteData;\n }\n if (publishedDataType === PublishedDataType.MapObjects) {\n return setMapObjectsData;\n }\n}\n\nexport async function getPublishedData(\n serverAPIInfo: ServerAPIInfo,\n localStorage: LocalStorage,\n) {\n const publishedDataType = serverAPIInfo.publishedDataType;\n const localStorageVersionKey = getLocalStorageKey(\n 'version',\n publishedDataType,\n );\n let status: Status = Status.Awaiting;\n let setRunTimeStoreData = getRunTimeStore(publishedDataType);\n\n const fetchInfo = async () => {\n const currentVersion = localStorage.contains(localStorageVersionKey)\n ? localStorage.getString(localStorageVersionKey)\n : '0.0.0';\n return new Promise(\n (resolve: (routingInfo: PublishedDataInfo) => void, reject) => {\n axios({\n url: `${serverAPIInfo.URL}/check-published-versions`,\n headers: {\n Authorization: `Bearer ${serverAPIInfo.accessToken}`,\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n data: JSON.stringify({\n version: currentVersion,\n dataType: getDataType(serverAPIInfo.publishedDataType),\n }),\n })\n .then(response => {\n const remoteData = response.data;\n\n const publishedDataInfo = {\n currentVersion: undefined,\n remoteVersion: undefined,\n URL: undefined,\n data: undefined,\n } as PublishedDataInfo;\n const localVersion = localStorage.getString(localStorageVersionKey);\n let remoteVersion = localVersion;\n if (remoteData.hasOwnProperty('version')) {\n remoteVersion = remoteData.version;\n }\n\n publishedDataInfo.currentVersion = localVersion;\n publishedDataInfo.remoteVersion = remoteVersion;\n if (localVersion) {\n const currentData = localStorage.getString(\n getLocalStorageKey('data', publishedDataType),\n );\n const tag = localStorage.getString(\n getLocalStorageKey('encryptionTag', publishedDataType),\n );\n\n // Check both because data is useless without tag\n if (tag && currentData) {\n publishedDataInfo.data = currentData;\n }\n }\n if (remoteVersion) {\n if (remoteData.hasOwnProperty('downloadUrl')) {\n publishedDataInfo.URL = remoteData.downloadUrl;\n }\n if (\n (localVersion && remoteVersion > localVersion) ||\n !localVersion ||\n !publishedDataInfo.data\n ) {\n status = publishedDataInfo.URL\n ? Status.DownloadingResources\n : status;\n }\n }\n\n console.log(\n 'final: ',\n publishedDataInfo.URL,\n publishedDataInfo.currentVersion,\n publishedDataInfo.remoteVersion,\n );\n resolve(publishedDataInfo);\n })\n .catch(function (error) {\n console.log('error while fetching published version: ');\n if (error.response) {\n // The request was made and the server responded with a status code\n // that falls out of the range of 2xx\n console.log(error.response.data);\n console.log(error.response.status);\n console.log(error.response.headers);\n } else if (error.request) {\n // The request was made but no response was received\n // `error.request` is an instance of XMLHttpRequest in the browser and an instance of\n // http.ClientRequest in node.js\n console.log(error.request);\n } else {\n // Something happened in setting up the request that triggered an Error\n console.log('Error', error.message);\n }\n console.log(error.config);\n reject(error);\n });\n },\n );\n };\n\n const storeFileToLocalStorage = (data: any, version: any, tag: any) => {\n try {\n localStorage.set(getLocalStorageKey('data', publishedDataType), data);\n localStorage.set(localStorageVersionKey, version);\n localStorage.set(\n getLocalStorageKey('encryptionTag', publishedDataType),\n tag,\n );\n return true;\n } catch (e) {\n console.log('error storing routing file from local storage', e);\n return false;\n }\n };\n\n const loadFileFromStore = () => {\n const currentData = localStorage.getString(\n getLocalStorageKey('data', publishedDataType),\n );\n const tag = localStorage.getString(\n getLocalStorageKey('encryptionTag', publishedDataType),\n );\n if (currentData && tag) {\n const decryptedJson = decryptFile(currentData, tag, serverAPIInfo.secretKey);\n // JSON.parse(storage.getString('routeData')\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n return true;\n } else {\n return false;\n }\n };\n\n const onError = () => {\n try {\n const loaded = loadFileFromStore();\n if (!loaded) {\n console.log('failed to load data');\n status = Status.Unavailable;\n }\n } catch (error) {\n console.log('erro while loading data');\n status = Status.Unavailable;\n localStorage.clearAll();\n }\n };\n\n try {\n const info = await fetchInfo();\n // @ts-ignore\n if (status === Status.DownloadingResources && info.URL) {\n // download\n console.log('downloading from server');\n try {\n // Fetch encrypted data from the server\n // This is the API call for getting map-objects.json\n const response = await fetch(info.URL);\n if (!response.ok) {\n throw new Error(`HTTP error! Status: ${response.status}`);\n }\n const responseData = await response.json();\n // const responseData = JSON.parse(fileContent);\n const {data, tag} = responseData;\n\n const decryptedJson = await decryptFile(data, tag, serverAPIInfo.secretKey);\n const storedSuccessfully = storeFileToLocalStorage(\n data,\n info.remoteVersion,\n tag,\n );\n if (storedSuccessfully) {\n console.log('loaded file');\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n }\n } catch (error) {\n console.error('Error fetching and decrypting data:', error);\n onError();\n }\n } else {\n const tag = localStorage.getString('encryptionTag');\n // set to store\n if (info.data && tag) {\n console.log('loaded local file');\n const decryptedJson = decryptFile(info.data, tag, serverAPIInfo.secretKey);\n setRunTimeStoreData({data: decryptedJson});\n status = Status.Ready;\n } else {\n onError();\n }\n }\n } catch (error) {\n onError();\n }\n\n return status;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,IAAAC,QAAA,GAAAD,OAAA;AAAA,IAAAE,aAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAA,IAAAG,gBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAA,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAOdG,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAAA,IAKjBE,MAAM,GAAAD,OAAA,CAAAC,MAAA,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAuBlB,SAASC,WAAWA,CAACC,iBAAoC,EAAE;EACzD,IAAIA,iBAAiB,KAAKJ,iBAA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