mobility-toolbox-js 2.0.0-beta.52 → 2.0.0-beta.54

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 (93) hide show
  1. package/README.md +26 -3
  2. package/api/RealtimeAPI.d.ts +79 -84
  3. package/api/RealtimeAPI.d.ts.map +1 -1
  4. package/api/RealtimeAPI.js +102 -266
  5. package/common/api/WebSocketAPI.d.ts +13 -15
  6. package/common/api/WebSocketAPI.d.ts.map +1 -1
  7. package/common/controls/ControlCommon.d.ts +1 -1
  8. package/common/controls/ControlCommon.d.ts.map +1 -1
  9. package/common/layers/LayerCommon.d.ts +1 -0
  10. package/common/layers/LayerCommon.d.ts.map +1 -1
  11. package/common/layers/LayerCommon.js +3 -0
  12. package/common/mixins/RealtimeLayerMixin.d.ts +5 -5
  13. package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
  14. package/common/mixins/RealtimeLayerMixin.js +6 -6
  15. package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -1
  16. package/common/mixins/UserInteractionsLayerMixin.js +7 -10
  17. package/common/styles/realtimeDefaultStyle.d.ts +2 -2
  18. package/common/styles/realtimeDefaultStyle.d.ts.map +1 -1
  19. package/common/styles/realtimeDelayStyle.d.ts +2 -2
  20. package/common/styles/realtimeDelayStyle.d.ts.map +1 -1
  21. package/common/styles/realtimeSimpleStyle.d.ts +2 -1
  22. package/common/styles/realtimeSimpleStyle.d.ts.map +1 -1
  23. package/common/typedefs.js +3 -3
  24. package/common/utils/{createTrackerFilters.d.ts → createRealtimeFilters.d.ts} +3 -3
  25. package/common/utils/createRealtimeFilters.d.ts.map +1 -0
  26. package/common/utils/{createTrackerFilters.js → createRealtimeFilters.js} +2 -2
  27. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  28. package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
  29. package/common/utils/debounceDeparturesMessages.js +24 -0
  30. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  31. package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
  32. package/common/utils/debounceWebsocketMessages.js +29 -0
  33. package/common/utils/getMapboxRender.d.ts +3 -3
  34. package/common/utils/getMapboxRender.d.ts.map +1 -1
  35. package/common/utils/getMapboxRender.js +2 -1
  36. package/common/utils/getMaplibreRender.d.ts +3 -1
  37. package/common/utils/getMaplibreRender.d.ts.map +1 -1
  38. package/common/utils/getMaplibreRender.js +4 -4
  39. package/common/utils/getRealtimeModeSuffix.d.ts +4 -2
  40. package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -1
  41. package/common/utils/getUrlWithParams.d.ts +2 -2
  42. package/common/utils/getUrlWithParams.d.ts.map +1 -1
  43. package/common/utils/getVehiclePosition.d.ts +7 -5
  44. package/common/utils/getVehiclePosition.d.ts.map +1 -1
  45. package/common/utils/index.d.ts +5 -2
  46. package/common/utils/index.js +6 -3
  47. package/common/utils/realtimeConfig.d.ts +49 -0
  48. package/common/utils/realtimeConfig.d.ts.map +1 -0
  49. package/common/utils/{trackerConfig.js → realtimeConfig.js} +17 -17
  50. package/common/utils/sortAndFilterDepartures.d.ts +16 -0
  51. package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
  52. package/common/utils/sortAndFilterDepartures.js +58 -0
  53. package/common/utils/sortByDelay.d.ts +1 -1
  54. package/common/utils/sortByDelay.d.ts.map +1 -1
  55. package/common/utils/timeUtils.d.ts +23 -4
  56. package/common/utils/timeUtils.d.ts.map +1 -1
  57. package/common/utils/timeUtils.js +1 -1
  58. package/mapbox/layers/RealtimeLayer.d.ts +4 -4
  59. package/mbt.js +349 -410
  60. package/mbt.js.map +3 -3
  61. package/mbt.min.js +62 -62
  62. package/mbt.min.js.map +3 -3
  63. package/ol/controls/RoutingControl.d.ts +95 -91
  64. package/ol/controls/RoutingControl.d.ts.map +1 -1
  65. package/ol/controls/RoutingControl.js +100 -90
  66. package/ol/layers/Layer.d.ts +3 -2
  67. package/ol/layers/Layer.d.ts.map +1 -1
  68. package/ol/layers/Layer.js +2 -0
  69. package/ol/layers/MapGlLayer.d.ts.map +1 -1
  70. package/ol/layers/MapGlLayer.js +3 -5
  71. package/ol/layers/MapboxLayer.d.ts +1 -1
  72. package/ol/layers/MapboxLayer.d.ts.map +1 -1
  73. package/ol/layers/MapboxLayer.js +1 -0
  74. package/ol/layers/MapboxStyleLayer.js +4 -2
  75. package/ol/layers/MaplibreLayer.d.ts +2 -1
  76. package/ol/layers/MaplibreLayer.d.ts.map +1 -1
  77. package/ol/layers/RealtimeLayer.d.ts +8 -6
  78. package/ol/layers/RealtimeLayer.d.ts.map +1 -1
  79. package/ol/layers/RealtimeLayer.js +3 -3
  80. package/ol/layers/RoutingLayer.d.ts +15 -5
  81. package/ol/layers/RoutingLayer.d.ts.map +1 -1
  82. package/ol/layers/RoutingLayer.js +3 -2
  83. package/ol/styles/fullTrajectoryStyle.d.ts +2 -2
  84. package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -1
  85. package/package.json +1 -1
  86. package/types/common.d.ts +6 -1
  87. package/types/realtime.d.ts +0 -2
  88. package/common/utils/cleanStopTime.d.ts +0 -8
  89. package/common/utils/cleanStopTime.d.ts.map +0 -1
  90. package/common/utils/cleanStopTime.js +0 -25
  91. package/common/utils/createTrackerFilters.d.ts.map +0 -1
  92. package/common/utils/trackerConfig.d.ts +0 -24
  93. package/common/utils/trackerConfig.d.ts.map +0 -1
@@ -1,7 +1,6 @@
1
1
  import WebSocketAPI from '../common/api/WebSocketAPI';
2
- import cleanStopTime from '../common/utils/cleanStopTime';
2
+ import debounceWebsocketMessages from '../common/utils/debounceWebsocketMessages';
3
3
  import getModeSuffix from '../common/utils/getRealtimeModeSuffix';
4
- import compareDepartures from '../common/utils/compareDepartures';
5
4
  /**
6
5
  * Enum for Realtime modes.
7
6
  * @readonly
@@ -46,14 +45,6 @@ class RealtimeAPI {
46
45
  constructor(options = {}) {
47
46
  this.defineProperties(options);
48
47
  /** @ignore */
49
- this.subscribedStationUic = undefined;
50
- /** @ignore */
51
- this.departureUpdateTimeout = undefined;
52
- /** @ignore */
53
- this.maxDepartureAge = 30;
54
- /** @ignore */
55
- this.extraGeoms = {};
56
- /** @ignore */
57
48
  this.prefix = options.prefix || '';
58
49
  /** @ignore */
59
50
  this.onOpen = this.onOpen.bind(this);
@@ -67,8 +58,11 @@ class RealtimeAPI {
67
58
  const { apiKey } = opt;
68
59
  let { url, projection, bbox, buffer = [100, 100] } = opt;
69
60
  const wsApi = new WebSocketAPI();
61
+ if (!url) {
62
+ url = 'wss://api.geops.io/tracker-ws/v1/';
63
+ }
70
64
  if (apiKey) {
71
- url = `${url || 'wss://api.geops.io/tracker-ws/v1/'}?key=${apiKey}`;
65
+ url = `${url}?key=${apiKey}`;
72
66
  }
73
67
  Object.defineProperties(this, {
74
68
  url: {
@@ -210,7 +204,7 @@ class RealtimeAPI {
210
204
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
211
205
  * @private
212
206
  */
213
- subscribe(channel, onSuccess, onError, quiet = false) {
207
+ subscribe(channel, onSuccess, onError = () => { }, quiet = false) {
214
208
  if (!channel || !onSuccess) {
215
209
  return;
216
210
  }
@@ -221,65 +215,14 @@ class RealtimeAPI {
221
215
  *
222
216
  * @param {string} channel Name of the websocket channel to unsubscribe.
223
217
  * @param {string} suffix Suffix to add to the channel name.
224
- * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
225
- * @private
226
- */
227
- unsubscribe(channel, suffix = '', cb) {
228
- this.wsApi.unsubscribe(`${channel}${getModeSuffix(RealtimeModes.SCHEMATIC, RealtimeModes)}${suffix}`, cb);
229
- this.wsApi.unsubscribe(`${channel}${getModeSuffix(RealtimeModes.TOPOGRAPHIC, RealtimeModes)}${suffix || ''}`, cb);
230
- }
231
- /**
232
- * Filter departures and return an array.
233
- *
234
- * @param {Object} depObject The object containing departures by id.
235
- * @param {boolean} [sortByMinArrivalTime=false] If true sort departures by arrival time.
236
- * @return {Array<Departure>} Return departures array.
218
+ * @param {function} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
237
219
  * @private
238
220
  */
239
- filterDepartures(depObject, sortByMinArrivalTime = false) {
240
- const departures = Object.keys(depObject).map((k) => depObject[k]);
241
- departures.sort((a, b) => compareDepartures(a, b, sortByMinArrivalTime));
242
- const futureDate = new Date();
243
- futureDate.setMinutes(futureDate.getMinutes() + this.maxDepartureAge);
244
- const future = futureDate.getTime();
245
- const pastDate = new Date();
246
- pastDate.setMinutes(pastDate.getMinutes() - this.maxDepartureAge);
247
- const past = pastDate.getTime();
248
- const departureArray = [];
249
- const platformsBoarding = [];
250
- let previousDeparture = null;
251
- for (let i = departures.length - 1; i >= 0; i -= 1) {
252
- const departure = Object.assign({}, departures[i]);
253
- const time = new Date(departure.time).getTime();
254
- // Only show departures within the next 30 minutes
255
- if (time > past && time < future) {
256
- // If 2 trains are boarding at the same platform,
257
- // remove the older one.
258
- if (departure.state === 'BOARDING') {
259
- if (platformsBoarding.indexOf(departure.platform) === -1) {
260
- platformsBoarding.push(departure.platform);
261
- }
262
- else {
263
- departure.state = 'HIDDEN';
264
- }
265
- }
266
- // If two trains with the same line number and destinatin
267
- // and a departure difference < 1 minute, hide the second one.
268
- if (previousDeparture &&
269
- departure.to[0] === previousDeparture.to[0] &&
270
- Math.abs(time - previousDeparture.time) < 1000 &&
271
- departure.line.name === previousDeparture.line.name) {
272
- departure.state = 'HIDDEN';
273
- }
274
- if (/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(departure.state)) {
275
- departure.cancelled = true;
276
- }
277
- previousDeparture = departure;
278
- previousDeparture.time = time;
279
- departureArray.unshift(departure);
280
- }
281
- }
282
- return departureArray;
221
+ unsubscribe(channel, suffix = '', onMessage) {
222
+ const suffixSchenatic = getModeSuffix(RealtimeModes.SCHEMATIC, RealtimeModes);
223
+ const suffixTopographic = getModeSuffix(RealtimeModes.TOPOGRAPHIC, RealtimeModes);
224
+ this.wsApi.unsubscribe(`${channel}${suffixSchenatic}${suffix || ''}`, onMessage);
225
+ this.wsApi.unsubscribe(`${channel}${suffixTopographic}${suffix || ''}`, onMessage);
283
226
  }
284
227
  /**
285
228
  * Subscribe to departures channel of a given station.
@@ -287,67 +230,44 @@ class RealtimeAPI {
287
230
  * @param {number} stationId UIC of the station.
288
231
  * @param {Boolean} sortByMinArrivalTime Sort by minimum arrival time
289
232
  * @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
233
+ * @param {function} onError Callback when the subscription fails.
234
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
290
235
  */
291
- subscribeDepartures(stationId, sortByMinArrivalTime, onMessage) {
292
- window.clearTimeout(this.departureUpdateTimeout);
293
- this.unsubscribeDepartures();
294
- this.subscribedStationUic = stationId;
295
- const channel = stationId ? `timetable_${stationId}` : null;
296
- const departureObject = {};
297
- if (!channel) {
298
- return;
299
- }
300
- const onSuccess = (data) => {
301
- if (data.source === channel) {
302
- const content = data.content || {};
303
- // TODO: These lines seems useless because content.timestamp never exists
304
- // we should check if actually the case
305
- const tDiff = new Date(content.timestamp).getTime() - Date.now();
306
- departureObject[content.call_id] = Object.assign(Object.assign({}, content), { timediff: tDiff });
307
- window.clearTimeout(this.departureUpdateTimeout);
308
- this.departureUpdateTimeout = window.setTimeout(() => {
309
- const departures = this.filterDepartures(departureObject, sortByMinArrivalTime || false);
310
- onMessage(departures);
311
- }, 100);
312
- }
313
- };
314
- this.subscribe(channel, onSuccess, () => {
315
- onMessage([]);
316
- });
236
+ subscribeDepartures(stationId, onMessage, onError = () => { }, quiet = false) {
237
+ this.subscribe(`timetable_${stationId}`, onMessage, onError, quiet);
317
238
  }
318
239
  /**
319
240
  * Unsubscribe from current departures channel.
320
- * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
241
+ * @param {RealtimeStationId} id Station's id
242
+ * @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
321
243
  */
322
- unsubscribeDepartures(cb) {
323
- if (this.subscribedStationUic) {
324
- this.unsubscribe(`timetable_${this.subscribedStationUic}`, '', cb);
325
- this.subscribedStationUic = undefined;
326
- }
244
+ unsubscribeDepartures(id, onMessage) {
245
+ this.unsubscribe(`timetable_${id}`, '', onMessage);
327
246
  }
328
247
  /**
329
248
  * Subscribe to the disruptions channel for tenant.
330
249
  *
331
- * @param {function(news: RealtimeNews)} onMessage Function called on each message of the channel.
250
+ * @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
251
+ * @param {function} onError Callback when the subscription fails.
252
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
332
253
  */
333
- subscribeDisruptions(onMessage) {
334
- this.subscribe(`${this.prefix}newsticker`, (data) => {
335
- onMessage(data.content);
336
- });
254
+ subscribeDisruptions(onMessage, onError = () => { }, quiet = false) {
255
+ this.subscribe(`${this.prefix}newsticker`, onMessage, onError, quiet);
337
256
  }
338
257
  /**
339
258
  * Unsubscribe disruptions.
340
- * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
259
+ *
260
+ * @param {function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
341
261
  */
342
- unsubscribeDisruptions(cb) {
343
- this.unsubscribe(`${this.prefix}newsticker`, '', cb);
262
+ unsubscribeDisruptions(onMessage) {
263
+ this.unsubscribe(`${this.prefix}newsticker`, '', onMessage);
344
264
  }
345
265
  /**
346
266
  * Return a station with a given uic number and a mode.
347
267
  *
348
268
  * @param {number} uic UIC of the station.
349
269
  * @param {RealtimeMode} mode Realtime mode.
350
- * @return {Promise<Station>} A station.
270
+ * @return {Promise<{data: { content: RealtimeStation }}>} A station.
351
271
  */
352
272
  getStation(uic, mode) {
353
273
  const params = {
@@ -355,42 +275,20 @@ class RealtimeAPI {
355
275
  args: uic,
356
276
  };
357
277
  return new Promise((resolve, reject) => {
358
- this.wsApi.get(params, (data) => {
359
- if (data.content) {
360
- resolve(data.content);
361
- }
362
- else {
363
- reject();
364
- }
365
- });
278
+ this.wsApi.get(params, resolve, reject);
366
279
  });
367
280
  }
368
281
  /**
369
- * Update the model's station list for a given mode and a bbox.
370
- *
282
+ * Get the list of ststions available for a specifc mode. The promise is resolved every 100ms
371
283
  * @param {RealtimeMode} mode Realtime mode.
372
- * @return {Promise<Array<Station>>} An array of stations.
284
+ * @param {number} timeout = 100 Duration in ms between each promise resolve calls.
285
+ * @return {Promise<RealtimeStation[]>} An array of stations.
373
286
  */
374
- getStations(mode) {
375
- const stations = [];
376
- const params = {
377
- channel: `station${getModeSuffix(mode, RealtimeModes)}`,
378
- };
379
- window.clearTimeout(this.stationUpdateTimeout);
380
- return new Promise((resolve, reject) => {
381
- this.wsApi.get(params, (data) => {
382
- if (data.content) {
383
- stations.push(data.content);
384
- window.clearTimeout(this.stationUpdateTimeout);
385
- /** @ignore */
386
- this.stationUpdateTimeout = window.setTimeout(() => {
387
- resolve(stations);
388
- }, 50);
389
- }
390
- else {
391
- reject(data.content);
392
- }
393
- });
287
+ getStations(mode, timeout = 100) {
288
+ return new Promise((resolve) => {
289
+ this.wsApi.get({
290
+ channel: `station${getModeSuffix(mode, RealtimeModes)}`,
291
+ }, debounceWebsocketMessages(resolve, undefined, timeout));
394
292
  });
395
293
  }
396
294
  /**
@@ -398,86 +296,74 @@ class RealtimeAPI {
398
296
  * One message pro station.
399
297
  *
400
298
  * @param {RealtimeMode} mode Realtime mode.
401
- * @param {function(station: Station)} onMessage Function called on each message of the channel.
299
+ * @param {function(data: { content: RealtimeStation })} onMessage Function called on each message of the channel.
300
+ * @param {function} onError Callback when the subscription fails.
301
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
402
302
  */
403
- subscribeStations(mode, onMessage) {
404
- this.unsubscribeStations();
405
- this.subscribe(`station${getModeSuffix(mode, RealtimeModes)}`, (data) => {
406
- if (data.content) {
407
- onMessage(data.content);
408
- }
409
- });
303
+ subscribeStations(mode, onMessage, onError = () => { }, quiet = false) {
304
+ this.subscribe(`station${getModeSuffix(mode, RealtimeModes)}`, onMessage, onError, quiet);
410
305
  }
411
306
  /**
412
307
  * Unsubscribe to stations channel.
413
- * @param {function} cb The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
308
+ * @param {function(data: { content: RealtimeStation })} onMessage The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
414
309
  */
415
- unsubscribeStations(cb) {
416
- window.clearTimeout(this.stationUpdateTimeout);
417
- this.unsubscribe('station', '', cb);
310
+ unsubscribeStations(onMessage) {
311
+ this.unsubscribe('station', '', onMessage);
418
312
  }
419
313
  /**
420
314
  * Subscribe to extra_geoms channel.
421
315
  *
422
- * @param {function(extraGeoms: GeosJSONFeature[])} onMessage Function called on each message of the channel.
316
+ * @param {function(data: { content: RealtimeExtraGeom })} onMessage Function called on each message of the channel.
317
+ * @param {function} onError Callback when the subscription fails.
318
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
423
319
  */
424
- subscribeExtraGeoms(onMessage) {
425
- this.subscribe('extra_geoms', (data) => {
426
- const extraGeom = data.content;
427
- if (extraGeom) {
428
- const { ref } = extraGeom.properties;
429
- if (extraGeom.type === 'Feature') {
430
- this.extraGeoms[ref] = extraGeom;
431
- }
432
- else {
433
- delete this.extraGeoms[ref];
434
- }
435
- onMessage(Object.keys(this.extraGeoms).map((key) => this.extraGeoms[key]));
436
- }
437
- });
320
+ subscribeExtraGeoms(onMessage, onError = () => { }, quiet = false) {
321
+ this.subscribe('extra_geoms', onMessage, onError, quiet);
438
322
  }
439
323
  /**
440
324
  * Unsubscribe to extra_geoms channel.
441
- * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
325
+ * @param {function(data: { content: RealtimeExtraGeom })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
442
326
  */
443
- unsubscribeExtraGeoms(cb) {
444
- this.unsubscribe('extra_geoms', '', cb);
327
+ unsubscribeExtraGeoms(onMessage) {
328
+ this.unsubscribe('extra_geoms', '', onMessage);
445
329
  }
446
330
  /**
447
331
  * Subscribe to trajectory channel.
448
332
  *
449
333
  * @param {RealtimeMode} mode Realtime mode.
450
- * @param {function(trajectory: RealtimeTrajectory)} onMessage Function called on each message of the channel.
451
- * @param {boolean} quiet If true, the subscription will not send GET and SUB requests to the websocket.
334
+ * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Function called on each message of the channel.
335
+ * @param {function} onError Callback when the subscription fails.
336
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
452
337
  */
453
- subscribeTrajectory(mode, onMessage, quiet = false) {
338
+ subscribeTrajectory(mode, onMessage, onError = () => { }, quiet = false) {
454
339
  this.unsubscribeTrajectory(onMessage);
455
- this.subscribe(`trajectory${getModeSuffix(mode, RealtimeModes)}`, onMessage, undefined, quiet);
340
+ this.subscribe(`trajectory${getModeSuffix(mode, RealtimeModes)}`, onMessage, onError, quiet);
456
341
  }
457
342
  /**
458
343
  * Unsubscribe to trajectory channels.
459
- * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
344
+ * @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
460
345
  */
461
- unsubscribeTrajectory(cb) {
462
- this.unsubscribe(`trajectory`, '', cb);
346
+ unsubscribeTrajectory(onMessage) {
347
+ this.unsubscribe(`trajectory`, '', onMessage);
463
348
  }
464
349
  /**
465
350
  * Subscribe to deleted_vhicles channel.
466
351
  *
467
352
  * @param {RealtimeMode} mode Realtime mode.
468
- * @param {function(response: { content: Vehicle })} onMessage Function called on each message of the channel.
469
- * @param {boolean} quiet If true, the subscription will not send GET and SUB requests to the websocket.
353
+ * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
354
+ * @param {function} onError Callback when the subscription fails.
355
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
470
356
  */
471
- subscribeDeletedVehicles(mode, onMessage, quiet = false) {
357
+ subscribeDeletedVehicles(mode, onMessage, onError = () => { }, quiet = false) {
472
358
  this.unsubscribeDeletedVehicles(onMessage);
473
- this.subscribe(`deleted_vehicles${getModeSuffix(mode, RealtimeModes)}`, onMessage, undefined, quiet);
359
+ this.subscribe(`deleted_vehicles${getModeSuffix(mode, RealtimeModes)}`, onMessage, onError, quiet);
474
360
  }
475
361
  /**
476
362
  * Unsubscribe to deleted_vhicles channels.
477
- * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
363
+ * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
478
364
  */
479
- unsubscribeDeletedVehicles(cb) {
480
- this.unsubscribe('deleted_vehicles', '', cb);
365
+ unsubscribeDeletedVehicles(onMessage) {
366
+ this.unsubscribe('deleted_vehicles', '', onMessage);
481
367
  }
482
368
  /**
483
369
  * Get a full trajectory of a vehicule .
@@ -485,7 +371,7 @@ class RealtimeAPI {
485
371
  * @param {string} id A vehicle id.
486
372
  * @param {RealtimeMode} mode Realtime mode.
487
373
  * @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
488
- * @return {Promise<FullTrajectory>} Return a full trajectory.
374
+ * @return {Promise<{ data: { content: FullTrajectory } }>} Return a full trajectory.
489
375
  */
490
376
  getFullTrajectory(id, mode, generalizationLevel) {
491
377
  const channel = [`full_trajectory${getModeSuffix(mode, RealtimeModes)}`];
@@ -498,129 +384,79 @@ class RealtimeAPI {
498
384
  const params = {
499
385
  channel: channel.join('_'),
500
386
  };
501
- return new Promise((resolve) => {
502
- this.wsApi.get(params, (data) => {
503
- if (data.content) {
504
- resolve(data.content);
505
- }
506
- });
387
+ return new Promise((resolve, reject) => {
388
+ this.wsApi.get(params, resolve, reject);
507
389
  });
508
390
  }
509
- /**
510
- * Get full trajectories of a vehicules .
511
- *
512
- * @param {string[]} ids List of vehicles ids.
513
- * @param {RealtimeMode} mode Realtime mode.
514
- * @param {string} generalizationLevel The generalization level to request. Can be one of '', 'gen5', 'gen10', 'gen30', 'gen100'.
515
- * @return {Promise<Array<FullTrajectory>>} Return an array of full trajectories.
516
- */
517
- getFullTrajectories(ids, mode, generalizationLevel) {
518
- const promises = ids.map((id) => this.getFullTrajectory(id, mode, generalizationLevel));
519
- return Promise.all(promises);
520
- }
521
391
  /**
522
392
  * Subscribe to full_trajectory channel of a given vehicle.
523
393
  *
524
394
  * @param {string} id A vehicle id.
525
395
  * @param {RealtimeMode} mode Realtime mode.
396
+ * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Function called on each message of the channel.
397
+ * @param {function} onError Callback when the subscription fails.
398
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
526
399
  */
527
- subscribeFullTrajectory(id, mode) {
528
- // window.clearTimeout(this.fullTrajectoryUpdateTimeout);
529
- this.unsubscribeFullTrajectory(id);
530
- this.subscribe(`full_trajectory${getModeSuffix(mode, RealtimeModes)}_${id}`, (data) => {
531
- // eslint-disable-next-line no-console
532
- console.log('subscribe full_trajectory', data);
533
- }, (err) => {
534
- // eslint-disable-next-line no-console
535
- console.log('subscribe full_trajectory error', err);
536
- });
400
+ subscribeFullTrajectory(id, mode, onMessage, onError = () => { }, quiet = false) {
401
+ this.subscribe(`full_trajectory${getModeSuffix(mode, RealtimeModes)}_${id}`, onMessage, onError, quiet);
537
402
  }
538
403
  /**
539
404
  * Unsubscribe from full_trajectory channel
540
405
  *
541
406
  * @param {string} id A vehicle id.
542
- * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
407
+ * @param {function(data: { content: RealtimeFullTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
543
408
  */
544
- unsubscribeFullTrajectory(id, cb) {
545
- this.unsubscribe('full_trajectory', `_${id}`, cb);
409
+ unsubscribeFullTrajectory(id, onMessage) {
410
+ this.unsubscribe('full_trajectory', `_${id}`, onMessage);
546
411
  }
547
412
  /**
548
413
  * Get the list of stops for this vehicle.
549
414
  *
550
415
  * @param {string} id A vehicle id.
551
- * @return {Promise<StopSequence>} Returns a stop sequence object.
416
+ * @return {Promise<{ data: { content: StopSequence[] } }>} Returns a stop sequence object.
552
417
  */
553
418
  getStopSequence(id) {
554
- const params = {
555
- channel: `stopsequence_${id}`,
556
- };
557
419
  return new Promise((resolve, reject) => {
558
- this.wsApi.get(params, (data) => {
559
- const content = data.content;
560
- if (content && content.length) {
561
- const stopSequences = content.map((stopSequence) => cleanStopTime(stopSequence));
562
- // Remove the delay from arrivalTime and departureTime
563
- resolve(stopSequences);
564
- }
565
- resolve([]);
566
- }, (err) => {
567
- reject(err);
568
- });
420
+ this.wsApi.get({
421
+ channel: `stopsequence_${id}`,
422
+ }, resolve, reject);
569
423
  });
570
424
  }
571
- /**
572
- * Get a list of stops for a list of vehicles.
573
- *
574
- * @param {string[]} ids List of vehicles ids.
575
- * @return {Promise<Array<StopSequence>>} Return an array of stop sequences.
576
- */
577
- getStopSequences(ids) {
578
- const promises = ids.map((id) => this.getStopSequence(id));
579
- return Promise.all(promises);
580
- }
581
425
  /**
582
426
  * Subscribe to stopsequence channel of a given vehicle.
583
427
  *
584
428
  * @param {string} id A vehicle id.
585
- * @param {function(stopSequence: StopSequence)} onMessage Function called on each message of the channel.
429
+ * @param {function(data: { content: StopSequence[] })} onMessage Function called on each message of the channel.
430
+ * @param {function} onError Callback when the subscription fails.
431
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
586
432
  */
587
- subscribeStopSequence(id, onMessage) {
588
- window.clearTimeout(this.fullTrajectoryUpdateTimeout);
589
- this.unsubscribeStopSequence(id);
590
- this.subscribe(`stopsequence_${id}`, (data) => {
591
- const content = data.content;
592
- if (content && content.length) {
593
- const stopSequences = content.map((stopSequence) => cleanStopTime(stopSequence));
594
- // Remove the delay from arrivalTime and departureTime
595
- onMessage(stopSequences);
596
- }
597
- }, (err) => {
598
- // eslint-disable-next-line no-console
599
- console.log('subscribe stopsequence error', err);
600
- });
433
+ subscribeStopSequence(id, onMessage, onError = () => { }, quiet = false) {
434
+ this.subscribe(`stopsequence_${id}`, onMessage, onError, quiet);
601
435
  }
602
436
  /**
603
437
  * Unsubscribe from stopsequence channel
604
438
  *
605
439
  * @param {string} id A vehicle id.
606
- * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
440
+ * @param {function(data: { content: StopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
607
441
  */
608
- unsubscribeStopSequence(id, cb) {
609
- this.unsubscribe(`stopsequence`, `_${id}`, cb);
442
+ unsubscribeStopSequence(id, onMessage) {
443
+ this.unsubscribe(`stopsequence`, `_${id}`, onMessage);
610
444
  }
611
445
  /**
612
446
  * Subscribe to healthcheck channel.
613
- * @param {function} onMessage Callback when the subscribe to healthcheck channel succeeds.
447
+ * @param {function(data: { content: string })} onMessage Callback when the subscribe to healthcheck channel succeeds.
448
+ * @param {function} onError Callback when the subscription fails.
449
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
614
450
  */
615
- subscribeHealthCheck(onMessage) {
616
- this.unsubscribeHealthCheck();
617
- this.subscribe('healthcheck', onMessage);
451
+ subscribeHealthCheck(onMessage, onError = () => { }, quiet = false) {
452
+ this.subscribe('healthcheck', onMessage, onError, quiet);
618
453
  }
619
454
  /**
620
455
  * Unsubscribe to healthcheck channel.
456
+ * @param {function(data: { content: string })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
621
457
  */
622
- unsubscribeHealthCheck() {
623
- this.unsubscribe('healthcheck');
458
+ unsubscribeHealthCheck(onMessage) {
459
+ this.unsubscribe('healthcheck', '', onMessage);
624
460
  }
625
461
  }
626
462
  export default RealtimeAPI;
@@ -1,19 +1,17 @@
1
- import { Feature } from 'geojson';
2
- import { RealtimeDeparture, RealtimeNews, RealtimeStation, RealtimeExtraGeom, RealtimeTrajectory, RealtimeTrajectoryResponse, RealtimeStopSequence, RealtimeFullTrajectory } from '../../types';
1
+ import { RealtimeTrajectoryResponse } from '../../types';
3
2
  export declare type WebSocketAPIParameters = {
4
3
  channel?: string;
5
4
  args?: string | number;
6
5
  id?: string | number;
7
6
  };
8
- export declare type WebSocketAPIMessageEventData = {
7
+ export declare type WebSocketAPIMessageEventData<T> = {
9
8
  timestamp: number;
10
9
  source: string;
11
- content: string | Feature | RealtimeTrajectoryResponse[] | RealtimeDeparture | RealtimeNews[] | RealtimeStation | RealtimeExtraGeom | RealtimeTrajectory | RealtimeStopSequence[] | RealtimeFullTrajectory;
10
+ content: T;
12
11
  client_reference: string | number | null;
13
12
  };
14
- export declare type WebSocketAPIBufferMessageEventData = Omit<WebSocketAPIMessageEventData, 'content'> & {
13
+ export declare type WebSocketAPIBufferMessageEventData = WebSocketAPIMessageEventData<RealtimeTrajectoryResponse[]> & {
15
14
  source: 'buffer';
16
- content: Array<WebSocketAPIMessageEventData>;
17
15
  };
18
16
  export declare type WebSocketAPIMessageEvent = Event & {
19
17
  data: string;
@@ -24,12 +22,12 @@ export interface WebSocketAPIMessageEventListener {
24
22
  /**
25
23
  * This type represents a function that has been call with each feature returned by the websocket.
26
24
  */
27
- export interface WebSocketAPIDataCallback {
28
- (data: WebSocketAPIMessageEventData): void;
25
+ export interface WebSocketAPIMessageCallback<T> {
26
+ (data: WebSocketAPIMessageEventData<T>): void;
29
27
  }
30
28
  export declare type WebSocketAPISubscription = {
31
29
  params: WebSocketAPIParameters;
32
- cb: WebSocketAPIDataCallback;
30
+ cb: WebSocketAPIMessageCallback<any>;
33
31
  errorCb?: EventListener;
34
32
  onMessageCb: WebSocketAPIMessageEventListener;
35
33
  onErrorCb?: EventListener;
@@ -40,7 +38,7 @@ export declare type WebSocketAPISubscribed = {
40
38
  };
41
39
  export declare type WebSocketAPIRequest = {
42
40
  params: WebSocketAPIParameters;
43
- cb: WebSocketAPIDataCallback;
41
+ cb: WebSocketAPIMessageCallback<any>;
44
42
  errorCb?: EventListener;
45
43
  onMessageCb: WebSocketAPIMessageEventListener;
46
44
  onErrorCb?: EventListener;
@@ -107,7 +105,7 @@ declare class WebSocketAPI {
107
105
  * @return {{onMessage: function, errorCb: function}} Object with onMessage and error callbacks
108
106
  * @private
109
107
  */
110
- listen(params: WebSocketAPIParameters, cb: WebSocketAPIDataCallback, errorCb?: EventListener): {
108
+ listen(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): {
111
109
  onMessageCb: WebSocketAPIMessageEventListener;
112
110
  onErrorCb?: EventListener;
113
111
  };
@@ -118,7 +116,7 @@ declare class WebSocketAPI {
118
116
  * @param {function} cb Callback used when listen.
119
117
  * @private
120
118
  */
121
- unlisten(params: WebSocketAPIParameters, cb: WebSocketAPIDataCallback): void;
119
+ unlisten(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>): void;
122
120
  /**
123
121
  * Sends a get request to the websocket.
124
122
  * The callback is called only once, when the response is received or when the call returns an error.
@@ -128,7 +126,7 @@ declare class WebSocketAPI {
128
126
  * @param {function} onError Callback on error and close event
129
127
  * @private
130
128
  */
131
- get(params: WebSocketAPIParameters, cb: WebSocketAPIDataCallback, errorCb?: EventListener): void;
129
+ get(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): void;
132
130
  /**
133
131
  * Subscribe to a given channel.
134
132
  *
@@ -138,14 +136,14 @@ declare class WebSocketAPI {
138
136
  * @param {boolean} quiet if false, no GET or SUB requests are send, only the callback is registered.
139
137
  * @private
140
138
  */
141
- subscribe(params: WebSocketAPIParameters, cb: WebSocketAPIDataCallback, errorCb?: EventListener, quiet?: boolean): void;
139
+ subscribe(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener, quiet?: boolean): void;
142
140
  /**
143
141
  * Unsubscribe from a channel.
144
142
  * @param {string} source source to unsubscribe from
145
143
  * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
146
144
  * @private
147
145
  */
148
- unsubscribe(source: string, cb?: WebSocketAPIDataCallback): void;
146
+ unsubscribe(source: string, cb?: WebSocketAPIMessageCallback<any>): void;
149
147
  /**
150
148
  * After an auto reconnection we need to re-subscribe to the channels.
151
149
  */
@@ -1 +1 @@
1
- {"version":3,"file":"WebSocketAPI.d.ts","sourceRoot":"","sources":["../../../src/common/api/WebSocketAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,OAAO,MAAM,sBAAsB,GAAG;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,4BAA4B,GAAG;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EACH,MAAM,GACN,OAAO,GACP,0BAA0B,EAAE,GAC5B,iBAAiB,GACjB,YAAY,EAAE,GACd,eAAe,GACf,iBAAiB,GACjB,kBAAkB,GAClB,oBAAoB,EAAE,GACtB,sBAAsB,CAAC;IAC3B,gBAAgB,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC1C,CAAC;AAEF,oBAAY,kCAAkC,GAAG,IAAI,CACnD,4BAA4B,EAC5B,SAAS,CACV,GAAG;IACF,MAAM,EAAE,QAAQ,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;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,EACpC,OAAO,CAAC,EAAE,aAAa,GACtB;QACD,WAAW,EAAE,gCAAgC,CAAC;QAC9C,SAAS,CAAC,EAAE,aAAa,CAAC;KAC3B;IA4CD;;;;;;OAMG;IACH,QAAQ,CACN,MAAM,EAAE,sBAAsB,EAC9B,EAAE,EAAE,2BAA2B,CAAC,GAAG,CAAC;IAWtC;;;;;;;;OAQG;IACH,GAAG,CACD,MAAM,EAAE,sBAAsB,EAC9B,EAAE,EAAE,2BAA2B,CAAC,GAAG,CAAC,EACpC,OAAO,CAAC,EAAE,aAAa;IAiDzB;;;;;;;;OAQG;IACH,SAAS,CACP,MAAM,EAAE,sBAAsB,EAC9B,EAAE,EAAE,2BAA2B,CAAC,GAAG,CAAC,EACpC,OAAO,CAAC,EAAE,aAAa,EACvB,KAAK,UAAQ;IAwBf;;;;;OAKG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,2BAA2B,CAAC,GAAG,CAAC;IA0BjE;;OAEG;IACH,8BAA8B;CAa/B;AAED,eAAe,YAAY,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import BaseObject from 'ol/Object';
2
- import { AnyMap } from '../../types';
2
+ import type { AnyMap } from '../../types';
3
3
  export declare type ControlCommonOptions = {
4
4
  active?: Boolean;
5
5
  element?: HTMLElement;