@panoramax/web-viewer 3.2.3 → 4.0.0-develop-39167b4d

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 (255) hide show
  1. package/.gitlab-ci.yml +13 -6
  2. package/CHANGELOG.md +53 -1
  3. package/CODE_OF_CONDUCT.md +1 -1
  4. package/README.md +1 -1
  5. package/build/editor.html +10 -1
  6. package/build/index.css +12 -12
  7. package/build/index.css.map +1 -1
  8. package/build/index.html +1 -1
  9. package/build/index.js +2126 -14
  10. package/build/index.js.map +1 -1
  11. package/build/map.html +1 -1
  12. package/build/photo.html +1 -0
  13. package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff +0 -0
  14. package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff2 +0 -0
  15. package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff +0 -0
  16. package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff2 +0 -0
  17. package/build/viewer.html +12 -1
  18. package/build/widgets.html +1 -0
  19. package/config/jest/mocks.js +201 -0
  20. package/config/paths.js +2 -0
  21. package/config/webpack.config.js +52 -0
  22. package/docs/03_URL_settings.md +14 -16
  23. package/docs/05_Compatibility.md +59 -76
  24. package/docs/09_Develop.md +46 -11
  25. package/docs/90_Releases.md +2 -2
  26. package/docs/images/class_diagram.drawio +60 -45
  27. package/docs/images/class_diagram.jpg +0 -0
  28. package/docs/images/screenshot.jpg +0 -0
  29. package/docs/index.md +135 -0
  30. package/docs/reference/components/core/Basic.md +196 -0
  31. package/docs/reference/components/core/CoverageMap.md +210 -0
  32. package/docs/reference/components/core/Editor.md +224 -0
  33. package/docs/reference/components/core/PhotoViewer.md +307 -0
  34. package/docs/reference/components/core/Viewer.md +350 -0
  35. package/docs/reference/components/layout/BottomDrawer.md +35 -0
  36. package/docs/reference/components/layout/CorneredGrid.md +29 -0
  37. package/docs/reference/components/layout/Mini.md +45 -0
  38. package/docs/reference/components/layout/Tabs.md +45 -0
  39. package/docs/reference/components/menus/MapBackground.md +32 -0
  40. package/docs/reference/components/menus/MapFilters.md +15 -0
  41. package/docs/reference/components/menus/MapLayers.md +15 -0
  42. package/docs/reference/components/menus/MapLegend.md +15 -0
  43. package/docs/reference/components/menus/PictureLegend.md +16 -0
  44. package/docs/reference/components/menus/PictureMetadata.md +15 -0
  45. package/docs/reference/components/menus/PlayerOptions.md +15 -0
  46. package/docs/reference/components/menus/QualityScoreDoc.md +15 -0
  47. package/docs/reference/components/menus/ReportForm.md +15 -0
  48. package/docs/reference/components/menus/ShareMenu.md +15 -0
  49. package/docs/reference/components/ui/Button.md +40 -0
  50. package/docs/reference/components/ui/ButtonGroup.md +36 -0
  51. package/docs/reference/components/ui/CopyButton.md +38 -0
  52. package/docs/reference/components/ui/Grade.md +32 -0
  53. package/docs/reference/components/ui/LinkButton.md +45 -0
  54. package/docs/reference/components/ui/ListGroup.md +22 -0
  55. package/docs/reference/components/ui/Loader.md +56 -0
  56. package/docs/reference/components/ui/Map.md +239 -0
  57. package/docs/reference/components/ui/MapMore.md +256 -0
  58. package/docs/reference/components/ui/Photo.md +385 -0
  59. package/docs/reference/components/ui/Popup.md +56 -0
  60. package/docs/reference/components/ui/ProgressBar.md +32 -0
  61. package/docs/reference/components/ui/QualityScore.md +45 -0
  62. package/docs/reference/components/ui/SearchBar.md +63 -0
  63. package/docs/reference/components/ui/TogglableGroup.md +39 -0
  64. package/docs/reference/components/ui/widgets/GeoSearch.md +32 -0
  65. package/docs/reference/components/ui/widgets/Legend.md +49 -0
  66. package/docs/reference/components/ui/widgets/MapFiltersButton.md +33 -0
  67. package/docs/reference/components/ui/widgets/MapLayersButton.md +15 -0
  68. package/docs/reference/components/ui/widgets/OSMEditors.md +15 -0
  69. package/docs/reference/components/ui/widgets/PictureLegendActions.md +32 -0
  70. package/docs/reference/components/ui/widgets/Player.md +33 -0
  71. package/docs/reference/components/ui/widgets/Zoom.md +15 -0
  72. package/docs/reference/utils/API.md +334 -0
  73. package/docs/reference/utils/InitParameters.md +68 -0
  74. package/docs/reference/utils/URLHandler.md +107 -0
  75. package/docs/reference.md +79 -0
  76. package/docs/shortcuts.md +11 -0
  77. package/docs/tutorials/aerial_imagery.md +19 -0
  78. package/docs/tutorials/authentication.md +10 -0
  79. package/docs/tutorials/custom_widgets.md +59 -0
  80. package/docs/tutorials/map_style.md +39 -0
  81. package/docs/tutorials/migrate_v4.md +153 -0
  82. package/docs/tutorials/synced_coverage.md +43 -0
  83. package/mkdocs.yml +66 -5
  84. package/package.json +22 -17
  85. package/public/editor.html +21 -29
  86. package/public/index.html +17 -12
  87. package/public/map.html +19 -18
  88. package/public/photo.html +55 -0
  89. package/public/viewer.html +22 -26
  90. package/public/widgets.html +306 -0
  91. package/scripts/doc.js +79 -0
  92. package/src/components/core/Basic.css +48 -0
  93. package/src/components/core/Basic.js +349 -0
  94. package/src/components/core/CoverageMap.css +9 -0
  95. package/src/components/core/CoverageMap.js +139 -0
  96. package/src/components/core/Editor.css +23 -0
  97. package/src/components/core/Editor.js +390 -0
  98. package/src/components/core/PhotoViewer.css +48 -0
  99. package/src/components/core/PhotoViewer.js +499 -0
  100. package/src/components/core/Viewer.css +98 -0
  101. package/src/components/core/Viewer.js +564 -0
  102. package/src/components/core/index.js +12 -0
  103. package/src/components/index.js +13 -0
  104. package/src/components/layout/BottomDrawer.js +257 -0
  105. package/src/components/layout/CorneredGrid.js +112 -0
  106. package/src/components/layout/Mini.js +117 -0
  107. package/src/components/layout/Tabs.js +133 -0
  108. package/src/components/layout/index.js +9 -0
  109. package/src/components/menus/MapBackground.js +106 -0
  110. package/src/components/menus/MapFilters.js +400 -0
  111. package/src/components/menus/MapLayers.js +143 -0
  112. package/src/components/menus/MapLegend.js +34 -0
  113. package/src/components/menus/PictureLegend.js +257 -0
  114. package/src/components/menus/PictureMetadata.js +317 -0
  115. package/src/components/menus/PlayerOptions.js +95 -0
  116. package/src/components/menus/QualityScoreDoc.js +36 -0
  117. package/src/components/menus/ReportForm.js +133 -0
  118. package/src/components/menus/Share.js +100 -0
  119. package/src/components/menus/index.js +15 -0
  120. package/src/components/styles.js +383 -0
  121. package/src/components/ui/Button.js +77 -0
  122. package/src/components/ui/ButtonGroup.css +57 -0
  123. package/src/components/ui/ButtonGroup.js +68 -0
  124. package/src/components/ui/CopyButton.js +106 -0
  125. package/src/components/ui/Grade.js +54 -0
  126. package/src/components/ui/LinkButton.js +67 -0
  127. package/src/components/ui/ListGroup.js +66 -0
  128. package/src/components/ui/Loader.js +203 -0
  129. package/src/components/{Map.css → ui/Map.css} +5 -17
  130. package/src/components/{Map.js → ui/Map.js} +148 -156
  131. package/src/components/ui/MapMore.js +324 -0
  132. package/src/components/{Photo.css → ui/Photo.css} +6 -6
  133. package/src/components/{Photo.js → ui/Photo.js} +313 -101
  134. package/src/components/ui/Popup.js +145 -0
  135. package/src/components/ui/ProgressBar.js +104 -0
  136. package/src/components/ui/QualityScore.js +147 -0
  137. package/src/components/ui/SearchBar.js +367 -0
  138. package/src/components/ui/TogglableGroup.js +157 -0
  139. package/src/components/ui/index.js +22 -0
  140. package/src/components/ui/widgets/GeoSearch.css +21 -0
  141. package/src/components/ui/widgets/GeoSearch.js +139 -0
  142. package/src/components/ui/widgets/Legend.js +113 -0
  143. package/src/components/ui/widgets/MapFiltersButton.js +104 -0
  144. package/src/components/ui/widgets/MapLayersButton.js +79 -0
  145. package/src/components/ui/widgets/OSMEditors.js +155 -0
  146. package/src/components/ui/widgets/PictureLegendActions.js +117 -0
  147. package/src/components/ui/widgets/Player.css +7 -0
  148. package/src/components/ui/widgets/Player.js +151 -0
  149. package/src/components/ui/widgets/Zoom.js +82 -0
  150. package/src/components/ui/widgets/index.js +13 -0
  151. package/src/img/loader_base.jpg +0 -0
  152. package/src/img/panoramax.svg +13 -0
  153. package/src/img/switch_big.svg +20 -10
  154. package/src/index.js +7 -9
  155. package/src/translations/br.json +1 -0
  156. package/src/translations/da.json +38 -15
  157. package/src/translations/de.json +5 -3
  158. package/src/translations/en.json +35 -15
  159. package/src/translations/eo.json +38 -15
  160. package/src/translations/es.json +1 -1
  161. package/src/translations/fr.json +36 -16
  162. package/src/translations/hu.json +1 -1
  163. package/src/translations/it.json +39 -16
  164. package/src/translations/ja.json +182 -1
  165. package/src/translations/nl.json +106 -6
  166. package/src/translations/pl.json +1 -1
  167. package/src/translations/sv.json +182 -0
  168. package/src/translations/zh_Hant.json +35 -14
  169. package/src/utils/API.js +109 -49
  170. package/src/utils/InitParameters.js +388 -0
  171. package/src/utils/PhotoAdapter.js +1 -0
  172. package/src/utils/URLHandler.js +362 -0
  173. package/src/utils/geocoder.js +152 -0
  174. package/src/utils/{I18n.js → i18n.js} +7 -3
  175. package/src/utils/index.js +11 -0
  176. package/src/utils/{Map.js → map.js} +256 -77
  177. package/src/utils/picture.js +442 -0
  178. package/src/utils/utils.js +324 -0
  179. package/src/utils/widgets.js +55 -0
  180. package/tests/components/core/Basic.test.js +121 -0
  181. package/tests/components/core/BasicMock.js +25 -0
  182. package/tests/components/core/CoverageMap.test.js +20 -0
  183. package/tests/components/core/Editor.test.js +20 -0
  184. package/tests/components/core/PhotoViewer.test.js +57 -0
  185. package/tests/components/core/Viewer.test.js +84 -0
  186. package/tests/components/core/__snapshots__/PhotoViewer.test.js.snap +73 -0
  187. package/tests/components/core/__snapshots__/Viewer.test.js.snap +145 -0
  188. package/tests/components/ui/CopyButton.test.js +52 -0
  189. package/tests/components/ui/Loader.test.js +55 -0
  190. package/tests/components/{Map.test.js → ui/Map.test.js} +73 -61
  191. package/tests/components/{Photo.test.js → ui/Photo.test.js} +97 -63
  192. package/tests/components/ui/Popup.test.js +26 -0
  193. package/tests/components/ui/QualityScore.test.js +18 -0
  194. package/tests/components/ui/SearchBar.test.js +110 -0
  195. package/tests/components/ui/__snapshots__/CopyButton.test.js.snap +33 -0
  196. package/tests/components/ui/__snapshots__/Loader.test.js.snap +56 -0
  197. package/tests/components/{__snapshots__ → ui/__snapshots__}/Map.test.js.snap +11 -38
  198. package/tests/components/{__snapshots__ → ui/__snapshots__}/Photo.test.js.snap +70 -6
  199. package/tests/components/ui/__snapshots__/Popup.test.js.snap +29 -0
  200. package/tests/components/ui/__snapshots__/QualityScore.test.js.snap +11 -0
  201. package/tests/components/ui/__snapshots__/SearchBar.test.js.snap +65 -0
  202. package/tests/utils/API.test.js +83 -83
  203. package/tests/utils/InitParameters.test.js +499 -0
  204. package/tests/utils/URLHandler.test.js +401 -0
  205. package/tests/utils/__snapshots__/API.test.js.snap +10 -0
  206. package/tests/utils/__snapshots__/URLHandler.test.js.snap +21 -0
  207. package/tests/utils/__snapshots__/{Map.test.js.snap → geocoder.test.js.snap} +1 -1
  208. package/tests/utils/__snapshots__/map.test.js.snap +11 -0
  209. package/tests/utils/__snapshots__/picture.test.js.snap +327 -0
  210. package/tests/utils/__snapshots__/widgets.test.js.snap +19 -0
  211. package/tests/utils/geocoder.test.js +37 -0
  212. package/tests/utils/{I18n.test.js → i18n.test.js} +8 -8
  213. package/tests/utils/map.test.js +126 -0
  214. package/tests/utils/picture.test.js +745 -0
  215. package/tests/utils/utils.test.js +288 -0
  216. package/tests/utils/widgets.test.js +31 -0
  217. package/docs/01_Start.md +0 -149
  218. package/docs/02_Usage.md +0 -831
  219. package/docs/04_Advanced_examples.md +0 -216
  220. package/src/Editor.css +0 -37
  221. package/src/Editor.js +0 -361
  222. package/src/StandaloneMap.js +0 -114
  223. package/src/Viewer.css +0 -203
  224. package/src/Viewer.js +0 -1246
  225. package/src/components/CoreView.css +0 -70
  226. package/src/components/CoreView.js +0 -175
  227. package/src/components/Loader.css +0 -74
  228. package/src/components/Loader.js +0 -120
  229. package/src/img/loader_hd.jpg +0 -0
  230. package/src/utils/Exif.js +0 -193
  231. package/src/utils/Utils.js +0 -631
  232. package/src/utils/Widgets.js +0 -562
  233. package/src/viewer/URLHash.js +0 -469
  234. package/src/viewer/Widgets.css +0 -880
  235. package/src/viewer/Widgets.js +0 -1470
  236. package/tests/Editor.test.js +0 -126
  237. package/tests/StandaloneMap.test.js +0 -45
  238. package/tests/Viewer.test.js +0 -366
  239. package/tests/__snapshots__/Editor.test.js.snap +0 -298
  240. package/tests/__snapshots__/StandaloneMap.test.js.snap +0 -30
  241. package/tests/__snapshots__/Viewer.test.js.snap +0 -195
  242. package/tests/components/CoreView.test.js +0 -92
  243. package/tests/components/Loader.test.js +0 -38
  244. package/tests/components/__snapshots__/Loader.test.js.snap +0 -15
  245. package/tests/utils/Exif.test.js +0 -124
  246. package/tests/utils/Map.test.js +0 -113
  247. package/tests/utils/Utils.test.js +0 -300
  248. package/tests/utils/Widgets.test.js +0 -107
  249. package/tests/utils/__snapshots__/Exif.test.js.snap +0 -43
  250. package/tests/utils/__snapshots__/Utils.test.js.snap +0 -41
  251. package/tests/utils/__snapshots__/Widgets.test.js.snap +0 -44
  252. package/tests/viewer/URLHash.test.js +0 -559
  253. package/tests/viewer/Widgets.test.js +0 -127
  254. package/tests/viewer/__snapshots__/URLHash.test.js.snap +0 -108
  255. package/tests/viewer/__snapshots__/Widgets.test.js.snap +0 -403
package/src/utils/API.js CHANGED
@@ -1,22 +1,29 @@
1
- import { TILES_PICTURES_ZOOM } from "./Map";
2
- import { BASE_PANORAMA_ID } from "./Utils";
1
+ import { TILES_PICTURES_ZOOM } from "./map";
2
+ import { isNullId } from "./utils";
3
3
 
4
4
  /**
5
- * API contains various utility functions to communicate with the backend
5
+ * API contains various utility functions to communicate with Panoramax/STAC API
6
6
  *
7
- * @param {string} endpoint The API endpoint. It corresponds to the <a href="https://github.com/radiantearth/stac-api-spec/blob/main/overview.md#example-landing-page">STAC landing page</a>, with all links describing the API capabilites.
8
- * @param {object} [options] Options received from viewer that may change API behaviour
7
+ * @class Panoramax.utils.API
8
+ * @typicalname api
9
+ * @fires Panoramax.utils.API#ready
10
+ * @fires Panoramax.utils.API#broken
11
+ * @param {string} endpoint The endpoint. It corresponds to the <a href="https://github.com/radiantearth/stac-api-spec/blob/main/overview.md#example-landing-page">STAC landing page</a>, with all links describing the API capabilites.
12
+ * @param {object} [options] Options
9
13
  * @param {string|object} [options.style] General map style
10
14
  * @param {string} [options.tiles] API route serving pictures & sequences vector tiles
11
- * @param {boolean} [options.skipReadLanding] True to not call API landing page automatically (defaults to false)
15
+ * @param {boolean} [options.skipReadLanding=false] True to not call API landing page automatically
12
16
  * @param {object} [options.fetch] Set custom options for fetch calls made against API ([same syntax as fetch options parameter](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters))
13
- * @param {string[]} [options.users] List of initial user IDs to load map styles for.
14
- * @private
17
+ * @param {string[]} [options.users] List of initial user IDs to load map styles for
15
18
  */
16
- export default class API {
19
+ export default class API extends EventTarget {
17
20
  constructor(endpoint, options = {}) {
21
+ super();
22
+
18
23
  if(endpoint === null || endpoint === undefined || typeof endpoint !== "string") {
19
- throw new Error("endpoint parameter is empty or not a valid string");
24
+ const e = new Error("endpoint parameter is empty or not a valid string");
25
+ this.dispatchEvent(new CustomEvent("broken", {detail: {error: e}}));
26
+ throw e;
20
27
  }
21
28
 
22
29
  // Parse local endpoints
@@ -26,7 +33,9 @@ export default class API {
26
33
 
27
34
  // Check endpoint
28
35
  if(!API.isValidHttpUrl(endpoint)) {
29
- throw new Error(`endpoint parameter is not a valid URL: ${endpoint}`);
36
+ const e = new Error(`endpoint parameter is not a valid URL: ${endpoint}`);
37
+ this.dispatchEvent(new CustomEvent("broken", {detail: {error: e}}));
38
+ throw e;
30
39
  }
31
40
 
32
41
  this._endpoint = endpoint;
@@ -42,19 +51,40 @@ export default class API {
42
51
  .catch(e => {
43
52
  this._isReady = -1;
44
53
  console.error(e);
54
+
55
+ /**
56
+ * Event when API is broken.
57
+ * This happens on any API loading or map styling issue.
58
+ * @event Panoramax.utils.API#broken
59
+ * @type {CustomEvent}
60
+ * @property {Error} detail.error The original error
61
+ */
62
+ this.dispatchEvent(new CustomEvent("broken", {detail: {error: e}}));
63
+
45
64
  return Promise.reject("Viewer failed to communicate with API");
46
65
  })
47
66
  .then(() => this._loadMapStyles(options.style, options.users))
48
67
  .then(() => {
49
68
  this._isReady = 1;
69
+
70
+ /**
71
+ * Event when API is ready to use.
72
+ * This happens after initial API read and map styles load.
73
+ * @event Panoramax.utils.API#ready
74
+ * @type {Event}
75
+ */
76
+ this.dispatchEvent(new Event("ready"));
77
+
50
78
  return "API is ready";
51
79
  });
52
80
  }
53
81
 
54
82
  /**
55
- * This function resolves when API is ready to be used
56
- *
57
- * @returns {Promise} Resolves when API is ready
83
+ * Resolves when the API is ready to be used.
84
+ * @memberOf Panoramax.utils.API#
85
+ * @returns {Promise}
86
+ * @fulfil {string} "API is ready" when initialization is complete.
87
+ * @reject {string} Error message
58
88
  */
59
89
  onceReady() {
60
90
  if(this._isReady == -1) {
@@ -69,9 +99,9 @@ export default class API {
69
99
  }
70
100
 
71
101
  /**
72
- * Check if API is ready to be used
73
- *
74
- * @returns {boolean} True if ready
102
+ * Checks if the API is ready to be used.
103
+ * @memberOf Panoramax.utils.API#
104
+ * @returns {boolean} True if the API is ready, false otherwise.
75
105
  */
76
106
  isReady() {
77
107
  return this._isReady == 1;
@@ -79,6 +109,7 @@ export default class API {
79
109
 
80
110
  /**
81
111
  * List of available features offered by API
112
+ * @memberOf Panoramax.utils.API#
82
113
  * @returns {string[]} Keywords of enabled features
83
114
  */
84
115
  getAvailableFeatures() {
@@ -87,6 +118,7 @@ export default class API {
87
118
 
88
119
  /**
89
120
  * List of unavailable features on API
121
+ * @memberOf Panoramax.utils.API#
90
122
  * @returns {string[]} Keywords of disabled features
91
123
  */
92
124
  getUnavailableFeatures() {
@@ -95,7 +127,7 @@ export default class API {
95
127
 
96
128
  /**
97
129
  * Interprets JSON landing page and store important information
98
- *
130
+ * @memberOf Panoramax.utils.API#
99
131
  * @private
100
132
  */
101
133
  _parseLanding(landing, options) {
@@ -252,9 +284,12 @@ export default class API {
252
284
 
253
285
  /**
254
286
  * Loads all MapLibre Styles JSON needed at start.
287
+ * @memberOf Panoramax.utils.API#
255
288
  * @param {string|object} style General map style
256
289
  * @param {string[]} users List of user IDs to handle. Should include special user "geovisio" for general tiles loading.
257
- * @returns {Promise} Resolves when style is ready.
290
+ * @returns {Promise}
291
+ * @fulfil {null} When style is ready.
292
+ * @private
258
293
  */
259
294
  _loadMapStyles(style, users) {
260
295
  const mapUsers = new Set(users || []);
@@ -298,19 +333,20 @@ export default class API {
298
333
 
299
334
  /**
300
335
  * Get the defaults fetch options to pass during API calls
301
- *
336
+ * @memberOf Panoramax.utils.API#
337
+ * @param {boolean} [noTimeout=false] Set to true to avoid default timeout
302
338
  * @private
303
339
  * @returns {object} The fetch options
304
340
  */
305
- _getFetchOptions() {
341
+ _getFetchOptions(noTimeout=false) {
306
342
  return Object.assign({
307
- signal: AbortSignal.timeout(15000)
343
+ signal: noTimeout ? undefined : AbortSignal.timeout(15000)
308
344
  }, this._fetchOpts);
309
345
  }
310
346
 
311
347
  /**
312
348
  * Get the RequestTransformFunction for MapLibre to handle fetch options
313
- *
349
+ * @memberOf Panoramax.utils.API#
314
350
  * @private
315
351
  * @returns {function} The RequestTransformFunction
316
352
  */
@@ -335,11 +371,13 @@ export default class API {
335
371
 
336
372
  /**
337
373
  * Get sequence GeoJSON representation
338
- *
374
+ * @memberOf Panoramax.utils.API#
339
375
  * @param {string} seqId The sequence ID
340
376
  * @param {string} [next] The next link URL (only for internals)
341
377
  * @param {object} [data] The previous dataset (only for internals)
342
- * @returns {Promise} Resolves on sequence GeoJSON
378
+ * @returns {Promise}
379
+ * @fulfil {object} Sequence GeoJSON
380
+ * @reject {Error} If API is not ready or for any network issue
343
381
  */
344
382
  async getSequenceItems(seqId, next = null, data = null) {
345
383
  if(!this.isReady()) { throw new Error("API is not ready to use"); }
@@ -347,7 +385,7 @@ export default class API {
347
385
  API.isIdValid(seqId);
348
386
  return fetch(
349
387
  next || `${this._endpoints.collections}/${seqId}/items`,
350
- this._getFetchOptions()
388
+ this._getFetchOptions(true)
351
389
  )
352
390
  .then(res => res.json())
353
391
  .then(res => {
@@ -368,7 +406,7 @@ export default class API {
368
406
 
369
407
  /**
370
408
  * Get full URL for listing pictures around a specific location
371
- *
409
+ * @memberOf Panoramax.utils.API#
372
410
  * @param {number} lat Latitude
373
411
  * @param {number} lon Longitude
374
412
  * @param {number} [factor] The radius to search around (in degrees)
@@ -391,13 +429,14 @@ export default class API {
391
429
 
392
430
  /**
393
431
  * Get list of pictures around a specific location
394
- *
432
+ * @memberOf Panoramax.utils.API#
395
433
  * @param {number} lat Latitude
396
434
  * @param {number} lon Longitude
397
435
  * @param {number} [factor] The radius to search around (in degrees)
398
436
  * @param {number} [limit] Max amount of pictures to retrieve
399
437
  * @param {string} [seqId] The sequence ID to filter on (by default, no filter)
400
- * @returns {object} The GeoJSON feature collection
438
+ * @returns {Promise}
439
+ * @fulfil {object} The GeoJSON feature collection
401
440
  */
402
441
  getPicturesAroundCoordinates(lat, lon, factor, limit, seqId) {
403
442
  return fetch(this.getPicturesAroundCoordinatesUrl(lat, lon, factor, limit, seqId), this._getFetchOptions())
@@ -406,10 +445,11 @@ export default class API {
406
445
 
407
446
  /**
408
447
  * Get full URL for retrieving a specific picture metadata
409
- *
448
+ * @memberOf Panoramax.utils.API#
410
449
  * @param {string} picId The picture unique identifier
411
450
  * @param {string} [seqId] The sequence ID
412
451
  * @returns {string} The corresponding URL
452
+ * @throws {Error} If API is not ready
413
453
  */
414
454
  getPictureMetadataUrl(picId, seqId) {
415
455
  if(!this.isReady()) { throw new Error("API is not ready to use"); }
@@ -422,8 +462,10 @@ export default class API {
422
462
 
423
463
  /**
424
464
  * Get JSON style for general vector tiles
425
- * @return {Promise} The MapLibre JSON style
426
- * @fires Error If API is not ready, or no style defined.
465
+ * @memberOf Panoramax.utils.API#
466
+ * @return {Promise|object} Promise if first load, MapLibre JSON style otherwise
467
+ * @fulfil {object} The MapLibre JSON style
468
+ * @reject {Error} If API is not ready, or no style defined.
427
469
  */
428
470
  getMapStyle() {
429
471
  if(this.isReady()) { return this.mapStyle; }
@@ -471,10 +513,12 @@ export default class API {
471
513
 
472
514
  /**
473
515
  * Get JSON style for specific-user vector tiles
516
+ * @memberOf Panoramax.utils.API#
474
517
  * @param {string} userId The user UUID
475
518
  * @param {boolean} [skipReadyCheck=false] Skip check for API readyness
476
- * @return {Promise} The MapLibre JSON style
477
- * @fires Error If API is not ready, or no style defined.
519
+ * @return {Promise}
520
+ * @fulfil {object} The MapLibre JSON style
521
+ * @reject {Error} If API is not ready, or no style defined.
478
522
  */
479
523
  getUserMapStyle(userId, skipReadyCheck = false) {
480
524
  if(!skipReadyCheck && !this.isReady()) { return Promise.reject(new Error("API is not ready to use")); }
@@ -515,9 +559,10 @@ export default class API {
515
559
 
516
560
  /**
517
561
  * Find the thumbnail URL for a given picture
518
- *
562
+ * @memberOf Panoramax.utils.API#
519
563
  * @param {object} picture The picture GeoJSON feature
520
564
  * @returns {string} The thumbnail URL, or null if not found
565
+ * @throws {Error} If API is not ready
521
566
  * @private
522
567
  */
523
568
  findThumbnailInPictureFeature(picture) {
@@ -538,10 +583,12 @@ export default class API {
538
583
 
539
584
  /**
540
585
  * Get a picture thumbnail URL for a given sequence
541
- *
586
+ * @memberOf Panoramax.utils.API#
542
587
  * @param {string} seqId The sequence ID
543
588
  * @param {object} [seq] The sequence metadata (with links) if already loaded
544
- * @returns {Promise} Promise resolving on the picture thumbnail URL, or null if not found
589
+ * @returns {Promise}
590
+ * @fulfil {string|null} Promise resolving on the picture thumbnail URL, or null if not found
591
+ * @throws {Error} If API is not ready
545
592
  */
546
593
  getPictureThumbnailURLForSequence(seqId, seq) {
547
594
  if(!this.isReady()) { throw new Error("API is not ready to use"); }
@@ -575,10 +622,12 @@ export default class API {
575
622
 
576
623
  /**
577
624
  * Get thumbnail URL for a specific picture
578
- *
625
+ * @memberOf Panoramax.utils.API#
579
626
  * @param {string} picId The picture unique identifier
580
627
  * @param {string} [seqId] The sequence ID
581
- * @returns {Promise} The corresponding URL on resolve, or undefined if no thumbnail could be found
628
+ * @returns {Promise}
629
+ * @fulfil {string|null} The corresponding URL on resolve, or null if no thumbnail could be found
630
+ * @throws {Error} If API is not ready
582
631
  */
583
632
  getPictureThumbnailURL(picId, seqId) {
584
633
  if(!this.isReady()) { throw new Error("API is not ready to use"); }
@@ -610,9 +659,10 @@ export default class API {
610
659
 
611
660
  /**
612
661
  * Get the RSS feed URL with map parameters (if map is enabled)
613
- *
662
+ * @memberOf Panoramax.utils.API#
614
663
  * @param {LngLatBounds} [bbox] The map current bounding box, or null if not available
615
- * @returns {string} The URL, or null if no RSS feed is available
664
+ * @returns {string|null} The URL, or null if no RSS feed is available
665
+ * @throws {Error} If API is not ready
616
666
  */
617
667
  getRSSURL(bbox) {
618
668
  if(!this.isReady()) { throw new Error("API is not ready to use"); }
@@ -632,9 +682,10 @@ export default class API {
632
682
 
633
683
  /**
634
684
  * Get full URL for retrieving a specific sequence metadata
635
- *
685
+ * @memberOf Panoramax.utils.API#
636
686
  * @param {string} seqId The sequence ID
637
687
  * @returns {string} The corresponding URL
688
+ * @throws {Error} If API is not ready
638
689
  */
639
690
  getSequenceMetadataUrl(seqId) {
640
691
  if(!this.isReady()) { throw new Error("API is not ready to use"); }
@@ -643,8 +694,9 @@ export default class API {
643
694
 
644
695
  /**
645
696
  * Get available data bounding box
646
- *
697
+ * @memberOf Panoramax.utils.API#
647
698
  * @returns {LngLatBoundsLike} The bounding box or null if not available
699
+ * @throws {Error} If API is not ready
648
700
  */
649
701
  getDataBbox() {
650
702
  if(!this.isReady()) { throw new Error("API is not ready to use"); }
@@ -654,8 +706,11 @@ export default class API {
654
706
 
655
707
  /**
656
708
  * Look for user ID based on user name query
709
+ * @memberOf Panoramax.utils.API#
657
710
  * @param {string} query The user name to look for
658
- * @returns {Promise} Resolves on list of potential users
711
+ * @returns {Promise}
712
+ * @fulfil {object|null} List of potential users
713
+ * @throws {Error} If API is not ready or user search not available
659
714
  */
660
715
  searchUsers(query) {
661
716
  if(!this.isReady()) { throw new Error("API is not ready to use"); }
@@ -670,8 +725,11 @@ export default class API {
670
725
 
671
726
  /**
672
727
  * Get user name based on its ID
728
+ * @memberOf Panoramax.utils.API#
673
729
  * @param {string} userId The user UUID
674
- * @returns {Promise} Resolves on user name
730
+ * @returns {Promise}
731
+ * @throws {Error} If API is not ready
732
+ * @fulfil {string|null} The user name (or null if not found)
675
733
  */
676
734
  getUserName(userId) {
677
735
  if(!this.isReady()) { throw new Error("API is not ready to use"); }
@@ -686,8 +744,10 @@ export default class API {
686
744
 
687
745
  /**
688
746
  * Send a report to API
747
+ * @memberOf Panoramax.utils.API#
689
748
  * @param {object} data The input form data
690
- * @returns {Promise} Resolves on report sent
749
+ * @returns {Promise}
750
+ * @fulfil {object} The JSON API response
691
751
  */
692
752
  sendReport(data) {
693
753
  if(!this.isReady()) { throw new Error("API is not ready to use"); }
@@ -715,7 +775,7 @@ export default class API {
715
775
 
716
776
  /**
717
777
  * Checks URL string validity
718
- *
778
+ * @memberOf Panoramax.utils.API
719
779
  * @param {string} str The URL to check
720
780
  * @returns {boolean} True if valid
721
781
  */
@@ -733,13 +793,13 @@ export default class API {
733
793
 
734
794
  /**
735
795
  * Checks picture or sequence ID validity
736
- *
796
+ * @memberOf Panoramax.utils.API
737
797
  * @param {string} id The ID to check
738
798
  * @returns {boolean} True if valid
739
799
  * @throws {Error} If not valid
740
800
  */
741
801
  static isIdValid(id) {
742
- if(!id || typeof id !== "string" || id.length === 0 || id === BASE_PANORAMA_ID) {
802
+ if(isNullId(id)) {
743
803
  throw new Error("id should be a valid picture unique identifier");
744
804
  }
745
805
  return true;