mobility-toolbox-js 2.3.10 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (471) hide show
  1. package/api/RealtimeAPI.d.ts +290 -0
  2. package/api/RealtimeAPI.d.ts.map +1 -0
  3. package/api/RealtimeAPI.js +483 -0
  4. package/api/RoutingAPI.d.ts +37 -0
  5. package/api/RoutingAPI.d.ts.map +1 -0
  6. package/api/RoutingAPI.js +35 -0
  7. package/api/StopsAPI.d.ts +38 -0
  8. package/api/StopsAPI.d.ts.map +1 -0
  9. package/api/StopsAPI.js +36 -0
  10. package/api/index.d.ts +4 -0
  11. package/api/index.d.ts.map +1 -0
  12. package/api/typedefs.d.ts +179 -0
  13. package/api/typedefs.d.ts.map +1 -0
  14. package/{src/api → api}/typedefs.js +1 -11
  15. package/common/api/HttpAPI.d.ts +31 -0
  16. package/common/api/HttpAPI.d.ts.map +1 -0
  17. package/common/api/HttpAPI.js +57 -0
  18. package/common/api/WebSocketAPI.d.ts +153 -0
  19. package/common/api/WebSocketAPI.d.ts.map +1 -0
  20. package/common/api/WebSocketAPI.js +341 -0
  21. package/common/controls/ControlCommon.d.ts +76 -0
  22. package/common/controls/ControlCommon.d.ts.map +1 -0
  23. package/common/controls/ControlCommon.js +150 -0
  24. package/common/controls/CopyrightControlCommon.d.ts +13 -0
  25. package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
  26. package/common/controls/CopyrightControlCommon.js +34 -0
  27. package/common/controls/StopFinderControlCommon.d.ts +55 -0
  28. package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
  29. package/common/controls/StopFinderControlCommon.js +144 -0
  30. package/common/index.d.ts +3 -0
  31. package/common/index.d.ts.map +1 -0
  32. package/common/layers/LayerCommon.d.ts +94 -0
  33. package/common/layers/LayerCommon.d.ts.map +1 -0
  34. package/common/layers/LayerCommon.js +244 -0
  35. package/common/mixins/RealtimeLayerMixin.d.ts +288 -0
  36. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
  37. package/common/mixins/RealtimeLayerMixin.js +779 -0
  38. package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
  39. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
  40. package/common/mixins/UserInteractionsLayerMixin.js +241 -0
  41. package/common/styles/index.d.ts +5 -0
  42. package/common/styles/index.d.ts.map +1 -0
  43. package/common/styles/realtimeDefaultStyle.d.ts +36 -0
  44. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
  45. package/common/styles/realtimeDefaultStyle.js +276 -0
  46. package/common/styles/realtimeDelayStyle.d.ts +12 -0
  47. package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
  48. package/common/styles/realtimeDelayStyle.js +13 -0
  49. package/common/styles/realtimeHeadingStyle.d.ts +12 -0
  50. package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
  51. package/common/styles/realtimeHeadingStyle.js +87 -0
  52. package/common/styles/realtimeSimpleStyle.d.ts +4 -0
  53. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
  54. package/common/styles/realtimeSimpleStyle.js +23 -0
  55. package/common/typedefs.d.ts +183 -0
  56. package/common/typedefs.d.ts.map +1 -0
  57. package/{src/common → common}/typedefs.js +1 -1
  58. package/common/utils/compareDepartures.d.ts +11 -0
  59. package/common/utils/compareDepartures.d.ts.map +1 -0
  60. package/common/utils/compareDepartures.js +35 -0
  61. package/common/utils/createCanvas.d.ts +11 -0
  62. package/common/utils/createCanvas.d.ts.map +1 -0
  63. package/common/utils/createCanvas.js +28 -0
  64. package/common/utils/createRealtimeFilters.d.ts +13 -0
  65. package/common/utils/createRealtimeFilters.d.ts.map +1 -0
  66. package/common/utils/createRealtimeFilters.js +74 -0
  67. package/common/utils/debounceDeparturesMessages.d.ts +13 -0
  68. package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
  69. package/common/utils/debounceDeparturesMessages.js +28 -0
  70. package/common/utils/debounceWebsocketMessages.d.ts +12 -0
  71. package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
  72. package/common/utils/debounceWebsocketMessages.js +30 -0
  73. package/common/utils/getLayersAsFlatArray.d.ts +4 -0
  74. package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
  75. package/common/utils/getLayersAsFlatArray.js +16 -0
  76. package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
  77. package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
  78. package/common/utils/getMapboxMapCopyrights.js +30 -0
  79. package/common/utils/getMapboxRender.d.ts +8 -0
  80. package/common/utils/getMapboxRender.d.ts.map +1 -0
  81. package/common/utils/getMapboxRender.js +88 -0
  82. package/common/utils/getMaplibreRender.d.ts +9 -0
  83. package/common/utils/getMaplibreRender.d.ts.map +1 -0
  84. package/common/utils/getMaplibreRender.js +40 -0
  85. package/{src/common/utils/getRealtimeModeSuffix.ts → common/utils/getRealtimeModeSuffix.d.ts} +2 -4
  86. package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
  87. package/common/utils/getRealtimeModeSuffix.js +7 -0
  88. package/common/utils/getUrlWithParams.d.ts +9 -0
  89. package/common/utils/getUrlWithParams.d.ts.map +1 -0
  90. package/common/utils/getUrlWithParams.js +18 -0
  91. package/common/utils/getVehiclePosition.d.ts +16 -0
  92. package/common/utils/getVehiclePosition.d.ts.map +1 -0
  93. package/common/utils/getVehiclePosition.js +72 -0
  94. package/common/utils/index.d.ts +18 -0
  95. package/common/utils/index.d.ts.map +1 -0
  96. package/{src/common → common}/utils/index.js +2 -1
  97. package/common/utils/realtimeConfig.d.ts +53 -0
  98. package/common/utils/realtimeConfig.d.ts.map +1 -0
  99. package/common/utils/realtimeConfig.js +202 -0
  100. package/common/utils/removeDuplicate.d.ts +10 -0
  101. package/common/utils/removeDuplicate.d.ts.map +1 -0
  102. package/common/utils/removeDuplicate.js +15 -0
  103. package/common/utils/renderTrajectories.d.ts +17 -0
  104. package/common/utils/renderTrajectories.d.ts.map +1 -0
  105. package/common/utils/renderTrajectories.js +110 -0
  106. package/common/utils/sortAndFilterDepartures.d.ts +16 -0
  107. package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
  108. package/common/utils/sortAndFilterDepartures.js +58 -0
  109. package/common/utils/sortByDelay.d.ts +4 -0
  110. package/common/utils/sortByDelay.d.ts.map +1 -0
  111. package/common/utils/sortByDelay.js +21 -0
  112. package/common/utils/timeUtils.d.ts +24 -0
  113. package/common/utils/timeUtils.d.ts.map +1 -0
  114. package/common/utils/timeUtils.js +39 -0
  115. package/iife.d.ts +3 -0
  116. package/iife.d.ts.map +1 -0
  117. package/{src/iife.js → iife.js} +1 -3
  118. package/index.d.ts +10 -0
  119. package/index.d.ts.map +1 -0
  120. package/index.js +10 -0
  121. package/mapbox/controls/CopyrightControl.d.ts +29 -0
  122. package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
  123. package/{src/mapbox/controls/CopyrightControl.ts → mapbox/controls/CopyrightControl.js} +21 -26
  124. package/mapbox/controls/index.d.ts +2 -0
  125. package/mapbox/controls/index.d.ts.map +1 -0
  126. package/mapbox/index.d.ts +6 -0
  127. package/mapbox/index.d.ts.map +1 -0
  128. package/mapbox/layers/Layer.d.ts +59 -0
  129. package/mapbox/layers/Layer.d.ts.map +1 -0
  130. package/mapbox/layers/Layer.js +101 -0
  131. package/mapbox/layers/RealtimeLayer.d.ts +180 -0
  132. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
  133. package/mapbox/layers/RealtimeLayer.js +270 -0
  134. package/mapbox/layers/index.d.ts +3 -0
  135. package/mapbox/layers/index.d.ts.map +1 -0
  136. package/mapbox/utils/getMercatorResolution.d.ts +9 -0
  137. package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
  138. package/mapbox/utils/getMercatorResolution.js +18 -0
  139. package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
  140. package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
  141. package/mapbox/utils/getSourceCoordinates.js +27 -0
  142. package/mapbox/utils/index.d.ts +3 -0
  143. package/mapbox/utils/index.d.ts.map +1 -0
  144. package/mbt.js +64822 -0
  145. package/mbt.js.map +7 -0
  146. package/mbt.min.js +1090 -0
  147. package/mbt.min.js.map +7 -0
  148. package/ol/controls/CopyrightControl.d.ts +31 -0
  149. package/ol/controls/CopyrightControl.d.ts.map +1 -0
  150. package/ol/controls/CopyrightControl.js +68 -0
  151. package/ol/controls/RoutingControl.d.ts +193 -0
  152. package/ol/controls/RoutingControl.d.ts.map +1 -0
  153. package/ol/controls/RoutingControl.js +631 -0
  154. package/ol/controls/StopFinderControl.d.ts +30 -0
  155. package/ol/controls/StopFinderControl.d.ts.map +1 -0
  156. package/{src/ol/controls/StopFinderControl.ts → ol/controls/StopFinderControl.js} +7 -10
  157. package/ol/controls/index.d.ts +4 -0
  158. package/ol/controls/index.d.ts.map +1 -0
  159. package/ol/index.d.ts +6 -0
  160. package/ol/index.d.ts.map +1 -0
  161. package/ol/layers/Layer.d.ts +86 -0
  162. package/ol/layers/Layer.d.ts.map +1 -0
  163. package/ol/layers/Layer.js +174 -0
  164. package/ol/layers/MapGlLayer.d.ts +67 -0
  165. package/ol/layers/MapGlLayer.d.ts.map +1 -0
  166. package/ol/layers/MapGlLayer.js +218 -0
  167. package/ol/layers/MapboxLayer.d.ts +50 -0
  168. package/ol/layers/MapboxLayer.d.ts.map +1 -0
  169. package/ol/layers/MapboxLayer.js +109 -0
  170. package/ol/layers/MapboxStyleLayer.d.ts +131 -0
  171. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
  172. package/ol/layers/MapboxStyleLayer.js +369 -0
  173. package/{src/ol/layers/MaplibreLayer.ts → ol/layers/MaplibreLayer.d.ts} +10 -21
  174. package/ol/layers/MaplibreLayer.d.ts.map +1 -0
  175. package/ol/layers/MaplibreLayer.js +34 -0
  176. package/ol/layers/RealtimeLayer.d.ts +202 -0
  177. package/ol/layers/RealtimeLayer.d.ts.map +1 -0
  178. package/ol/layers/RealtimeLayer.js +332 -0
  179. package/ol/layers/RoutingLayer.d.ts +35 -0
  180. package/ol/layers/RoutingLayer.d.ts.map +1 -0
  181. package/ol/layers/RoutingLayer.js +85 -0
  182. package/ol/layers/VectorLayer.d.ts +25 -0
  183. package/ol/layers/VectorLayer.d.ts.map +1 -0
  184. package/ol/layers/VectorLayer.js +38 -0
  185. package/ol/layers/WMSLayer.d.ts +42 -0
  186. package/ol/layers/WMSLayer.d.ts.map +1 -0
  187. package/ol/layers/WMSLayer.js +88 -0
  188. package/ol/layers/index.d.ts +9 -0
  189. package/ol/layers/index.d.ts.map +1 -0
  190. package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
  191. package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
  192. package/ol/styles/fullTrajectoryDelayStyle.js +33 -0
  193. package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
  194. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
  195. package/ol/styles/fullTrajectoryStyle.js +44 -0
  196. package/ol/styles/index.d.ts +3 -0
  197. package/ol/styles/index.d.ts.map +1 -0
  198. package/package.json +1 -1
  199. package/setupTests.d.ts +2 -0
  200. package/setupTests.d.ts.map +1 -0
  201. package/{src/setupTests.js → setupTests.js} +7 -12
  202. package/.esdoc.js +0 -18
  203. package/.eslintignore +0 -1
  204. package/.eslintrc.js +0 -25
  205. package/.fixpackrc +0 -20
  206. package/.github/workflows/build.yml +0 -16
  207. package/.github/workflows/conventional-pr-title.yml +0 -16
  208. package/.github/workflows/cypress.yml +0 -101
  209. package/.github/workflows/test.yml +0 -17
  210. package/.husky/commit-msg +0 -4
  211. package/.husky/post-checkout +0 -4
  212. package/.husky/post-merge +0 -4
  213. package/.husky/post-rebase +0 -4
  214. package/.husky/pre-commit +0 -4
  215. package/.lintstagedrc.js +0 -10
  216. package/.nvmrc +0 -1
  217. package/.prettierrc.js +0 -5
  218. package/.stylelintrc.js +0 -4
  219. package/CHANGELOG.md +0 -132
  220. package/LICENSE +0 -21
  221. package/MIGRATION-V2.md +0 -248
  222. package/README.md +0 -42
  223. package/__mocks__/mapbox-gl.js +0 -81
  224. package/__mocks__/maplibre-gl.js +0 -81
  225. package/babel.config.js +0 -9
  226. package/commitlint.config.js +0 -1
  227. package/cypress/e2e/examples/api.cy.js +0 -7
  228. package/cypress/e2e/examples/examples.cy.js +0 -7
  229. package/cypress/e2e/examples/navigation.cy.js +0 -29
  230. package/cypress/fixtures/example.json +0 -5
  231. package/cypress/plugins/index.js +0 -21
  232. package/cypress/support/commands.js +0 -25
  233. package/cypress/support/e2e.js +0 -20
  234. package/cypress.config.ts +0 -15
  235. package/data/fetchRoute.json +0 -292
  236. package/data/fetchTrajectories.json +0 -18
  237. package/data/fetchTrajectoryById.json +0 -3
  238. package/data/fetchTrajectoryStations.json +0 -18
  239. package/data/stopsSearch.json +0 -15
  240. package/dependabot.yml +0 -15
  241. package/doc/.eslintrc.json +0 -1
  242. package/doc/README.md +0 -34
  243. package/doc/next.config.js +0 -16
  244. package/doc/package.json +0 -41
  245. package/doc/pages/404.js +0 -5
  246. package/doc/pages/_app.js +0 -61
  247. package/doc/pages/_document.js +0 -64
  248. package/doc/pages/doc/[...slug].js +0 -23
  249. package/doc/pages/doc.js +0 -23
  250. package/doc/pages/example/[example].js +0 -52
  251. package/doc/pages/examples.js +0 -34
  252. package/doc/pages/index.js +0 -25
  253. package/doc/public/README.md +0 -15
  254. package/doc/public/favicon.ico +0 -0
  255. package/doc/public/static/assets/Lato-Black.ttf +0 -0
  256. package/doc/public/static/assets/Lato-BlackItalic.ttf +0 -0
  257. package/doc/public/static/assets/Lato-Bold.ttf +0 -0
  258. package/doc/public/static/assets/Lato-BoldItalic.ttf +0 -0
  259. package/doc/public/static/assets/Lato-Italic.ttf +0 -0
  260. package/doc/public/static/assets/Lato-Light.ttf +0 -0
  261. package/doc/public/static/assets/Lato-LightItalic.ttf +0 -0
  262. package/doc/public/static/assets/Lato-Regular.ttf +0 -0
  263. package/doc/public/static/assets/Lato-Thin.ttf +0 -0
  264. package/doc/public/static/assets/Lato-ThinItalic.ttf +0 -0
  265. package/doc/public/static/assets/OFL.txt +0 -93
  266. package/doc/public/static/examples/assets/tralis-live-map/index.js +0 -11
  267. package/doc/public/static/examples/assets/tralis-live-map/s1kreis.svg +0 -105
  268. package/doc/public/static/examples/assets/tralis-live-map/s20kreis.svg +0 -101
  269. package/doc/public/static/examples/assets/tralis-live-map/s2kreis.svg +0 -95
  270. package/doc/public/static/examples/assets/tralis-live-map/s3kreis.svg +0 -95
  271. package/doc/public/static/examples/assets/tralis-live-map/s4kreis.svg +0 -95
  272. package/doc/public/static/examples/assets/tralis-live-map/s6kreis.svg +0 -95
  273. package/doc/public/static/examples/assets/tralis-live-map/s7kreis.svg +0 -95
  274. package/doc/public/static/examples/assets/tralis-live-map/s8kreis.svg +0 -93
  275. package/doc/public/static/examples/assets/tralis-live-map/unknown.svg +0 -107
  276. package/doc/public/static/examples/layers.html +0 -11
  277. package/doc/public/static/examples/layers.js +0 -97
  278. package/doc/public/static/examples/mb-copyright.html +0 -26
  279. package/doc/public/static/examples/mb-copyright.js +0 -37
  280. package/doc/public/static/examples/mb-tracker.html +0 -1
  281. package/doc/public/static/examples/mb-tracker.js +0 -40
  282. package/doc/public/static/examples/mb-tracker.md +0 -1
  283. package/doc/public/static/examples/mb-tralis.html +0 -1
  284. package/doc/public/static/examples/mb-tralis.js +0 -34
  285. package/doc/public/static/examples/ol-copyright.html +0 -26
  286. package/doc/public/static/examples/ol-copyright.js +0 -43
  287. package/doc/public/static/examples/ol-mapbox-layer.html +0 -1
  288. package/doc/public/static/examples/ol-mapbox-layer.js +0 -28
  289. package/doc/public/static/examples/ol-mapbox-style-layer.html +0 -12
  290. package/doc/public/static/examples/ol-mapbox-style-layer.js +0 -48
  291. package/doc/public/static/examples/ol-query.html +0 -32
  292. package/doc/public/static/examples/ol-query.js +0 -83
  293. package/doc/public/static/examples/ol-routing.html +0 -26
  294. package/doc/public/static/examples/ol-routing.js +0 -65
  295. package/doc/public/static/examples/ol-routing.md +0 -1
  296. package/doc/public/static/examples/ol-stop-finder.html +0 -15
  297. package/doc/public/static/examples/ol-stop-finder.js +0 -35
  298. package/doc/public/static/examples/ol-stop-finder.md +0 -1
  299. package/doc/public/static/examples/ol-tracker.html +0 -1
  300. package/doc/public/static/examples/ol-tracker.js +0 -41
  301. package/doc/public/static/examples/ol-tracker.md +0 -1
  302. package/doc/public/static/examples/ol-tralis.html +0 -5
  303. package/doc/public/static/examples/ol-tralis.js +0 -62
  304. package/doc/public/static/examples/tralis-live-map.html +0 -1
  305. package/doc/public/static/examples/tralis-live-map.js +0 -67
  306. package/doc/public/static/examples/tralis-live-map.md +0 -3
  307. package/doc/public/static/img/live_tracker_mb.jpg +0 -0
  308. package/doc/public/static/img/live_tracker_munich.jpg +0 -0
  309. package/doc/public/static/img/live_tracker_ol.jpg +0 -0
  310. package/doc/public/static/img/mapbox.jpg +0 -0
  311. package/doc/public/static/img/mapbox_style.jpg +0 -0
  312. package/doc/public/static/img/ol-copyright.png +0 -0
  313. package/doc/public/static/img/query_objects.jpg +0 -0
  314. package/doc/public/static/img/routing.jpg +0 -0
  315. package/doc/public/static/img/simple_map.jpg +0 -0
  316. package/doc/public/static/img/stops.jpg +0 -0
  317. package/doc/public/vercel.svg +0 -4
  318. package/doc/src/components/CodeSandboxButton.js +0 -102
  319. package/doc/src/components/Documentation.js +0 -42
  320. package/doc/src/components/Esdoc/Anchor.js +0 -57
  321. package/doc/src/components/Esdoc/ClassDoc.js +0 -272
  322. package/doc/src/components/Esdoc/DeprecatedHTML.js +0 -16
  323. package/doc/src/components/Esdoc/DetailDocs.js +0 -279
  324. package/doc/src/components/Esdoc/DetailHTML.js +0 -33
  325. package/doc/src/components/Esdoc/DirectSubclassHTML.js +0 -30
  326. package/doc/src/components/Esdoc/DocBuilderUtils.js +0 -697
  327. package/doc/src/components/Esdoc/DocLinkHTML.js +0 -63
  328. package/doc/src/components/Esdoc/DocsLinkHTML.js +0 -38
  329. package/doc/src/components/Esdoc/Esdoc.js +0 -63
  330. package/doc/src/components/Esdoc/EsdocContent.js +0 -56
  331. package/doc/src/components/Esdoc/EsdocNavigation.js +0 -13
  332. package/doc/src/components/Esdoc/EsdocSearch.js +0 -78
  333. package/doc/src/components/Esdoc/ExperimentalHTML.js +0 -17
  334. package/doc/src/components/Esdoc/ExtendsChainHTML.js +0 -32
  335. package/doc/src/components/Esdoc/FileDocLinkHTML.js +0 -62
  336. package/doc/src/components/Esdoc/IdentifiersDoc.js +0 -113
  337. package/doc/src/components/Esdoc/IndirectSubclassHTML.js +0 -30
  338. package/doc/src/components/Esdoc/InheritedSummaryDoc.js +0 -70
  339. package/doc/src/components/Esdoc/InheritedSummaryHTML.js +0 -38
  340. package/doc/src/components/Esdoc/MixinClassesHTML.js +0 -29
  341. package/doc/src/components/Esdoc/NavDoc.js +0 -112
  342. package/doc/src/components/Esdoc/OverrideMethod.js +0 -44
  343. package/doc/src/components/Esdoc/OverrideMethodDescription.js +0 -35
  344. package/doc/src/components/Esdoc/Properties.js +0 -89
  345. package/doc/src/components/Esdoc/README.md +0 -45
  346. package/doc/src/components/Esdoc/SignatureHTML.js +0 -123
  347. package/doc/src/components/Esdoc/SingleDoc.js +0 -31
  348. package/doc/src/components/Esdoc/SummaryDoc.js +0 -160
  349. package/doc/src/components/Esdoc/SummaryHTML.js +0 -96
  350. package/doc/src/components/Esdoc/TypeDocLinkHTML.js +0 -251
  351. package/doc/src/components/Esdoc/index.js +0 -7
  352. package/doc/src/components/Esdoc/taffydb.js +0 -2070
  353. package/doc/src/components/Example.js +0 -200
  354. package/doc/src/components/ExampleCard.js +0 -126
  355. package/doc/src/components/Examples.js +0 -78
  356. package/doc/src/components/Home.js +0 -121
  357. package/doc/src/components/TrackerExample.js +0 -39
  358. package/doc/src/examples.js +0 -117
  359. package/doc/styles/App.scss +0 -53
  360. package/doc/styles/identifiers.css +0 -38
  361. package/doc/styles/search.css +0 -76
  362. package/doc/styles/style.css +0 -603
  363. package/esdoc/README.md +0 -27
  364. package/esdoc/plugins/MyPlugin.js +0 -69
  365. package/esdoc/plugins/dynamic-property-plugin/Plugin.js +0 -50
  366. package/esdoc/plugins/externals-plugin/Plugin.js +0 -45
  367. package/esdoc/plugins/externals-plugin/externals.js +0 -93
  368. package/esdoc/plugins/optional-chaining-plugin/Plugin.js +0 -8
  369. package/global-setup.js +0 -3
  370. package/jest.config.js +0 -24
  371. package/pull_request_template.md +0 -17
  372. package/scripts/read-pkg-json.js +0 -22
  373. package/src/api/RealtimeAPI.test.js +0 -144
  374. package/src/api/RealtimeAPI.ts +0 -712
  375. package/src/api/RoutingAPI.test.js +0 -41
  376. package/src/api/RoutingAPI.ts +0 -47
  377. package/src/api/StopsAPI.test.js +0 -34
  378. package/src/api/StopsAPI.ts +0 -45
  379. package/src/common/api/HttpAPI.test.js +0 -68
  380. package/src/common/api/HttpAPI.ts +0 -77
  381. package/src/common/api/WebSocketAPI.test.js +0 -421
  382. package/src/common/api/WebSocketAPI.ts +0 -515
  383. package/src/common/controls/ControlCommon.test.js +0 -106
  384. package/src/common/controls/ControlCommon.ts +0 -194
  385. package/src/common/controls/CopyrightControlCommon.ts +0 -41
  386. package/src/common/controls/StopFinderControlCommon.ts +0 -192
  387. package/src/common/layers/LayerCommon.test.js +0 -158
  388. package/src/common/layers/LayerCommon.ts +0 -321
  389. package/src/common/mixins/RealtimeLayerMixin.ts +0 -1168
  390. package/src/common/mixins/UserInteractionsLayerMixin.test.js +0 -227
  391. package/src/common/mixins/UserInteractionsLayerMixin.ts +0 -352
  392. package/src/common/styles/realtimeDefaultStyle.ts +0 -436
  393. package/src/common/styles/realtimeDelayStyle.ts +0 -27
  394. package/src/common/styles/realtimeHeadingStyle.ts +0 -138
  395. package/src/common/styles/realtimeSimpleStyle.ts +0 -25
  396. package/src/common/utils/compareDepartures.ts +0 -46
  397. package/src/common/utils/createCanvas.ts +0 -33
  398. package/src/common/utils/createRealtimeFilters.test.js +0 -100
  399. package/src/common/utils/createRealtimeFilters.ts +0 -96
  400. package/src/common/utils/debounceDeparturesMessages.ts +0 -52
  401. package/src/common/utils/debounceWebsocketMessages.ts +0 -47
  402. package/src/common/utils/getLayersAsFlatArray.ts +0 -17
  403. package/src/common/utils/getMapboxMapCopyrights.test.js +0 -47
  404. package/src/common/utils/getMapboxMapCopyrights.ts +0 -52
  405. package/src/common/utils/getMapboxRender.ts +0 -104
  406. package/src/common/utils/getMaplibreRender.ts +0 -54
  407. package/src/common/utils/getUrlWithParams.ts +0 -21
  408. package/src/common/utils/getVehiclePosition.ts +0 -92
  409. package/src/common/utils/realtimeConfig.test.js +0 -57
  410. package/src/common/utils/realtimeConfig.ts +0 -228
  411. package/src/common/utils/removeDuplicate.test.js +0 -22
  412. package/src/common/utils/removeDuplicate.ts +0 -22
  413. package/src/common/utils/renderTrajectories.ts +0 -194
  414. package/src/common/utils/sortAndFilterDepartures.ts +0 -78
  415. package/src/common/utils/sortByDelay.ts +0 -29
  416. package/src/common/utils/timeUtils.test.js +0 -16
  417. package/src/common/utils/timeUtils.ts +0 -45
  418. package/src/index.js +0 -10
  419. package/src/mapbox/layers/Layer.test.js +0 -217
  420. package/src/mapbox/layers/Layer.ts +0 -144
  421. package/src/mapbox/layers/RealtimeLayer.test.js +0 -13
  422. package/src/mapbox/layers/RealtimeLayer.ts +0 -350
  423. package/src/mapbox/utils/getMercatorResolution.ts +0 -21
  424. package/src/mapbox/utils/getSourceCoordinates.ts +0 -34
  425. package/src/ol/README.md +0 -0
  426. package/src/ol/controls/CopyrightControl.test.js +0 -211
  427. package/src/ol/controls/CopyrightControl.ts +0 -82
  428. package/src/ol/controls/RoutingControl.test.js +0 -205
  429. package/src/ol/controls/RoutingControl.ts +0 -869
  430. package/src/ol/controls/StopFinderControl.test.js +0 -59
  431. package/src/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
  432. package/src/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
  433. package/src/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
  434. package/src/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
  435. package/src/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
  436. package/src/ol/controls/snapshots/RoutingControlStation1.json +0 -60
  437. package/src/ol/controls/snapshots/RoutingControlStation2.json +0 -49
  438. package/src/ol/layers/Layer.test.js +0 -212
  439. package/src/ol/layers/Layer.ts +0 -252
  440. package/src/ol/layers/MapGlLayer.ts +0 -294
  441. package/src/ol/layers/MapboxLayer.test.js +0 -190
  442. package/src/ol/layers/MapboxLayer.ts +0 -136
  443. package/src/ol/layers/MapboxStyleLayer.test.js +0 -258
  444. package/src/ol/layers/MapboxStyleLayer.ts +0 -466
  445. package/src/ol/layers/RealtimeLayer.test.js +0 -84
  446. package/src/ol/layers/RealtimeLayer.ts +0 -465
  447. package/src/ol/layers/RoutingLayer.test.js +0 -48
  448. package/src/ol/layers/RoutingLayer.ts +0 -113
  449. package/src/ol/layers/VectorLayer.test.js +0 -87
  450. package/src/ol/layers/VectorLayer.ts +0 -48
  451. package/src/ol/layers/WMSLayer.test.js +0 -65
  452. package/src/ol/layers/WMSLayer.ts +0 -114
  453. package/src/ol/styles/fullTrajectoryDelayStyle.ts +0 -37
  454. package/src/ol/styles/fullTrajectoryStyle.ts +0 -56
  455. package/tsconfig.json +0 -23
  456. /package/{src/api → api}/index.js +0 -0
  457. /package/{src/common → common}/index.js +0 -0
  458. /package/{src/common → common}/styles/index.js +0 -0
  459. /package/{src/mapbox → mapbox}/controls/index.js +0 -0
  460. /package/{src/mapbox → mapbox}/index.js +0 -0
  461. /package/{src/mapbox → mapbox}/layers/index.js +0 -0
  462. /package/{src/mapbox → mapbox}/utils/index.js +0 -0
  463. /package/{src/ol → ol}/controls/index.js +0 -0
  464. /package/{src/ol → ol}/index.js +0 -0
  465. /package/{src/ol → ol}/layers/index.js +0 -0
  466. /package/{src/ol → ol}/styles/index.js +0 -0
  467. /package/{src/types → types}/common.d.ts +0 -0
  468. /package/{src/types → types}/index.d.ts +0 -0
  469. /package/{src/types → types}/realtime.d.ts +0 -0
  470. /package/{src/types → types}/routing.d.ts +0 -0
  471. /package/{src/types → types}/stops.d.ts +0 -0
@@ -1,712 +0,0 @@
1
- import WebSocketAPI, {
2
- WebSocketAPIMessageCallback,
3
- WebSocketAPIMessageEventData,
4
- WebSocketAPIParameters,
5
- } from '../common/api/WebSocketAPI';
6
- import debounceWebsocketMessages from '../common/utils/debounceWebsocketMessages';
7
- import getModeSuffix from '../common/utils/getRealtimeModeSuffix';
8
- import type {
9
- RealtimeMode,
10
- RealtimeDeparture,
11
- RealtimeNews,
12
- RealtimeStation,
13
- RealtimeExtraGeom,
14
- RealtimeTrainId,
15
- RealtimeGeneralizationLevel,
16
- RealtimeFullTrajectory,
17
- RealtimeTrajectoryResponse,
18
- RealtimeStationId,
19
- RealtimeVersion,
20
- RealtimeTrajectory,
21
- RealtimeTenant,
22
- } from '../types';
23
- import { StopSequence } from './typedefs';
24
-
25
- export type RealtimeAPIOptions = {
26
- url?: string;
27
- apiKey?: string;
28
- version?: RealtimeVersion;
29
- bbox?: (number | string)[];
30
- buffer?: number[];
31
- pingIntervalMs?: number;
32
- };
33
-
34
- export declare type RealtimeAPIExtraGeomsById = {
35
- [index: string]: RealtimeExtraGeom;
36
- };
37
-
38
- export type RealtimeAPIDeparturesById = {
39
- [index: string]: RealtimeDeparture;
40
- };
41
-
42
- export type RealtimeModesType = {
43
- RAW: RealtimeMode;
44
- TOPOGRAPHIC: RealtimeMode;
45
- SCHEMATIC: RealtimeMode;
46
- };
47
-
48
- /**
49
- * Enum for Realtime modes.
50
- * @readonly
51
- * @typedef {string} RealtimeMode
52
- * @property {string} RAW "raw"
53
- * @property {string} SCHEMATIC "schematic"
54
- * @property {string} TOPOGRAPHIC "topographic"
55
- * @enum {RealtimeMode}
56
- */
57
- export const RealtimeModes = {
58
- RAW: 'raw' as RealtimeMode,
59
- TOPOGRAPHIC: 'topographic' as RealtimeMode,
60
- SCHEMATIC: 'schematic' as RealtimeMode,
61
- };
62
-
63
- /**
64
- * This class provides convenience methods to access to the [geOps realtime api](https://developer.geops.io/apis/realtime/).
65
- *
66
- * @example
67
- * import { RealtimeAPI } from 'mobility-toolbox-js/api';
68
- *
69
- * const api = new RealtimeAPI({
70
- * url: "yourUrl",
71
- * apiKey: "yourApiKey"
72
- * });
73
- *
74
- * @example
75
- * import { RealtimeAPI } from 'mobility-toolbox-js/api';
76
- *
77
- * const api = new RealtimeAPI("yourUrl");
78
- */
79
- class RealtimeAPI {
80
- url!: string;
81
-
82
- version: RealtimeVersion = '2';
83
-
84
- wsApi!: WebSocketAPI;
85
-
86
- bbox?: (number | string)[];
87
-
88
- buffer?: number[];
89
-
90
- private pingInterval!: number;
91
-
92
- private pingIntervalMs!: number;
93
-
94
- private reconnectTimeout?: number;
95
-
96
- private reconnectTimeoutMs?: number;
97
-
98
- /**
99
- * Constructor
100
- *
101
- * @param {Object|string} options A string representing the url of the service or an object containing the url and the apiKey.
102
- * @param {string} options.url Url to the [geOps realtime api](https://developer.geops.io/apis/realtime/).
103
- * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
104
- * @param {number[5]} [options.bbox=[minX, minY, maxX, maxY, zoom, tenant] The bounding box to receive data from.
105
- */
106
- constructor(options: RealtimeAPIOptions = {}) {
107
- this.defineProperties(options);
108
-
109
- /** @private */
110
- this.onOpen = this.onOpen.bind(this);
111
- }
112
-
113
- /* @private */
114
- defineProperties(options: RealtimeAPIOptions = {}) {
115
- let opt = options || {};
116
-
117
- if (typeof options === 'string') {
118
- opt = { url: options };
119
- }
120
-
121
- const { apiKey, version } = opt;
122
- let { url, bbox, buffer = [100, 100] } = opt;
123
- const wsApi = new WebSocketAPI();
124
-
125
- if (!url) {
126
- url = 'wss://api.geops.io/tracker-ws/v1/';
127
- }
128
-
129
- if (apiKey) {
130
- url = `${url}?key=${apiKey}`;
131
- }
132
-
133
- Object.defineProperties(this, {
134
- url: {
135
- get: () => url,
136
- set: (newUrl) => {
137
- if (url !== newUrl) {
138
- url = newUrl;
139
-
140
- // Update the websocket only if the url has changed and the websocket is already open or is opening.
141
- if (this.wsApi.open || this.wsApi.connecting) {
142
- this.open();
143
- }
144
- }
145
- },
146
- },
147
- bbox: {
148
- get: () => bbox,
149
- set: (newBbox) => {
150
- if (JSON.stringify(newBbox) !== JSON.stringify(bbox)) {
151
- bbox = newBbox;
152
- if (this.wsApi && bbox) {
153
- this.wsApi.send(`BBOX ${bbox.join(' ')}`);
154
- }
155
- }
156
- },
157
- },
158
- buffer: {
159
- get: () => buffer,
160
- set: (newBuffer) => {
161
- if (JSON.stringify(newBuffer) !== JSON.stringify(buffer)) {
162
- buffer = newBuffer;
163
- if (this.wsApi) {
164
- this.wsApi.send(`BUFFER ${buffer.join(' ')}`);
165
- }
166
- }
167
- },
168
- },
169
- /**
170
- * The RealtimeApi version
171
- */
172
- version: {
173
- value: version,
174
- writable: true,
175
- },
176
- /**
177
- * The websocket helper class to connect the websocket.
178
- *
179
- * @private
180
- */
181
- wsApi: {
182
- value: wsApi,
183
- writable: true,
184
- },
185
- /**
186
- * Interval between PING request in ms.
187
- * If equal to 0, no PING request are sent.
188
- * @type {number}
189
- * @private
190
- */
191
- pingIntervalMs: {
192
- value: options.pingIntervalMs || 10000,
193
- writable: true,
194
- },
195
- /**
196
- * Timeout in ms after an automatic reconnection when the websoscket has been closed by the server.
197
- * @type {number}
198
- */
199
- reconnectTimeoutMs: {
200
- value: options.pingIntervalMs || 100,
201
- writable: true,
202
- },
203
- });
204
- }
205
-
206
- open() {
207
- this.wsApi.connect(this.url, this.onOpen);
208
-
209
- // Register reconnection on close.
210
- if (this.wsApi.websocket) {
211
- this.wsApi.websocket.onclose = () => {
212
- this.onClose();
213
- };
214
- }
215
- }
216
-
217
- /**
218
- * Close the websocket connection without reconnection.
219
- */
220
- close() {
221
- this.wsApi.close();
222
- }
223
-
224
- /**
225
- * Unsubscribe trajectory and deleted_vehicles channels. To resubscribe you have to set a new BBOX.
226
- */
227
- // eslint-disable-next-line class-methods-use-this
228
- reset() {
229
- this.wsApi.send('RESET');
230
- }
231
-
232
- /**
233
- * Callback when the websocket is opened and ready.
234
- * It applies the bbox and the projection.
235
- */
236
- onOpen() {
237
- if (this.bbox) {
238
- this.wsApi.send(`BBOX ${this.bbox.join(' ')}`);
239
- }
240
-
241
- if (this.buffer) {
242
- this.wsApi.send(`BUFFER ${this.buffer.join(' ')}`);
243
- }
244
-
245
- /**
246
- * Keep websocket alive
247
- */
248
- if (this.pingIntervalMs) {
249
- window.clearInterval(this.pingInterval);
250
- /** @private */
251
- this.pingInterval = window.setInterval(() => {
252
- this.wsApi.send('PING');
253
- }, this.pingIntervalMs);
254
- }
255
- }
256
-
257
- /**
258
- * Callback when the websocket is closed by the server.
259
- * It auto reconnects after a timeout.
260
- */
261
- onClose() {
262
- window.clearTimeout(this.pingInterval);
263
- window.clearTimeout(this.reconnectTimeout);
264
-
265
- if (this.reconnectTimeoutMs) {
266
- /** @private */
267
- this.reconnectTimeout = window.setTimeout(
268
- () => this.open(),
269
- this.reconnectTimeoutMs,
270
- );
271
- }
272
- }
273
-
274
- /**
275
- * Send GET to a channel.
276
- *
277
- * @param {string | WebSocketAPIParameters} channelOrParams Name of the websocket channel to send GET or an object representing parameters to send
278
- * @return {Promise<WebSocketAPIMessageEventData<?>>} A websocket response.
279
- */
280
- get(
281
- channelOrParams: string | WebSocketAPIParameters,
282
- ): Promise<WebSocketAPIMessageEventData<any>> {
283
- let params = channelOrParams as WebSocketAPIParameters;
284
-
285
- if (typeof channelOrParams === 'string') {
286
- params = { channel: channelOrParams };
287
- }
288
-
289
- return new Promise((resolve, reject) => {
290
- this.wsApi.get(params, resolve, reject);
291
- });
292
- }
293
-
294
- /**
295
- * Subscribe to a channel.
296
- *
297
- * @param {string} channel Name of the websocket channel to subscribe.
298
- * @param {function} onSuccess Callback when the subscription succeeds.
299
- * @param {function} onError Callback when the subscription fails.
300
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
301
- * @private
302
- */
303
- subscribe(
304
- channel: string,
305
- onSuccess: WebSocketAPIMessageCallback<any>,
306
- onError: EventListener = () => {},
307
- quiet: boolean = false,
308
- ) {
309
- if (!channel || !onSuccess) {
310
- return;
311
- }
312
- this.wsApi.subscribe({ channel }, onSuccess, onError, quiet);
313
- }
314
-
315
- /**
316
- * Unsubscribe both modes of a channel.
317
- *
318
- * @param {string} channel Name of the websocket channel to unsubscribe.
319
- * @param {string} suffix Suffix to add to the channel name.
320
- * @param {function} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
321
- * @private
322
- */
323
- unsubscribe(
324
- channel: string,
325
- suffix: string = '',
326
- onMessage?: WebSocketAPIMessageCallback<any>,
327
- ) {
328
- const suffixSchenatic = getModeSuffix(
329
- RealtimeModes.SCHEMATIC,
330
- RealtimeModes,
331
- );
332
- const suffixTopographic = getModeSuffix(
333
- RealtimeModes.TOPOGRAPHIC,
334
- RealtimeModes,
335
- );
336
- this.wsApi.unsubscribe(
337
- `${channel}${suffixSchenatic}${suffix || ''}`,
338
- onMessage,
339
- );
340
- this.wsApi.unsubscribe(
341
- `${channel}${suffixTopographic}${suffix || ''}`,
342
- onMessage,
343
- );
344
- }
345
-
346
- /**
347
- * Subscribe to departures channel of a given station.
348
- *
349
- * @param {number} stationId UIC of the station.
350
- * @param {Boolean} sortByMinArrivalTime Sort by minimum arrival time
351
- * @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
352
- * @param {function} onError Callback when the subscription fails.
353
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
354
- */
355
- subscribeDepartures(
356
- stationId: number,
357
- onMessage: WebSocketAPIMessageCallback<RealtimeDeparture>,
358
- onError: EventListener = () => {},
359
- quiet: boolean = false,
360
- ) {
361
- this.subscribe(`timetable_${stationId}`, onMessage, onError, quiet);
362
- }
363
-
364
- /**
365
- * Unsubscribe from current departures channel.
366
- * @param {RealtimeStationId} id Station's id
367
- * @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
368
- */
369
- unsubscribeDepartures(
370
- id: RealtimeStationId,
371
- onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>,
372
- ) {
373
- this.unsubscribe(`timetable_${id}`, '', onMessage);
374
- }
375
-
376
- /**
377
- * Subscribe to the disruptions channel for tenant.
378
- *
379
- * @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
380
- * @param {function} onError Callback when the subscription fails.
381
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
382
- */
383
- subscribeDisruptions(
384
- tenant: RealtimeTenant,
385
- onMessage: WebSocketAPIMessageCallback<RealtimeNews>,
386
- onError: EventListener = () => {},
387
- quiet: boolean = false,
388
- ) {
389
- this.subscribe(`${tenant}_newsticker`, onMessage, onError, quiet);
390
- }
391
-
392
- /**
393
- * Unsubscribe disruptions.
394
- *
395
- * @param {function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
396
- */
397
- unsubscribeDisruptions(
398
- tenant: RealtimeTenant,
399
- onMessage?: WebSocketAPIMessageCallback<RealtimeNews>,
400
- ) {
401
- this.unsubscribe(`${tenant}_newsticker`, '', onMessage);
402
- }
403
-
404
- /**
405
- * Return a station with a given uic number and a mode.
406
- *
407
- * @param {number} uic UIC of the station.
408
- * @param {RealtimeMode} mode Realtime mode.
409
- * @return {Promise<{data: { content: RealtimeStation }}>} A station.
410
- */
411
- getStation(
412
- uic: RealtimeStationId,
413
- mode: RealtimeMode,
414
- ): Promise<WebSocketAPIMessageEventData<RealtimeStation>> {
415
- const params = {
416
- channel: `station${getModeSuffix(mode, RealtimeModes)}`,
417
- args: uic,
418
- };
419
-
420
- return this.get(params);
421
- }
422
-
423
- /**
424
- * Get the list of ststions available for a specifc mode. The promise is resolved every 100ms
425
- * @param {RealtimeMode} mode Realtime mode.
426
- * @param {number} timeout = 100 Duration in ms between each promise resolve calls.
427
- * @return {Promise<RealtimeStation[]>} An array of stations.
428
- */
429
- getStations(mode: RealtimeMode, timeout = 100): Promise<RealtimeStation[]> {
430
- return new Promise((resolve) => {
431
- this.get(`station${getModeSuffix(mode, RealtimeModes)}`).then(
432
- debounceWebsocketMessages(resolve, undefined, timeout),
433
- );
434
- });
435
- }
436
-
437
- /**
438
- * Subscribe to stations channel.
439
- * One message pro station.
440
- *
441
- * @param {RealtimeMode} mode Realtime mode.
442
- * @param {function(data: { content: RealtimeStation })} onMessage Function called on each message of the channel.
443
- * @param {function} onError Callback when the subscription fails.
444
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
445
- */
446
- subscribeStations(
447
- mode: RealtimeMode,
448
- onMessage: WebSocketAPIMessageCallback<RealtimeStation>,
449
- onError: EventListener = () => {},
450
- quiet: boolean = false,
451
- ) {
452
- this.subscribe(
453
- `station${getModeSuffix(mode, RealtimeModes)}`,
454
- onMessage,
455
- onError,
456
- quiet,
457
- );
458
- }
459
-
460
- /**
461
- * Unsubscribe to stations channel.
462
- * @param {function(data: { content: RealtimeStation })} onMessage The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
463
- */
464
- unsubscribeStations(
465
- onMessage?: WebSocketAPIMessageCallback<RealtimeStation>,
466
- ) {
467
- this.unsubscribe('station', '', onMessage);
468
- }
469
-
470
- /**
471
- * Subscribe to extra_geoms channel.
472
- *
473
- * @param {function(data: { content: RealtimeExtraGeom })} onMessage Function called on each message of the channel.
474
- * @param {function} onError Callback when the subscription fails.
475
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
476
- */
477
- subscribeExtraGeoms(
478
- onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>,
479
- onError: EventListener = () => {},
480
- quiet: boolean = false,
481
- ) {
482
- this.subscribe('extra_geoms', onMessage, onError, quiet);
483
- }
484
-
485
- /**
486
- * Unsubscribe to extra_geoms channel.
487
- * @param {function(data: { content: RealtimeExtraGeom })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
488
- */
489
- unsubscribeExtraGeoms(
490
- onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>,
491
- ) {
492
- this.unsubscribe('extra_geoms', '', onMessage);
493
- }
494
-
495
- /**
496
- * Return a partial trajectory with a given id and a mode.
497
- *
498
- * @param {number} trainId The identifier of a trajectory.
499
- * @param {RealtimeMode} mode Realtime mode.
500
- * @return {Promise<{data: { content: RealtimeTrajectory }}>} A trajectory.
501
- */
502
- getTrajectory(
503
- id: RealtimeTrainId,
504
- mode: RealtimeMode,
505
- ): Promise<WebSocketAPIMessageEventData<RealtimeTrajectory>> {
506
- return this.get(
507
- `partial_trajectory${getModeSuffix(mode, RealtimeModes)}_${id}`,
508
- );
509
- }
510
-
511
- /**
512
- * Subscribe to trajectory channel.
513
- *
514
- * @param {RealtimeMode} mode Realtime mode.
515
- * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Function called on each message of the channel.
516
- * @param {function} onError Callback when the subscription fails.
517
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
518
- */
519
- subscribeTrajectory(
520
- mode: RealtimeMode,
521
- onMessage: WebSocketAPIMessageCallback<
522
- RealtimeTrajectoryResponse[] | RealtimeTrajectoryResponse
523
- >,
524
- onError: EventListener = () => {},
525
- quiet: boolean = false,
526
- ) {
527
- this.unsubscribeTrajectory(onMessage);
528
-
529
- let suffix = '';
530
- if (this.version === '1') {
531
- suffix = getModeSuffix(mode, RealtimeModes);
532
- }
533
-
534
- this.subscribe(`trajectory${suffix}`, onMessage, onError, quiet);
535
- }
536
-
537
- /**
538
- * Unsubscribe to trajectory channels.
539
- * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
540
- */
541
- unsubscribeTrajectory(
542
- onMessage: WebSocketAPIMessageCallback<RealtimeTrajectoryResponse[]>,
543
- ) {
544
- this.unsubscribe(`trajectory`, '', onMessage);
545
- }
546
-
547
- /**
548
- * Subscribe to deleted_vhicles channel.
549
- *
550
- * @param {RealtimeMode} mode Realtime mode.
551
- * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
552
- * @param {function} onError Callback when the subscription fails.
553
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
554
- */
555
- subscribeDeletedVehicles(
556
- mode: RealtimeMode,
557
- onMessage: WebSocketAPIMessageCallback<RealtimeTrainId>,
558
- onError: EventListener = () => {},
559
- quiet: boolean = false,
560
- ) {
561
- this.unsubscribeDeletedVehicles(onMessage);
562
-
563
- let suffix = '';
564
- if (this.version === '1') {
565
- suffix = getModeSuffix(mode, RealtimeModes);
566
- }
567
-
568
- this.subscribe(`deleted_vehicles${suffix}`, onMessage, onError, quiet);
569
- }
570
-
571
- /**
572
- * Unsubscribe to deleted_vhicles channels.
573
- * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
574
- */
575
- unsubscribeDeletedVehicles(
576
- onMessage: WebSocketAPIMessageCallback<RealtimeTrainId>,
577
- ) {
578
- this.unsubscribe('deleted_vehicles', '', onMessage);
579
- }
580
-
581
- /**
582
- * Get a full trajectory of a vehicule .
583
- *
584
- * @param {string} id A vehicle id.
585
- * @param {RealtimeMode} mode Realtime mode.
586
- * @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
587
- * @return {Promise<{ data: { content: RealtimeFullTrajectory } }>} Return a full trajectory.
588
- */
589
- getFullTrajectory(
590
- id: RealtimeTrainId,
591
- mode: RealtimeMode,
592
- generalizationLevel: RealtimeGeneralizationLevel | undefined,
593
- ): Promise<WebSocketAPIMessageEventData<RealtimeFullTrajectory>> {
594
- let suffix = '';
595
- if (this.version === '1') {
596
- suffix = getModeSuffix(mode, RealtimeModes);
597
- }
598
-
599
- const channel = [`full_trajectory${suffix}`];
600
- if (id) {
601
- channel.push(id);
602
- }
603
-
604
- if ((!mode || mode === RealtimeModes.TOPOGRAPHIC) && generalizationLevel) {
605
- channel.push(`gen${generalizationLevel}`);
606
- }
607
-
608
- return this.get(channel.join('_'));
609
- }
610
-
611
- /**
612
- * Subscribe to full_trajectory channel of a given vehicle.
613
- *
614
- * @param {string} id A vehicle id.
615
- * @param {RealtimeMode} mode Realtime mode.
616
- * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Function called on each message of the channel.
617
- * @param {function} onError Callback when the subscription fails.
618
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
619
- */
620
- subscribeFullTrajectory(
621
- id: RealtimeTrainId,
622
- mode: RealtimeMode,
623
- onMessage: WebSocketAPIMessageCallback<RealtimeFullTrajectory>,
624
- onError: EventListener = () => {},
625
- quiet: boolean = false,
626
- ) {
627
- let suffix = '';
628
- if (this.version === '1') {
629
- suffix = getModeSuffix(mode, RealtimeModes);
630
- }
631
-
632
- this.subscribe(`full_trajectory${suffix}_${id}`, onMessage, onError, quiet);
633
- }
634
-
635
- /**
636
- * Unsubscribe from full_trajectory channel
637
- *
638
- * @param {string} id A vehicle id.
639
- * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
640
- */
641
- unsubscribeFullTrajectory(
642
- id: RealtimeTrainId,
643
- onMessage?: WebSocketAPIMessageCallback<RealtimeFullTrajectory>,
644
- ) {
645
- this.unsubscribe('full_trajectory', `_${id}`, onMessage);
646
- }
647
-
648
- /**
649
- * Get the list of stops for this vehicle.
650
- *
651
- * @param {string} id A vehicle id.
652
- * @return {Promise<{ data: { content: StopSequence[] } }>} Returns a stop sequence object.
653
- */
654
- getStopSequence(
655
- id: RealtimeTrainId,
656
- ): Promise<WebSocketAPIMessageEventData<StopSequence[]>> {
657
- return this.get(`stopsequence_${id}`);
658
- }
659
-
660
- /**
661
- * Subscribe to stopsequence channel of a given vehicle.
662
- *
663
- * @param {string} id A vehicle id.
664
- * @param {function(data: { content: StopSequence[] })} onMessage Function called on each message of the channel.
665
- * @param {function} onError Callback when the subscription fails.
666
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
667
- */
668
- subscribeStopSequence(
669
- id: RealtimeTrainId,
670
- onMessage: WebSocketAPIMessageCallback<StopSequence[]>,
671
- onError: EventListener = () => {},
672
- quiet: boolean = false,
673
- ) {
674
- this.subscribe(`stopsequence_${id}`, onMessage, onError, quiet);
675
- }
676
-
677
- /**
678
- * Unsubscribe from stopsequence channel
679
- *
680
- * @param {string} id A vehicle id.
681
- * @param {function(data: { content: StopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
682
- */
683
- unsubscribeStopSequence(
684
- id: RealtimeTrainId,
685
- onMessage?: WebSocketAPIMessageCallback<StopSequence[]>,
686
- ) {
687
- this.unsubscribe(`stopsequence`, `_${id}`, onMessage);
688
- }
689
-
690
- /**
691
- * Subscribe to healthcheck channel.
692
- * @param {function(data: { content: string })} onMessage Callback when the subscribe to healthcheck channel succeeds.
693
- * @param {function} onError Callback when the subscription fails.
694
- * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
695
- */
696
- subscribeHealthCheck(
697
- onMessage: WebSocketAPIMessageCallback<string>,
698
- onError: EventListener = () => {},
699
- quiet: boolean = false,
700
- ) {
701
- this.subscribe('healthcheck', onMessage, onError, quiet);
702
- }
703
-
704
- /**
705
- * Unsubscribe to healthcheck channel.
706
- * @param {function(data: { content: string })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
707
- */
708
- unsubscribeHealthCheck(onMessage?: WebSocketAPIMessageCallback<string>) {
709
- this.unsubscribe('healthcheck', '', onMessage);
710
- }
711
- }
712
- export default RealtimeAPI;