mobility-toolbox-js 2.0.1-beta.13 → 2.1.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 (259) hide show
  1. package/api/RealtimeAPI.d.ts +279 -0
  2. package/api/RealtimeAPI.d.ts.map +1 -0
  3. package/api/RealtimeAPI.js +466 -0
  4. package/api/RoutingAPI.d.ts +37 -0
  5. package/api/RoutingAPI.d.ts.map +1 -0
  6. package/api/RoutingAPI.js +32 -12
  7. package/api/StopsAPI.d.ts +38 -0
  8. package/api/StopsAPI.d.ts.map +1 -0
  9. package/api/StopsAPI.js +33 -9
  10. package/api/index.d.ts +4 -0
  11. package/api/index.d.ts.map +1 -0
  12. package/api/index.js +3 -3
  13. package/api/typedefs.d.ts +179 -0
  14. package/api/typedefs.d.ts.map +1 -0
  15. package/api/typedefs.js +75 -0
  16. package/common/api/HttpAPI.d.ts +31 -0
  17. package/common/api/HttpAPI.d.ts.map +1 -0
  18. package/common/api/HttpAPI.js +54 -27
  19. package/common/api/WebSocketAPI.d.ts +153 -0
  20. package/common/api/WebSocketAPI.d.ts.map +1 -0
  21. package/common/api/WebSocketAPI.js +330 -164
  22. package/common/controls/ControlCommon.d.ts +76 -0
  23. package/common/controls/ControlCommon.d.ts.map +1 -0
  24. package/common/controls/ControlCommon.js +150 -0
  25. package/common/controls/CopyrightControlCommon.d.ts +13 -0
  26. package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
  27. package/common/controls/CopyrightControlCommon.js +34 -0
  28. package/common/controls/StopFinderControlCommon.d.ts +55 -0
  29. package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
  30. package/common/controls/StopFinderControlCommon.js +144 -0
  31. package/common/index.d.ts +3 -0
  32. package/common/index.d.ts.map +1 -0
  33. package/common/index.js +2 -4
  34. package/common/layers/LayerCommon.d.ts +94 -0
  35. package/common/layers/LayerCommon.d.ts.map +1 -0
  36. package/common/layers/LayerCommon.js +244 -0
  37. package/common/mixins/RealtimeLayerMixin.d.ts +286 -0
  38. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
  39. package/common/mixins/RealtimeLayerMixin.js +776 -0
  40. package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
  41. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
  42. package/common/mixins/UserInteractionsLayerMixin.js +241 -0
  43. package/common/styles/index.d.ts +5 -0
  44. package/common/styles/index.d.ts.map +1 -0
  45. package/common/styles/index.js +4 -4
  46. package/common/styles/realtimeDefaultStyle.d.ts +36 -0
  47. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
  48. package/common/styles/realtimeDefaultStyle.js +275 -0
  49. package/common/styles/realtimeDelayStyle.d.ts +12 -0
  50. package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
  51. package/common/styles/realtimeDelayStyle.js +13 -0
  52. package/common/styles/realtimeHeadingStyle.d.ts +12 -0
  53. package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
  54. package/common/styles/realtimeHeadingStyle.js +85 -0
  55. package/common/styles/realtimeSimpleStyle.d.ts +4 -0
  56. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
  57. package/common/styles/realtimeSimpleStyle.js +23 -0
  58. package/common/typedefs.d.ts +111 -0
  59. package/common/typedefs.d.ts.map +1 -0
  60. package/common/typedefs.js +52 -0
  61. package/common/utils/compareDepartures.d.ts +11 -0
  62. package/common/utils/compareDepartures.d.ts.map +1 -0
  63. package/common/utils/compareDepartures.js +35 -0
  64. package/common/utils/createCanvas.d.ts +10 -0
  65. package/common/utils/createCanvas.d.ts.map +1 -0
  66. package/common/utils/createCanvas.js +27 -0
  67. package/common/utils/createRealtimeFilters.d.ts +13 -0
  68. package/common/utils/createRealtimeFilters.d.ts.map +1 -0
  69. package/common/utils/createRealtimeFilters.js +74 -0
  70. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  71. package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
  72. package/common/utils/debounceDeparturesMessages.js +24 -0
  73. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  74. package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
  75. package/common/utils/debounceWebsocketMessages.js +29 -0
  76. package/common/utils/getLayersAsFlatArray.d.ts +3 -0
  77. package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
  78. package/common/utils/getLayersAsFlatArray.js +15 -0
  79. package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
  80. package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
  81. package/common/utils/getMapboxMapCopyrights.js +26 -15
  82. package/common/utils/getMapboxRender.d.ts +7 -0
  83. package/common/utils/getMapboxRender.d.ts.map +1 -0
  84. package/common/utils/getMapboxRender.js +87 -0
  85. package/common/utils/getMaplibreRender.d.ts +7 -0
  86. package/common/utils/getMaplibreRender.d.ts.map +1 -0
  87. package/common/utils/getMaplibreRender.js +38 -0
  88. package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
  89. package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
  90. package/common/utils/getRealtimeModeSuffix.js +7 -0
  91. package/common/utils/getUrlWithParams.d.ts +9 -0
  92. package/common/utils/getUrlWithParams.d.ts.map +1 -0
  93. package/common/utils/getUrlWithParams.js +18 -0
  94. package/common/utils/getVehiclePosition.d.ts +16 -0
  95. package/common/utils/getVehiclePosition.d.ts.map +1 -0
  96. package/common/utils/getVehiclePosition.js +67 -37
  97. package/common/utils/index.d.ts +17 -0
  98. package/common/utils/index.d.ts.map +1 -0
  99. package/common/utils/index.js +17 -5
  100. package/common/utils/realtimeConfig.d.ts +49 -0
  101. package/common/utils/realtimeConfig.d.ts.map +1 -0
  102. package/common/utils/realtimeConfig.js +173 -0
  103. package/common/utils/removeDuplicate.d.ts +10 -0
  104. package/common/utils/removeDuplicate.d.ts.map +1 -0
  105. package/common/utils/removeDuplicate.js +12 -5
  106. package/common/utils/renderTrajectories.d.ts +17 -0
  107. package/common/utils/renderTrajectories.d.ts.map +1 -0
  108. package/common/utils/renderTrajectories.js +110 -0
  109. package/common/utils/sortAndFilterDepartures.d.ts +16 -0
  110. package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
  111. package/common/utils/sortAndFilterDepartures.js +58 -0
  112. package/common/utils/sortByDelay.d.ts +3 -0
  113. package/common/utils/sortByDelay.d.ts.map +1 -0
  114. package/common/utils/sortByDelay.js +17 -15
  115. package/common/utils/timeUtils.d.ts +24 -0
  116. package/common/utils/timeUtils.d.ts.map +1 -0
  117. package/common/utils/timeUtils.js +34 -15
  118. package/iife.d.ts +3 -0
  119. package/iife.d.ts.map +1 -0
  120. package/iife.js +5 -0
  121. package/index.d.ts +10 -0
  122. package/index.d.ts.map +1 -0
  123. package/index.js +8 -6
  124. package/mapbox/controls/CopyrightControl.d.ts +29 -0
  125. package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
  126. package/mapbox/controls/CopyrightControl.js +44 -25
  127. package/mapbox/controls/index.d.ts +2 -0
  128. package/mapbox/controls/index.d.ts.map +1 -0
  129. package/mapbox/controls/index.js +2 -1
  130. package/mapbox/index.d.ts +6 -0
  131. package/mapbox/index.d.ts.map +1 -0
  132. package/mapbox/index.js +5 -4
  133. package/mapbox/layers/Layer.d.ts +59 -0
  134. package/mapbox/layers/Layer.d.ts.map +1 -0
  135. package/mapbox/layers/Layer.js +99 -55
  136. package/mapbox/layers/RealtimeLayer.d.ts +181 -0
  137. package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
  138. package/mapbox/layers/RealtimeLayer.js +276 -0
  139. package/mapbox/layers/index.d.ts +3 -0
  140. package/mapbox/layers/index.d.ts.map +1 -0
  141. package/mapbox/layers/index.js +2 -2
  142. package/mapbox/utils/getMercatorResolution.d.ts +9 -0
  143. package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
  144. package/mapbox/utils/getMercatorResolution.js +18 -0
  145. package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
  146. package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
  147. package/mapbox/utils/getSourceCoordinates.js +27 -0
  148. package/mapbox/utils/index.d.ts +3 -0
  149. package/mapbox/utils/index.d.ts.map +1 -0
  150. package/mapbox/utils/index.js +2 -0
  151. package/mbt.js +26061 -16500
  152. package/mbt.js.map +4 -4
  153. package/mbt.min.js +205 -126
  154. package/mbt.min.js.map +4 -4
  155. package/ol/controls/CopyrightControl.d.ts +31 -0
  156. package/ol/controls/CopyrightControl.d.ts.map +1 -0
  157. package/ol/controls/CopyrightControl.js +62 -36
  158. package/ol/controls/RoutingControl.d.ts +193 -0
  159. package/ol/controls/RoutingControl.d.ts.map +1 -0
  160. package/ol/controls/RoutingControl.js +601 -357
  161. package/ol/controls/StopFinderControl.d.ts +30 -0
  162. package/ol/controls/StopFinderControl.d.ts.map +1 -0
  163. package/ol/controls/StopFinderControl.js +30 -8
  164. package/ol/controls/index.d.ts +4 -0
  165. package/ol/controls/index.d.ts.map +1 -0
  166. package/ol/controls/index.js +3 -3
  167. package/ol/index.d.ts +6 -0
  168. package/ol/index.d.ts.map +1 -0
  169. package/ol/index.js +5 -5
  170. package/ol/layers/Layer.d.ts +86 -0
  171. package/ol/layers/Layer.d.ts.map +1 -0
  172. package/ol/layers/Layer.js +163 -77
  173. package/ol/layers/MapGlLayer.d.ts +67 -0
  174. package/ol/layers/MapGlLayer.d.ts.map +1 -0
  175. package/ol/layers/MapGlLayer.js +218 -0
  176. package/ol/layers/MapboxLayer.d.ts +50 -0
  177. package/ol/layers/MapboxLayer.d.ts.map +1 -0
  178. package/ol/layers/MapboxLayer.js +99 -193
  179. package/ol/layers/MapboxStyleLayer.d.ts +129 -0
  180. package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
  181. package/ol/layers/MapboxStyleLayer.js +362 -171
  182. package/ol/layers/MaplibreLayer.d.ts +28 -0
  183. package/ol/layers/MaplibreLayer.d.ts.map +1 -0
  184. package/ol/layers/MaplibreLayer.js +30 -135
  185. package/ol/layers/RealtimeLayer.d.ts +202 -0
  186. package/ol/layers/RealtimeLayer.d.ts.map +1 -0
  187. package/ol/layers/RealtimeLayer.js +340 -0
  188. package/ol/layers/RoutingLayer.d.ts +34 -0
  189. package/ol/layers/RoutingLayer.d.ts.map +1 -0
  190. package/ol/layers/RoutingLayer.js +72 -48
  191. package/ol/layers/VectorLayer.d.ts +25 -0
  192. package/ol/layers/VectorLayer.d.ts.map +1 -0
  193. package/ol/layers/VectorLayer.js +34 -18
  194. package/ol/layers/WMSLayer.d.ts +42 -0
  195. package/ol/layers/WMSLayer.d.ts.map +1 -0
  196. package/ol/layers/WMSLayer.js +84 -34
  197. package/ol/layers/index.d.ts +9 -0
  198. package/ol/layers/index.d.ts.map +1 -0
  199. package/ol/layers/index.js +8 -8
  200. package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
  201. package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
  202. package/ol/styles/fullTrajectoryDelayStyle.js +26 -24
  203. package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
  204. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
  205. package/ol/styles/fullTrajectoryStyle.js +40 -39
  206. package/ol/styles/index.d.ts +3 -0
  207. package/ol/styles/index.d.ts.map +1 -0
  208. package/ol/styles/index.js +2 -2
  209. package/package.json +81 -133
  210. package/setupTests.d.ts +2 -0
  211. package/setupTests.d.ts.map +1 -0
  212. package/setupTests.js +26 -0
  213. package/types/common.d.ts +122 -0
  214. package/types/index.d.ts +11 -0
  215. package/types/realtime.d.ts +320 -0
  216. package/types/routing.d.ts +206 -0
  217. package/types/stops.d.ts +143 -0
  218. package/README.md +0 -23
  219. package/api/RoutingAPI.test.js +0 -25
  220. package/api/StopsAPI.test.js +0 -22
  221. package/api/TralisAPI.js +0 -359
  222. package/api/TralisAPI.test.js +0 -67
  223. package/api/TralisAPIUtils.js +0 -43
  224. package/common/Tracker.js +0 -93
  225. package/common/api/HttpAPI.test.js +0 -50
  226. package/common/api/WebSocketAPI.test.js +0 -311
  227. package/common/controls/Control.js +0 -81
  228. package/common/controls/Control.test.js +0 -87
  229. package/common/layers/Layer.js +0 -213
  230. package/common/layers/Layer.test.js +0 -526
  231. package/common/mixins/CopyrightMixin.js +0 -24
  232. package/common/mixins/SearchMixin.js +0 -110
  233. package/common/mixins/TralisLayerMixin.js +0 -479
  234. package/common/styles/trackerDefaultStyle.js +0 -197
  235. package/common/styles/trackerDelayStyle.js +0 -8
  236. package/common/styles/trackerSimpleStyle.js +0 -18
  237. package/common/trackerConfig.js +0 -152
  238. package/common/trackerConfig.test.js +0 -23
  239. package/common/utils/createTrackerFilters.js +0 -56
  240. package/common/utils/createTrackerFilters.test.js +0 -79
  241. package/common/utils/getMapboxMapCopyrights.test.js +0 -40
  242. package/common/utils/getMapboxStyleUrl.js +0 -22
  243. package/common/utils/removeDuplicate.test.js +0 -19
  244. package/common/utils/timeUtils.test.js +0 -10
  245. package/mapbox/layers/Layer.test.js +0 -182
  246. package/mapbox/layers/TralisLayer.js +0 -182
  247. package/mapbox/layers/TralisLayer.test.js +0 -38
  248. package/mapbox/utils.js +0 -32
  249. package/ol/controls/CopyrightControl.test.js +0 -165
  250. package/ol/controls/RoutingControl.test.js +0 -151
  251. package/ol/controls/StopFinderControl.test.js +0 -48
  252. package/ol/layers/Layer.test.js +0 -174
  253. package/ol/layers/MapboxLayer.test.js +0 -160
  254. package/ol/layers/MapboxStyleLayer.test.js +0 -231
  255. package/ol/layers/RoutingLayer.test.js +0 -40
  256. package/ol/layers/TralisLayer.js +0 -185
  257. package/ol/layers/TralisLayer.test.js +0 -79
  258. package/ol/layers/VectorLayer.test.js +0 -87
  259. package/ol/layers/WMSLayer.test.js +0 -76
@@ -1,38 +1,88 @@
1
- import GeoJSON from "ol/format/GeoJSON";
2
- import Layer from "./Layer";
1
+ import GeoJSON from 'ol/format/GeoJSON';
2
+ import Layer from './Layer';
3
+ /**
4
+ * Class use to display a WMS layer.
5
+ *
6
+ * @classproperty {ol/Map~Map} map - The map where the layer is displayed.
7
+ * @extends {Layer}
8
+ */
3
9
  class WMSLayer extends Layer {
4
- constructor(options = {}) {
5
- super(options);
6
- this.abortController = new AbortController();
7
- this.format = new GeoJSON();
8
- }
9
- getFeatureInfoUrl(coord) {
10
- const projection = this.map.getView().getProjection();
11
- const resolution = this.map.getView().getResolution();
12
- if (this.olLayer.getSource().getFeatureInfoUrl) {
13
- return this.olLayer.getSource().getFeatureInfoUrl(coord, resolution, projection, {
14
- info_format: "application/json",
15
- query_layers: this.olLayer.getSource().getParams().layers
16
- });
10
+ /**
11
+ * @override
12
+ */
13
+ constructor(options) {
14
+ super(options);
15
+ /** @ignore */
16
+ this.abortController = new AbortController();
17
+ /** @ignore */
18
+ this.format = new GeoJSON();
19
+ }
20
+ /**
21
+ * Get features infos' Url.
22
+ * @param {ol/coordinate~Coordinate} coord
23
+ * @return {ol/layer/Layer~Layer}
24
+ */
25
+ getFeatureInfoUrl(coord) {
26
+ var _a, _b, _c, _d, _e, _f;
27
+ if (!this.map) {
28
+ return;
29
+ }
30
+ const projection = this.map.getView().getProjection();
31
+ const resolution = this.map.getView().getResolution();
32
+ if (resolution &&
33
+ projection &&
34
+ ((_b = (_a = this.olLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.getFeatureInfoUrl)) {
35
+ // eslint-disable-next-line consistent-return
36
+ return (_d = (_c = this.olLayer) === null || _c === void 0 ? void 0 : _c.getSource()) === null || _d === void 0 ? void 0 : _d.getFeatureInfoUrl(coord, resolution, projection, {
37
+ info_format: 'application/json',
38
+ query_layers: (_f = (_e = this.olLayer) === null || _e === void 0 ? void 0 : _e.getSource()) === null || _f === void 0 ? void 0 : _f.getParams().layers,
39
+ });
40
+ }
41
+ }
42
+ /**
43
+ * Request feature information for a given coordinate.
44
+ * @param {ol/coordinate~Coordinate} coordinate to request the information at.
45
+ * @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
46
+ */
47
+ getFeatureInfoAtCoordinate(coordinate) {
48
+ var _a;
49
+ (_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
50
+ this.abortController = new AbortController();
51
+ const { signal } = this.abortController;
52
+ const url = this.getFeatureInfoUrl(coordinate);
53
+ if (!url) {
54
+ // eslint-disable-next-line no-console
55
+ console.error('No url for the WMS layer.');
56
+ // resolve an empty feature array something fails
57
+ return Promise.resolve({
58
+ features: [],
59
+ coordinate,
60
+ layer: this,
61
+ });
62
+ }
63
+ return fetch(url, { signal })
64
+ .then((resp) => resp.json())
65
+ .then((r) => r.features)
66
+ .then((data) => ({
67
+ layer: this,
68
+ coordinate,
69
+ features: data.map((d) => this.format.readFeature(d)),
70
+ }))
71
+ .catch(() =>
72
+ // resolve an empty feature array something fails
73
+ Promise.resolve({
74
+ features: [],
75
+ coordinate,
76
+ layer: this,
77
+ }));
78
+ }
79
+ /**
80
+ * Create a copy of the WMSLayer.
81
+ * @param {Object} newOptions Options to override
82
+ * @return {WMSLayer} A WMSLayer
83
+ */
84
+ clone(newOptions) {
85
+ return new WMSLayer(Object.assign(Object.assign({}, this.options), newOptions));
17
86
  }
18
- return false;
19
- }
20
- getFeatureInfoAtCoordinate(coordinate) {
21
- this.abortController.abort();
22
- this.abortController = new AbortController();
23
- const { signal } = this.abortController;
24
- return fetch(this.getFeatureInfoUrl(coordinate), { signal }).then((resp) => resp.json()).then((r) => r.features).then((data) => ({
25
- layer: this,
26
- coordinate,
27
- features: data.map((d) => this.format.readFeature(d))
28
- })).catch(() => Promise.resolve({
29
- features: [],
30
- coordinate,
31
- layer: this
32
- }));
33
- }
34
- clone(newOptions) {
35
- return new WMSLayer({ ...this.options, ...newOptions });
36
- }
37
87
  }
38
88
  export default WMSLayer;
@@ -0,0 +1,9 @@
1
+ export { default as Layer } from "./Layer";
2
+ export { default as MapboxLayer } from "./MapboxLayer";
3
+ export { default as MaplibreLayer } from "./MaplibreLayer";
4
+ export { default as MapboxStyleLayer } from "./MapboxStyleLayer";
5
+ export { default as RoutingLayer } from "./RoutingLayer";
6
+ export { default as RealtimeLayer } from "./RealtimeLayer";
7
+ export { default as VectorLayer } from "./VectorLayer";
8
+ export { default as WMSLayer } from "./WMSLayer";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ol/layers/index.js"],"names":[],"mappings":""}
@@ -1,8 +1,8 @@
1
- export { default as Layer } from "./Layer";
2
- export { default as MapboxLayer } from "./MapboxLayer";
3
- export { default as MaplibreLayer } from "./MaplibreLayer";
4
- export { default as MapboxStyleLayer } from "./MapboxStyleLayer";
5
- export { default as RoutingLayer } from "./RoutingLayer";
6
- export { default as TralisLayer } from "./TralisLayer";
7
- export { default as VectorLayer } from "./VectorLayer";
8
- export { default as WMSLayer } from "./WMSLayer";
1
+ export { default as Layer } from './Layer';
2
+ export { default as MapboxLayer } from './MapboxLayer';
3
+ export { default as MaplibreLayer } from './MaplibreLayer';
4
+ export { default as MapboxStyleLayer } from './MapboxStyleLayer';
5
+ export { default as RoutingLayer } from './RoutingLayer';
6
+ export { default as RealtimeLayer } from './RealtimeLayer';
7
+ export { default as VectorLayer } from './VectorLayer';
8
+ export { default as WMSLayer } from './WMSLayer';
@@ -0,0 +1,4 @@
1
+ import { Style } from 'ol/style';
2
+ declare const fullTrajectoryDelaystyle: () => Style[];
3
+ export default fullTrajectoryDelaystyle;
4
+ //# sourceMappingURL=fullTrajectoryDelayStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fullTrajectoryDelayStyle.d.ts","sourceRoot":"","sources":["../../../src/ol/styles/fullTrajectoryDelayStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAwB,MAAM,UAAU,CAAC;AAgCvD,QAAA,MAAM,wBAAwB,QAAO,KAAK,EAEzC,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -1,31 +1,33 @@
1
- import { Style, Fill, Stroke, Circle } from "ol/style";
1
+ import { Style, Fill, Stroke, Circle } from 'ol/style';
2
+ /** @private */
2
3
  const stroke = new Style({
3
- zIndex: 2,
4
- image: new Circle({
5
- radius: 5,
6
- fill: new Fill({
7
- color: "#000000"
8
- })
9
- }),
10
- stroke: new Stroke({
11
- color: "#000000",
12
- width: 6
13
- })
4
+ zIndex: 2,
5
+ image: new Circle({
6
+ radius: 5,
7
+ fill: new Fill({
8
+ color: '#000000',
9
+ }),
10
+ }),
11
+ stroke: new Stroke({
12
+ color: '#000000',
13
+ width: 6,
14
+ }),
14
15
  });
16
+ /** @private */
15
17
  const fill = new Style({
16
- zIndex: 3,
17
- image: new Circle({
18
- radius: 4,
19
- fill: new Fill({
20
- color: "#a0a0a0"
21
- })
22
- }),
23
- stroke: new Stroke({
24
- color: "#a0a0a0",
25
- width: 4
26
- })
18
+ zIndex: 3,
19
+ image: new Circle({
20
+ radius: 4,
21
+ fill: new Fill({
22
+ color: '#a0a0a0',
23
+ }),
24
+ }),
25
+ stroke: new Stroke({
26
+ color: '#a0a0a0',
27
+ width: 4,
28
+ }),
27
29
  });
28
30
  const fullTrajectoryDelaystyle = () => {
29
- return [stroke, fill];
31
+ return [stroke, fill];
30
32
  };
31
33
  export default fullTrajectoryDelaystyle;
@@ -0,0 +1,5 @@
1
+ import type { FeatureLike } from 'ol/Feature';
2
+ import { Style } from 'ol/style';
3
+ declare const fullTrajectorystyle: (feature: FeatureLike, resolution: number, options: any) => Style[];
4
+ export default fullTrajectorystyle;
5
+ //# sourceMappingURL=fullTrajectoryStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fullTrajectoryStyle.d.ts","sourceRoot":"","sources":["../../../src/ol/styles/fullTrajectoryStyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAwB,MAAM,UAAU,CAAC;AAiBvD,QAAA,MAAM,mBAAmB,YACd,WAAW,cACR,MAAM,WACT,GAAG,KACX,KAAK,EAgCP,CAAC;AACF,eAAe,mBAAmB,CAAC"}
@@ -1,43 +1,44 @@
1
- import { Style, Fill, Stroke, Circle } from "ol/style";
2
- import { getBgColor } from "../../common/trackerConfig";
1
+ import { Style, Fill, Stroke, Circle } from 'ol/style';
2
+ /** @private */
3
3
  const borderStyle = new Style({
4
- zIndex: 2,
5
- image: new Circle({
6
- radius: 5,
7
- fill: new Fill({
8
- color: "#000000"
9
- })
10
- }),
11
- stroke: new Stroke({
12
- color: "#000000",
13
- width: 6
14
- })
15
- });
16
- const fullTrajectorystyle = (feature) => {
17
- let lineColor = "#ffffff";
18
- const type = feature.get("type");
19
- let stroke = feature.get("stroke");
20
- if (stroke && stroke[0] !== "#") {
21
- stroke = `#${stroke}`;
22
- }
23
- lineColor = stroke || getBgColor(type);
24
- lineColor = /#ffffff/i.test(lineColor) ? "#ff0000" : lineColor;
25
- const style = [
26
- borderStyle,
27
- new Style({
28
- zIndex: 3,
29
- image: new Circle({
30
- radius: 4,
4
+ zIndex: 2,
5
+ image: new Circle({
6
+ radius: 5,
31
7
  fill: new Fill({
32
- color: lineColor
33
- })
34
- }),
35
- stroke: new Stroke({
36
- color: lineColor,
37
- width: 4
38
- })
39
- })
40
- ];
41
- return style;
8
+ color: '#000000',
9
+ }),
10
+ }),
11
+ stroke: new Stroke({
12
+ color: '#000000',
13
+ width: 6,
14
+ }),
15
+ });
16
+ const fullTrajectorystyle = (feature, resolution, options) => {
17
+ let lineColor = '#ffffff'; // white
18
+ const type = feature.get('type');
19
+ let stroke = feature.get('stroke');
20
+ if (stroke && stroke[0] !== '#') {
21
+ stroke = `#${stroke}`;
22
+ }
23
+ lineColor = stroke || (options === null || options === void 0 ? void 0 : options.getBgColor(type));
24
+ // Don't allow white lines, use red instead.
25
+ lineColor = /#ffffff/i.test(lineColor) ? '#ff0000' : lineColor;
26
+ const style = [
27
+ borderStyle,
28
+ new Style({
29
+ zIndex: 3,
30
+ image: new Circle({
31
+ radius: 4,
32
+ fill: new Fill({
33
+ color: lineColor,
34
+ }),
35
+ }),
36
+ stroke: new Stroke({
37
+ color: lineColor,
38
+ width: 4,
39
+ }),
40
+ }),
41
+ ];
42
+ return style;
42
43
  };
43
44
  export default fullTrajectorystyle;
@@ -0,0 +1,3 @@
1
+ export { default as fullTrajectoryStyle } from "./fullTrajectoryStyle";
2
+ export { default as fullTrajectoryDelayStyle } from "./fullTrajectoryDelayStyle";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ol/styles/index.js"],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- export { default as fullTrajectoryStyle } from "./fullTrajectoryStyle";
2
- export { default as fullTrajectoryDelayStyle } from "./fullTrajectoryDelayStyle";
1
+ export { default as fullTrajectoryStyle } from './fullTrajectoryStyle';
2
+ export { default as fullTrajectoryDelayStyle } from './fullTrajectoryDelayStyle';
package/package.json CHANGED
@@ -2,189 +2,137 @@
2
2
  "name": "mobility-toolbox-js",
3
3
  "license": "MIT",
4
4
  "description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
5
- "version": "2.0.1-beta.13",
6
- "main": "index.js",
5
+ "version": "2.1.0",
6
+ "homepage": "https://mobility-toolbox-js.geops.io/",
7
+ "module": "index.js",
7
8
  "exports": {
8
9
  ".": "./index.js",
9
10
  "./api": "./api/index.js",
10
11
  "./mapbox": "./mapbox/index.js",
11
- "./ol": "./ol/index.js"
12
+ "./ol": "./ol/index.js",
13
+ "./types": "./types/index.d.ts"
12
14
  },
13
15
  "dependencies": {
14
- "@turf/helpers": "^6.5.0",
15
- "@turf/transform-rotate": "^6.5.0",
16
+ "@turf/helpers": "6.5.0",
17
+ "@turf/transform-rotate": "6.5.0",
16
18
  "lodash.debounce": "4.0.8",
17
19
  "lodash.throttle": "4.1.1",
18
- "path": "^0.12.7",
19
- "query-string": "7.1.0",
20
- "turf": "^3.0.14",
21
- "uuid": "8.3.2"
20
+ "uuid": "9.0.0"
22
21
  },
23
22
  "peerDependencies": {
24
- "mapbox-gl": "^1",
25
- "maplibre-gl": "^1",
26
- "ol": "^6"
23
+ "mapbox-gl": "1.13.2",
24
+ "maplibre-gl": "2.4.0",
25
+ "ol": "7.3.0"
27
26
  },
28
27
  "devDependencies": {
29
- "@babel/core": "7.16.12",
30
- "@babel/eslint-parser": "7.16.5",
31
- "@babel/plugin-transform-runtime": "7.16.10",
32
- "@babel/preset-env": "^7.16.11",
33
- "@babel/preset-react": "7.16.7",
34
- "@commitlint/cli": "17.0.2",
35
- "@commitlint/config-conventional": "17.0.2",
36
- "autoprefixer": "9.7.6",
37
- "cypress": "9.4.1",
38
- "deepmerge": "4.2.2",
39
- "esbuild": "^0.14.47",
40
- "esbuild-jest": "^0.5.0",
28
+ "@commitlint/cli": "17.6.1",
29
+ "@commitlint/config-conventional": "17.6.1",
30
+ "@types/geojson": "7946.0.10",
31
+ "@types/lodash.debounce": "4.0.7",
32
+ "@types/lodash.throttle": "4.1.7",
33
+ "@types/mapbox-gl": "2.7.10",
34
+ "@types/offscreencanvas": "2019.7.0",
35
+ "@types/topojson": "3.2.3",
36
+ "@types/uuid": "9.0.1",
37
+ "@typescript-eslint/eslint-plugin": "5.59.0",
38
+ "@typescript-eslint/parser": "5.59.0",
39
+ "cypress": "12.10.0",
40
+ "esbuild": "0.17.17",
41
+ "esbuild-jest": "0.5.0",
41
42
  "esdoc": "1.1.0",
42
43
  "esdoc-ecmascript-proposal-plugin": "1.0.0",
43
44
  "esdoc-publish-html-plugin": "1.1.2",
44
45
  "esdoc-standard-plugin": "1.0.0",
45
- "eslint": "8.8.0",
46
+ "esdoc-typescript-plugin": "1.0.1",
47
+ "eslint": "8.38.0",
46
48
  "eslint-config-airbnb": "19.0.4",
47
- "eslint-config-prettier": "8.3.0",
48
- "eslint-plugin-cypress": "2.12.1",
49
- "eslint-plugin-import": "2.25.4",
50
- "eslint-plugin-jsx-a11y": "^6.6.0",
51
- "eslint-plugin-prettier": "4.0.0",
52
- "eslint-plugin-react": "^7.30.1",
53
- "fixpack": "3.0.6",
54
- "husky": "8.0.1",
55
- "jest": "26.6.3",
56
- "jest-canvas-mock": "2.3.1",
49
+ "eslint-config-airbnb-typescript": "17.0.0",
50
+ "eslint-config-prettier": "8.8.0",
51
+ "eslint-plugin-cypress": "2.13.2",
52
+ "eslint-plugin-import": "2.27.5",
53
+ "eslint-plugin-jsx-a11y": "6.7.1",
54
+ "eslint-plugin-prettier": "4.2.1",
55
+ "eslint-plugin-react": "7.32.2",
56
+ "fixpack": "4.0.0",
57
+ "husky": "8.0.3",
58
+ "is-ci": "3.0.1",
59
+ "jest": "29.5.0",
60
+ "jest-canvas-mock": "2.5.0",
61
+ "jest-environment-jsdom": "29.5.0",
57
62
  "jest-fetch-mock": "3.0.3",
58
63
  "jest-serializer-html": "7.1.0",
59
- "jest-transformer-svg": "^2.0.0",
60
- "jest-websocket-mock": "2.3.0",
61
- "lint-staged": "12.3.3",
64
+ "jest-transformer-svg": "2.0.1",
65
+ "jest-websocket-mock": "2.4.0",
66
+ "lint-staged": "13.2.1",
62
67
  "mapbox-gl": "1.13.2",
63
- "maplibre-gl": "2.1.9",
64
- "mock-socket": "9.1.2",
65
- "ol": "6.12.0",
66
- "postcss": "8.3.3",
67
- "postcss-loader": "3.0.0",
68
- "prettier": "2.5.1",
69
- "sass": "1.52.2",
70
- "sass-loader": "8.0.2",
71
- "sort-json": "2.0.0",
68
+ "maplibre-gl": "2.4.0",
69
+ "mock-socket": "9.2.1",
70
+ "next": "12.1.6",
71
+ "next-transpile-modules": "10.0.0",
72
+ "ol": "7.3.0",
73
+ "openapi-typescript": "6.2.1",
74
+ "prettier": "2.8.7",
75
+ "raw-loader": "4.0.2",
76
+ "sort-json": "2.0.1",
72
77
  "standard-version": "9.5.0",
73
- "start-server-and-test": "1.14.0",
74
- "stylelint": "14.3.0",
75
- "stylelint-config-recommended-scss": "5.0.2",
76
- "stylelint-config-standard": "24.0.0",
77
- "stylelint-scss": "4.1.0"
78
+ "start-server-and-test": "2.0.0",
79
+ "stylelint": "15.5.0",
80
+ "stylelint-config-recommended-scss": "10.0.0",
81
+ "stylelint-config-standard": "33.0.0",
82
+ "stylelint-scss": "4.6.0",
83
+ "typescript": "5.0.4"
78
84
  },
79
85
  "scripts": {
80
86
  "apidoc": "esdoc && cp apidoc/index.json doc/src/components/Esdoc",
81
- "build": "yarn esbuild",
87
+ "build": "yarn build:tsc && yarn esbuild:iife",
88
+ "build:tsc": "rm -rf build && yarn tsc && cp package.json build/ && cp -R src/types build/ && find build -type f -name '*.test.*' -delete",
82
89
  "coverage": "yarn test --watchAll=false --coverage --coverageDirectory=coverage",
83
90
  "cy:open": "cypress open",
84
91
  "cy:test": "start-server-and-test dev http://localhost:3000 'cypress run --browser chrome'",
85
92
  "cy:test:chrome": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser chrome'",
86
93
  "cy:test:edge": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser edge'",
87
94
  "cy:test:firefox": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser firefox'",
88
- "dev": "yarn doc && yarn dev:examples",
89
- "dev:examples": "cd doc && yarn dev",
90
- "doc": "yarn apidoc && cd doc && yarn install --frozen-lockfile && yarn build",
91
- "esbuild": "rm -rf build && yarn esbuild:all && yarn esbuild:iife && cp README.md build/ && cp package.json build/",
92
- "esbuild:all": "esbuild src/index.js src/**/*.js src/**/**/*.js --target=chrome100 --outdir=build/ --loader:.js=jsx",
95
+ "dev": "rm -rf .next && rm -rf doc/.next && yarn doc && yarn dev:examples",
96
+ "dev:examples": "rm -rf .next && rm -rf doc/.next && yarn build && cd build && yarn link && cd ../doc && yarn link mobility-toolbox-js && yarn dev",
97
+ "doc": "yarn build && yarn apidoc && cd doc && rm -rf .next && rm -rf node_modules/mobility-toolbox-js && yarn install --force && yarn build",
98
+ "esbuild": "yarn esbuild:all && yarn esbuild:iife",
99
+ "esbuild:all": "esbuild src/index.js src/**/*.js src/**/*.ts src/**/**/*.js src/**/**/*.ts --target=chrome100 --outdir=build/ --loader:.js=jsx",
93
100
  "esbuild:iife": "yarn esbuild:iife:unminify && yarn esbuild:iife:minify",
94
101
  "esbuild:iife:base": "esbuild src/iife.js --bundle --sourcemap --target=chrome100",
95
102
  "esbuild:iife:minify": "yarn esbuild:iife:base --minify --outfile=build/mbt.min.js",
96
103
  "esbuild:iife:unminify": "yarn esbuild:iife:base --outfile=build/mbt.js",
97
- "format": "prettier --write 'src/**/*.js' && eslint 'src/**/*.js' --fix && stylelint 'src/**/*.css' 'src/**/*.scss' --fix",
104
+ "format": "prettier --write 'src/**/*.js' && eslint 'src/**/*.js' --fix && stylelint 'src/**/*.css' 'src/**/*.scss' --fix --allow-empty-input",
98
105
  "lib": "REACT_APP_LIB_MODE=1 webpack --mode production",
99
106
  "lib:dev": "REACT_APP_LIB_MODE=1 webpack --mode development",
100
107
  "link2": "cmdToAdd=$(node ./scripts/read-pkg-json.js add) && $cmdToAdd && yarn build && cmdToRemove=$(node ./scripts/read-pkg-json.js remove) && $cmdToRemove && cd build && yarn link",
101
- "lint": "eslint 'src/**/*.js' && stylelint 'src/**/*.css' 'src/**/*.scss' --allow-empty-input",
108
+ "lint": "eslint src/**/*.js src/**/*.ts && stylelint src/**/*.css src/**/*.scss --allow-empty-input",
109
+ "prepare": "is-ci || husky install",
102
110
  "publish:beta": "HUSKY=0 yarn release -- --prerelease beta --skip.changelog && git push origin HEAD && yarn run build && cd build && HUSKY=0 yarn publish --tag beta && git push --tags ",
103
111
  "publish:beta:dryrun": "yarn release -- --prerelease beta --dry-run --skip.changelog",
112
+ "publish:public": "yarn release --skip.changelog && git push origin HEAD && yarn run build && cd build && HUSKY=0 yarn publish && git push --tags ",
104
113
  "publish:public:dryrun": "yarn release --dry-run",
105
114
  "release": "standard-version",
106
115
  "start": "yarn doc && cd doc && yarn start",
107
116
  "start:examples": "cd doc && yarn build && yarn start",
108
- "test": "TZ='UTC' jest",
109
- "test:watch": "yarn test --watchAll"
110
- },
111
- "browserslist": {
112
- "production": [
113
- ">0.2%",
114
- "not dead",
115
- "not op_mini all"
116
- ],
117
- "development": [
118
- "last 1 chrome version",
119
- "last 1 firefox version",
120
- "last 1 safari version",
121
- "last 1 ie version"
122
- ]
123
- },
124
- "eslintConfig": {
125
- "env": {
126
- "cypress/globals": true,
127
- "node": true,
128
- "browser": true,
129
- "es6": true,
130
- "jest": true
131
- },
132
- "parser": "@babel/eslint-parser",
133
- "extends": [
134
- "airbnb",
135
- "prettier"
136
- ],
137
- "plugins": [
138
- "cypress",
139
- "prettier"
140
- ],
141
- "rules": {
142
- "arrow-body-style": 0,
143
- "react/jsx-filename-extension": [
144
- 1,
145
- {
146
- "extensions": [
147
- ".js",
148
- ".jsx"
149
- ]
150
- }
151
- ],
152
- "prettier/prettier": "error"
153
- }
117
+ "test": "TZ='UTC' jest ",
118
+ "test:watch": "yarn test --watchAll",
119
+ "tsc": "tsc",
120
+ "types:backend": "openapi-typescript https://developer.geops.io/swagger/routing.json --output src/types/routing.d.ts && openapi-typescript https://developer.geops.io/swagger/stops.json --output src/types/stops.d.ts"
154
121
  },
122
+ "browserslist": [
123
+ ">0.2%",
124
+ "not dead",
125
+ "not op_mini all",
126
+ "not ie <= 11",
127
+ "not android < 5"
128
+ ],
155
129
  "keywords": [
156
130
  "mobility",
157
131
  "toolbox"
158
132
  ],
159
- "lint-staged": {
160
- "(src|__mocks__)/**/*.js": [
161
- "eslint --fix",
162
- "prettier --write",
163
- "git add",
164
- "yarn test --bail --findRelatedTests"
165
- ],
166
- "package.json": [
167
- "fixpack --sortToTop name --sortToTop license --sortToTop description --sortToTop version --sortToTop author --sortToTop main --sortToTop module --sortToTop files --sortToTop exports --sortToTop proxy --sortToTop dependencies --sortToTop peerDependencies --sortToTop devDependencies --sortToTop resolutions --sortToTop scripts"
168
- ],
169
- "src/**/*.{css,scss}": [
170
- "stylelint --fix --allow-empty-input"
171
- ]
172
- },
173
- "prettier": {
174
- "trailingComma": "all",
175
- "singleQuote": true
176
- },
177
133
  "repository": {
178
134
  "type": "git",
179
135
  "url": "https://github.com/geops/mobility-toolbox-js"
180
136
  },
181
- "stylelint": {
182
- "plugins": [
183
- "stylelint-scss"
184
- ],
185
- "extends": [
186
- "stylelint-config-standard",
187
- "stylelint-config-recommended-scss"
188
- ]
189
- }
137
+ "sideEffects": false
190
138
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=setupTests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupTests.d.ts","sourceRoot":"","sources":["../src/setupTests.js"],"names":[],"mappings":""}
package/setupTests.js ADDED
@@ -0,0 +1,26 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import 'jest-canvas-mock';
3
+ import fetchTrajectoryByIdResponse from '../data/fetchTrajectoryById.json';
4
+ import fetchTrajectoriesResponse from '../data/fetchTrajectories.json';
5
+ import fetchTrajectoryStationsResponse from '../data/fetchTrajectoryStations.json';
6
+ import stopsSearchResponse from '../data/stopsSearch.json';
7
+ import fetchRouteResponse from '../data/fetchRoute.json';
8
+ global.fetchTrajectoryByIdResponse = fetchTrajectoryByIdResponse;
9
+ global.fetchTrajectoriesResponse = fetchTrajectoriesResponse;
10
+ global.fetchTrajectoryStationsResponse = fetchTrajectoryStationsResponse;
11
+ global.stopsSearchResponse = stopsSearchResponse;
12
+ global.fetchRouteResponse = fetchRouteResponse;
13
+ global.URL.createObjectURL = jest.fn(() => 'fooblob');
14
+ window.OffscreenCanvas = () => {
15
+ return document.createElement('canvas');
16
+ };
17
+ /* eslint-disable */
18
+ class ResizeObserver {
19
+ constructor(onResize) {
20
+ ResizeObserver.onResize = onResize;
21
+ }
22
+ observe() { }
23
+ unobserve() { }
24
+ disconnect() { }
25
+ }
26
+ window.ResizeObserver = ResizeObserver;