@twinmatrix/spatialverse-sdk-web 0.0.2 → 0.0.4

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 (143) 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 +40 -41
  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 +170 -196
  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 +861 -1170
  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 +166 -159
  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 +523 -610
  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 +149 -154
  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 +809 -1033
  34. package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  35. package/lib/cjs/meta-atlas-sdk/utils/helpers.js +32 -49
  36. package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
  37. package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +21 -34
  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 +363 -491
  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 -47
  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 +26 -23
  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 +47 -62
  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 +4 -3
  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 +14 -12
  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 +204 -200
  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 +6 -6
  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 +53 -42
  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 +18 -16
  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 +73 -79
  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 +16 -15
  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 +148 -124
  98. package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
  99. package/lib/esm/meta-atlas-sdk/utils/helpers.js +4 -2
  100. package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
  101. package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
  102. package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
  103. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +115 -109
  104. package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
  105. package/lib/esm/react/MetaAtlasMap.js +120 -0
  106. package/lib/esm/react/MetaAtlasMap.js.map +1 -0
  107. package/lib/esm/react/hooks/useDrawing/index.js +2 -2
  108. package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
  109. package/lib/esm/react/hooks/useFocus/index.js +4 -3
  110. package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
  111. package/lib/esm/react/hooks/useMapEvents/index.js +9 -6
  112. package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
  113. package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
  114. package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
  115. package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
  116. package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
  117. package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
  118. package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
  119. package/lib/esm/react/hooks/useRouting/index.js +2 -2
  120. package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
  121. package/lib/esm/react/hooks/useSearch/index.js +2 -2
  122. package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
  123. package/lib/esm/react/hooks/useStampRally/index.js +15 -12
  124. package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
  125. package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
  126. package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
  127. package/lib/esm/react/index.js +11 -15
  128. package/lib/esm/react/index.js.map +1 -1
  129. package/lib/esm/react/stores/useMapDataStore.js +17 -21
  130. package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
  131. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
  132. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
  133. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
  134. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
  135. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
  136. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
  137. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
  138. package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
  139. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
  140. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
  141. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
  142. package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
  143. package/package.json +10 -7
@@ -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: "".concat(serverAPIInfo.URL, "/check-published-versions"),
56
+ headers: {
57
+ Authorization: "Bearer ".concat(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;
254
153
  }
255
- }, _callee2, null, [[3, 8], [1, 12]]);
256
- }));
257
- return _getPublishedData.apply(this, arguments);
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: ".concat(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();
191
+ }
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,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,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","concat","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,Q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