mobility-toolbox-js 3.0.0-beta.9 → 3.0.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 (105) hide show
  1. package/README.md +11 -3
  2. package/api/HttpAPI.d.ts +5 -16
  3. package/api/HttpAPI.js +1 -14
  4. package/api/RealtimeAPI.d.ts +188 -143
  5. package/api/RealtimeAPI.js +265 -206
  6. package/api/RoutingAPI.d.ts +21 -11
  7. package/api/RoutingAPI.js +17 -7
  8. package/api/StopsAPI.d.ts +20 -14
  9. package/api/StopsAPI.js +17 -11
  10. package/api/WebSocketAPI.d.ts +60 -66
  11. package/api/WebSocketAPI.js +164 -165
  12. package/api/index.js +1 -1
  13. package/api/typedefs.d.ts +0 -102
  14. package/api/typedefs.js +27 -42
  15. package/common/controls/StopFinderControlCommon.d.ts +13 -13
  16. package/common/controls/StopFinderControlCommon.js +32 -32
  17. package/common/index.d.ts +1 -1
  18. package/common/index.js +1 -1
  19. package/common/styles/realtimeDefaultStyle.js +6 -11
  20. package/common/styles/realtimeHeadingStyle.js +5 -10
  21. package/common/styles/realtimeSimpleStyle.d.ts +0 -1
  22. package/common/styles/realtimeSimpleStyle.js +0 -1
  23. package/common/typedefs.d.ts +11 -121
  24. package/common/typedefs.js +6 -31
  25. package/common/utils/RealtimeEngine.d.ts +214 -0
  26. package/common/utils/RealtimeEngine.js +554 -0
  27. package/common/utils/compareDepartures.d.ts +2 -2
  28. package/common/utils/compareDepartures.js +2 -2
  29. package/common/utils/debounceWebsocketMessages.d.ts +1 -1
  30. package/common/utils/getLayersAsFlatArray.d.ts +0 -1
  31. package/common/utils/getLayersAsFlatArray.js +0 -1
  32. package/common/utils/getMapGlCopyrights.d.ts +1 -1
  33. package/common/utils/getMapGlCopyrights.js +3 -3
  34. package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
  35. package/common/utils/getRealtimeModeSuffix.js +1 -0
  36. package/common/utils/getVehiclePosition.d.ts +5 -4
  37. package/common/utils/getVehiclePosition.js +6 -3
  38. package/common/utils/realtimeConfig.d.ts +1 -1
  39. package/common/utils/realtimeConfig.js +0 -1
  40. package/common/utils/renderTrajectories.d.ts +2 -1
  41. package/common/utils/renderTrajectories.js +7 -6
  42. package/common/utils/sortAndFilterDepartures.d.ts +2 -1
  43. package/common/utils/sortAndFilterDepartures.js +2 -1
  44. package/common/utils/sortByDelay.d.ts +2 -2
  45. package/common/utils/sortByDelay.js +5 -1
  46. package/maplibre/controls/CopyrightControl.d.ts +9 -6
  47. package/maplibre/controls/CopyrightControl.js +11 -8
  48. package/maplibre/layers/Layer.d.ts +8 -7
  49. package/maplibre/layers/Layer.js +2 -3
  50. package/maplibre/layers/RealtimeLayer.d.ts +82 -118
  51. package/maplibre/layers/RealtimeLayer.js +154 -118
  52. package/maplibre/utils/getSourceCoordinates.d.ts +1 -0
  53. package/maplibre/utils/getSourceCoordinates.js +6 -5
  54. package/mbt.js +14611 -14591
  55. package/mbt.js.map +4 -4
  56. package/mbt.min.js +75 -75
  57. package/mbt.min.js.map +4 -4
  58. package/ol/controls/CopyrightControl.d.ts +13 -5
  59. package/ol/controls/CopyrightControl.js +13 -5
  60. package/ol/controls/RoutingControl.d.ts +105 -101
  61. package/ol/controls/RoutingControl.js +250 -264
  62. package/ol/controls/StopFinderControl.d.ts +24 -5
  63. package/ol/controls/StopFinderControl.js +24 -5
  64. package/ol/layers/Layer.d.ts +26 -0
  65. package/ol/layers/Layer.js +39 -0
  66. package/ol/layers/MaplibreLayer.d.ts +56 -28
  67. package/ol/layers/MaplibreLayer.js +154 -31
  68. package/ol/layers/MaplibreStyleLayer.d.ts +71 -149
  69. package/ol/layers/MaplibreStyleLayer.js +281 -210
  70. package/ol/layers/RealtimeLayer.d.ts +95 -230
  71. package/ol/layers/RealtimeLayer.js +209 -211
  72. package/ol/layers/VectorLayer.d.ts +17 -0
  73. package/ol/layers/VectorLayer.js +33 -0
  74. package/ol/layers/index.d.ts +2 -0
  75. package/ol/layers/index.js +3 -0
  76. package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
  77. package/ol/renderers/MaplibreLayerRenderer.js +142 -114
  78. package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
  79. package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
  80. package/ol/renderers/RealtimeLayerRenderer.d.ts +7 -7
  81. package/ol/renderers/RealtimeLayerRenderer.js +46 -66
  82. package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
  83. package/ol/styles/fullTrajectoryStyle.d.ts +1 -2
  84. package/ol/styles/fullTrajectoryStyle.js +5 -7
  85. package/ol/styles/routingStyle.d.ts +0 -1
  86. package/ol/styles/routingStyle.js +13 -10
  87. package/ol/utils/defineDeprecatedProperties.d.ts +10 -0
  88. package/ol/utils/defineDeprecatedProperties.js +180 -0
  89. package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
  90. package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
  91. package/package.json +44 -44
  92. package/setupTests.js +17 -4
  93. package/types/common.d.ts +53 -69
  94. package/types/index.d.ts +1 -1
  95. package/types/realtime.d.ts +98 -95
  96. package/types/routing.d.ts +60 -60
  97. package/types/stops.d.ts +62 -62
  98. package/common/mixins/RealtimeLayerMixin.d.ts +0 -273
  99. package/common/mixins/RealtimeLayerMixin.js +0 -743
  100. package/ol/layers/MapGlLayer.d.ts +0 -144
  101. package/ol/layers/MapGlLayer.js +0 -144
  102. package/ol/mixins/MobilityLayerMixin.d.ts +0 -98
  103. package/ol/mixins/MobilityLayerMixin.js +0 -6
  104. package/ol/mixins/PropertiesLayerMixin.d.ts +0 -127
  105. package/ol/mixins/PropertiesLayerMixin.js +0 -143
@@ -8,52 +8,6 @@ class WebSocketAPI {
8
8
  constructor() {
9
9
  this.defineProperties();
10
10
  }
11
- defineProperties() {
12
- Object.defineProperties(this, {
13
- closed: {
14
- get: () => !!(!this.websocket ||
15
- this.websocket.readyState === this.websocket.CLOSED),
16
- },
17
- closing: {
18
- get: () => !!(this.websocket &&
19
- this.websocket.readyState === this.websocket.CLOSING),
20
- },
21
- connecting: {
22
- get: () => !!(this.websocket &&
23
- this.websocket.readyState === this.websocket.CONNECTING),
24
- },
25
- open: {
26
- get: () => !!(this.websocket && this.websocket.readyState === this.websocket.OPEN),
27
- },
28
- /**
29
- * Array of message to send on open.
30
- * @type {Array<string>}
31
- * @private
32
- */
33
- messagesOnOpen: {
34
- value: [],
35
- writable: true,
36
- },
37
- /**
38
- * Array of subscriptions.
39
- * @type {Array<WebSocketSubscription>}
40
- * @private
41
- */
42
- subscriptions: {
43
- value: [],
44
- writable: true,
45
- },
46
- /**
47
- * List of channels subscribed.
48
- * @type {WebSocketSubscribed}
49
- * @private
50
- */
51
- subscribed: {
52
- value: {},
53
- writable: true,
54
- },
55
- });
56
- }
57
11
  /**
58
12
  * Get the websocket request string.
59
13
  *
@@ -71,6 +25,27 @@ class WebSocketAPI {
71
25
  reqStr += params.id ? ` ${params.id}` : '';
72
26
  return reqStr.trim();
73
27
  }
28
+ addEvents(onMessage, onError) {
29
+ if (this.websocket) {
30
+ this.websocket.addEventListener('message', onMessage);
31
+ if (onError) {
32
+ this.websocket.addEventListener('error', onError);
33
+ this.websocket.addEventListener('close', onError);
34
+ }
35
+ }
36
+ }
37
+ /**
38
+ * Close the websocket definitively.
39
+ *
40
+ * @private
41
+ */
42
+ close() {
43
+ if (this.websocket && (this.open || this.connecting)) {
44
+ this.websocket.onclose = () => { };
45
+ this.websocket.close();
46
+ this.messagesOnOpen = [];
47
+ }
48
+ }
74
49
  /**
75
50
  * (Re)connect the websocket.
76
51
  *
@@ -96,7 +71,6 @@ class WebSocketAPI {
96
71
  this.websocket.close();
97
72
  }
98
73
  }
99
- /** @private */
100
74
  this.websocket = new WebSocket(url);
101
75
  if (!this.open) {
102
76
  this.websocket.addEventListener('open', () => {
@@ -109,65 +83,94 @@ class WebSocketAPI {
109
83
  this.subscribePreviousSubscriptions();
110
84
  }
111
85
  }
112
- /**
113
- * Close the websocket definitively.
114
- *
115
- * @private
116
- */
117
- close() {
118
- if (this.websocket && (this.open || this.connecting)) {
119
- this.websocket.onclose = () => { };
120
- this.websocket.close();
121
- this.messagesOnOpen = [];
122
- }
86
+ defineProperties() {
87
+ Object.defineProperties(this, {
88
+ closed: {
89
+ get: () => !!(!this.websocket ||
90
+ this.websocket.readyState === this.websocket.CLOSED),
91
+ },
92
+ closing: {
93
+ get: () => !!(this.websocket &&
94
+ this.websocket.readyState === this.websocket.CLOSING),
95
+ },
96
+ connecting: {
97
+ get: () => !!(this.websocket &&
98
+ this.websocket.readyState === this.websocket.CONNECTING),
99
+ },
100
+ /**
101
+ * Array of message to send on open.
102
+ * @type {Array<string>}
103
+ * @private
104
+ */
105
+ messagesOnOpen: {
106
+ value: [],
107
+ writable: true,
108
+ },
109
+ open: {
110
+ get: () => !!(this.websocket && this.websocket.readyState === this.websocket.OPEN),
111
+ },
112
+ /**
113
+ * List of channels subscribed.
114
+ * @type {WebSocketSubscribed}
115
+ * @private
116
+ */
117
+ subscribed: {
118
+ value: {},
119
+ writable: true,
120
+ },
121
+ /**
122
+ * Array of subscriptions.
123
+ * @type {Array<WebSocketSubscription>}
124
+ * @private
125
+ */
126
+ subscriptions: {
127
+ value: [],
128
+ writable: true,
129
+ },
130
+ });
123
131
  }
124
132
  /**
125
- * Sends a message to the websocket.
133
+ * Sends a get request to the websocket.
134
+ * The callback is called only once, when the response is received or when the call returns an error.
126
135
  *
127
- * @param {message} message Message to send.
136
+ * @param {Object} params Parameters for the websocket get request
137
+ * @param {function} cb callback on message event
138
+ * @param {function} errorCb Callback on error and close event
128
139
  * @private
129
140
  */
130
- send(message) {
131
- if (!this.websocket || this.closed || this.closing) {
132
- return;
133
- }
134
- const send = () => {
135
- var _a;
136
- (_a = this.websocket) === null || _a === void 0 ? void 0 : _a.send(message);
141
+ get(params, cb, errorCb) {
142
+ const requestString = WebSocketAPI.getRequestString('GET', params);
143
+ this.send(requestString);
144
+ // We wrap the callbacks to make sure they are called only once.
145
+ const once = (callback) =>
146
+ // @ts-expect-error : Spread error
147
+ (...args) => {
148
+ // @ts-expect-error : Spread error
149
+ callback(...args);
150
+ const index = this.requests.findIndex((request) => requestString === request.requestString && cb === request.cb);
151
+ const { onErrorCb, onMessageCb } = this.requests[index];
152
+ this.removeEvents(onMessageCb, onErrorCb);
153
+ this.requests.splice(index, 1);
137
154
  };
138
- if (!this.open) {
139
- // This 'if' avoid sending 2 identical BBOX message on open,
140
- if (!this.messagesOnOpen.includes(message)) {
141
- this.messagesOnOpen.push(message);
142
- this.websocket.addEventListener('open', () => {
143
- this.messagesOnOpen = [];
144
- send();
145
- });
146
- this.websocket.addEventListener('close', () => {
147
- this.messagesOnOpen = [];
148
- });
149
- }
150
- }
151
- else if (!this.messagesOnOpen.includes(message)) {
152
- send();
155
+ const { onErrorCb, onMessageCb } = this.listen(params, once(cb), errorCb && once(errorCb));
156
+ // Store requests and callbacks to be able to remove them.
157
+ if (!this.requests) {
158
+ this.requests = [];
153
159
  }
154
- }
155
- addEvents(onMessage, onError) {
156
- if (this.websocket) {
157
- this.websocket.addEventListener('message', onMessage);
158
- if (onError) {
159
- this.websocket.addEventListener('error', onError);
160
- this.websocket.addEventListener('close', onError);
161
- }
160
+ const index = this.requests.findIndex((request) => requestString === request.requestString && cb === request.cb);
161
+ const newReq = {
162
+ cb,
163
+ errorCb,
164
+ onErrorCb,
165
+ onMessageCb,
166
+ params,
167
+ requestString,
168
+ };
169
+ if (index > -1) {
170
+ this.requests[index] = newReq;
162
171
  }
163
- }
164
- removeEvents(onMessage, onError) {
165
- if (this.websocket) {
166
- this.websocket.removeEventListener('message', onMessage);
167
- if (onError) {
168
- this.websocket.removeEventListener('error', onError);
169
- this.websocket.removeEventListener('close', onError);
170
- }
172
+ else {
173
+ this.requests.push(newReq);
171
174
  }
172
175
  }
173
176
  /**
@@ -213,64 +216,46 @@ class WebSocketAPI {
213
216
  });
214
217
  };
215
218
  this.addEvents(onMessage, errorCb);
216
- return { onMessageCb: onMessage, onErrorCb: errorCb };
219
+ return { onErrorCb: errorCb, onMessageCb: onMessage };
217
220
  }
218
- /**
219
- * Unlisten websocket messages.
220
- *
221
- * @param {Object} params Parameters for the websocket get request.
222
- * @param {function} cb Callback used when listen.
223
- * @private
224
- */
225
- unlisten(params, cb) {
226
- [...(this.subscriptions || []), ...(this.requests || [])]
227
- .filter((s) => s.params.channel === params.channel && (!cb || s.cb === cb))
228
- .forEach(({ onMessageCb, onErrorCb }) => {
229
- this.removeEvents(onMessageCb, onErrorCb);
230
- });
221
+ removeEvents(onMessage, onError) {
222
+ if (this.websocket) {
223
+ this.websocket.removeEventListener('message', onMessage);
224
+ if (onError) {
225
+ this.websocket.removeEventListener('error', onError);
226
+ this.websocket.removeEventListener('close', onError);
227
+ }
228
+ }
231
229
  }
232
230
  /**
233
- * Sends a get request to the websocket.
234
- * The callback is called only once, when the response is received or when the call returns an error.
231
+ * Sends a message to the websocket.
235
232
  *
236
- * @param {Object} params Parameters for the websocket get request
237
- * @param {function} onMessage callback on message event
238
- * @param {function} onError Callback on error and close event
233
+ * @param {message} message Message to send.
239
234
  * @private
240
235
  */
241
- get(params, cb, errorCb) {
242
- const requestString = WebSocketAPI.getRequestString('GET', params);
243
- this.send(requestString);
244
- // We wrap the callbacks to make sure they are called only once.
245
- const once = (callback) =>
246
- // @ts-ignore: Spread error
247
- (...args) => {
248
- // @ts-ignore: Spread error
249
- callback(...args);
250
- const index = this.requests.findIndex((request) => requestString === request.requestString && cb === request.cb);
251
- const { onMessageCb, onErrorCb } = this.requests[index];
252
- this.removeEvents(onMessageCb, onErrorCb);
253
- this.requests.splice(index, 1);
254
- };
255
- const { onMessageCb, onErrorCb } = this.listen(params, once(cb), errorCb && once(errorCb));
256
- // Store requests and callbacks to be able to remove them.
257
- if (!this.requests) {
258
- this.requests = [];
236
+ send(message) {
237
+ if (!this.websocket || this.closed || this.closing) {
238
+ return;
259
239
  }
260
- const index = this.requests.findIndex((request) => requestString === request.requestString && cb === request.cb);
261
- const newReq = {
262
- params,
263
- requestString,
264
- cb,
265
- errorCb,
266
- onMessageCb,
267
- onErrorCb,
240
+ const send = () => {
241
+ var _a;
242
+ (_a = this.websocket) === null || _a === void 0 ? void 0 : _a.send(message);
268
243
  };
269
- if (index > -1) {
270
- this.requests[index] = newReq;
244
+ if (!this.open) {
245
+ // This 'if' avoid sending 2 identical BBOX message on open,
246
+ if (!this.messagesOnOpen.includes(message)) {
247
+ this.messagesOnOpen.push(message);
248
+ this.websocket.addEventListener('open', () => {
249
+ this.messagesOnOpen = [];
250
+ send();
251
+ });
252
+ this.websocket.addEventListener('close', () => {
253
+ this.messagesOnOpen = [];
254
+ });
255
+ }
271
256
  }
272
- else {
273
- this.requests.push(newReq);
257
+ else if (!this.messagesOnOpen.includes(message)) {
258
+ send();
274
259
  }
275
260
  }
276
261
  /**
@@ -283,10 +268,10 @@ class WebSocketAPI {
283
268
  * @private
284
269
  */
285
270
  subscribe(params, cb, errorCb, quiet = false) {
286
- const { onMessageCb, onErrorCb } = this.listen(params, cb, errorCb);
271
+ const { onErrorCb, onMessageCb } = this.listen(params, cb, errorCb);
287
272
  const reqStr = WebSocketAPI.getRequestString('', params);
288
273
  const index = this.subscriptions.findIndex((subcr) => params.channel === subcr.params.channel && cb === subcr.cb);
289
- const newSubscr = { params, cb, errorCb, onMessageCb, onErrorCb, quiet };
274
+ const newSubscr = { cb, errorCb, onErrorCb, onMessageCb, params, quiet };
290
275
  if (index > -1) {
291
276
  this.subscriptions[index] = newSubscr;
292
277
  }
@@ -301,6 +286,35 @@ class WebSocketAPI {
301
286
  this.subscribed[reqStr] = true;
302
287
  }
303
288
  }
289
+ /**
290
+ * After an auto reconnection we need to re-subscribe to the channels.
291
+ */
292
+ subscribePreviousSubscriptions() {
293
+ // Before to subscribe previous subscriptions we make sure they
294
+ // are all defined as unsubscribed, because this code is asynchrone
295
+ // and a subscription could have been added in between.
296
+ Object.keys(this.subscribed).forEach((key) => {
297
+ this.subscribed[key] = false;
298
+ });
299
+ // Subscribe all previous subscriptions.
300
+ [...this.subscriptions].forEach((s) => {
301
+ this.subscribe(s.params, s.cb, s.errorCb, s.quiet);
302
+ });
303
+ }
304
+ /**
305
+ * Unlisten websocket messages.
306
+ *
307
+ * @param {Object} params Parameters for the websocket get request.
308
+ * @param {function} cb Callback used when listen.
309
+ * @private
310
+ */
311
+ unlisten(params, cb) {
312
+ [...(this.subscriptions || []), ...(this.requests || [])]
313
+ .filter((s) => s.params.channel === params.channel && (!cb || s.cb === cb))
314
+ .forEach(({ onErrorCb, onMessageCb }) => {
315
+ this.removeEvents(onMessageCb, onErrorCb);
316
+ });
317
+ }
304
318
  /**
305
319
  * Unsubscribe from a channel.
306
320
  * @param {string} source source to unsubscribe from
@@ -309,7 +323,7 @@ class WebSocketAPI {
309
323
  */
310
324
  unsubscribe(source, cb) {
311
325
  const toRemove = this.subscriptions.filter((s) => s.params.channel === source && (!cb || s.cb === cb));
312
- toRemove.forEach(({ onMessageCb, onErrorCb }) => {
326
+ toRemove.forEach(({ onErrorCb, onMessageCb }) => {
313
327
  this.removeEvents(onMessageCb, onErrorCb);
314
328
  });
315
329
  this.subscriptions = this.subscriptions.filter((s) => s.params.channel !== source || (cb && s.cb !== cb));
@@ -323,20 +337,5 @@ class WebSocketAPI {
323
337
  this.subscribed[source] = false;
324
338
  }
325
339
  }
326
- /**
327
- * After an auto reconnection we need to re-subscribe to the channels.
328
- */
329
- subscribePreviousSubscriptions() {
330
- // Before to subscribe previous subscriptions we make sure they
331
- // are all defined as unsubscribed, because this code is asynchrone
332
- // and a subscription could have been added in between.
333
- Object.keys(this.subscribed).forEach((key) => {
334
- this.subscribed[key] = false;
335
- });
336
- // Subscribe all previous subscriptions.
337
- [...this.subscriptions].forEach((s) => {
338
- this.subscribe(s.params, s.cb, s.errorCb, s.quiet);
339
- });
340
- }
341
340
  }
342
341
  export default WebSocketAPI;
package/api/index.js CHANGED
@@ -1,3 +1,3 @@
1
+ export { default as RealtimeAPI, RealtimeModes } from './RealtimeAPI';
1
2
  export { default as RoutingAPI } from './RoutingAPI';
2
3
  export { default as StopsAPI } from './StopsAPI';
3
- export { default as RealtimeAPI, RealtimeModes } from './RealtimeAPI';
package/api/typedefs.d.ts CHANGED
@@ -1,59 +1,4 @@
1
1
  export default dummy;
2
- export type Departure = {
3
- /**
4
- * Timestamp in ms.
5
- */
6
- time: number;
7
- no_stop_between: boolean;
8
- train_number: number;
9
- to: string[];
10
- /**
11
- * Timestamp in ms.
12
- */
13
- ris_aimed_time: number;
14
- /**
15
- * Timestamp in ms.
16
- */
17
- updated_at: number;
18
- new_to: boolean;
19
- /**
20
- * Timestamp in ms.
21
- */
22
- min_arrival_time: number;
23
- /**
24
- * List of next stops. Like value in at_station_ds100.
25
- */
26
- next_stoppoints: string[];
27
- /**
28
- * Timestamp in ms.
29
- */
30
- ris_estimated_time: number;
31
- line: NetworkLine;
32
- /**
33
- * if true this departure has realtime data.
34
- */
35
- has_fzo: boolean;
36
- train_id: number;
37
- platform: string;
38
- state: any | null;
39
- /**
40
- * Timestamp in ms.
41
- */
42
- fzo_estimated_time: number;
43
- formation: any | null;
44
- no_stop_till: any | null;
45
- train_type: number;
46
- call_id: number;
47
- /**
48
- * Timestamp in ms.
49
- */
50
- created_at: string;
51
- at_station_ds100: string;
52
- /**
53
- * Timestamp in ms.
54
- */
55
- timediff: number;
56
- };
57
2
  export type Station = GeoJSONFeature;
58
3
  export type StationProperties = {
59
4
  transfers: Transfer[];
@@ -98,38 +43,6 @@ export type Transfer = {
98
43
  */
99
44
  lines: string[];
100
45
  };
101
- export type StopSequence = GeoJSONFeature;
102
- export type RealtimeTrajectory = GeoJSONFeature;
103
- export type FullTrajectory = GeoJSONFeature;
104
- export type Vehicle = GeoJSONFeature;
105
- export type ExtraGeom = GeoJSONFeature;
106
- /**
107
- * @typedef {Object} Departure
108
- * @property {number} time Timestamp in ms.
109
- * @property {boolean} no_stop_between
110
- * @property {number} train_number
111
- * @property {string[]} to
112
- * @property {number} ris_aimed_time Timestamp in ms.
113
- * @property {number} updated_at Timestamp in ms.
114
- * @property {boolean} new_to
115
- * @property {number} min_arrival_time Timestamp in ms.
116
- * @property {string[]} next_stoppoints List of next stops. Like value in at_station_ds100.
117
- * @property {number} ris_estimated_time Timestamp in ms.
118
- * @property {NetworkLine} line
119
- * @property {boolean} has_fzo if true this departure has realtime data.
120
- * @property {number} train_id
121
- * @property {string} platform
122
- * @property {?*} state
123
- * @property {number} fzo_estimated_time Timestamp in ms.
124
- * @property {?*} formation
125
- * @property {?*} no_stop_till
126
- * @property {number} train_type
127
- * @property {number} call_id
128
- * @property {string} created_at Timestamp in ms.
129
- * @property {string} at_station_ds100
130
- * @property {number} timediff Timestamp in ms.
131
- *
132
- */
133
46
  /**
134
47
  * @typedef {GeoJSONFeature} Station
135
48
  * @property {StationProperties} properties Returns the station's properties.
@@ -160,19 +73,4 @@ export type ExtraGeom = GeoJSONFeature;
160
73
  * @property {string} mot Mode of transportation (ex: U-Bahn).
161
74
  * @property {string[]} lines Array of lines name (ex: ["U4", "U5"]).
162
75
  */
163
- /**
164
- * @typedef {GeoJSONFeature} StopSequence
165
- */
166
- /**
167
- * @typedef {GeoJSONFeature} RealtimeTrajectory
168
- */
169
- /**
170
- * @typedef {GeoJSONFeature} FullTrajectory
171
- */
172
- /**
173
- * @typedef {GeoJSONFeature} Vehicle
174
- */
175
- /**
176
- * @typedef {GeoJSONFeature} ExtraGeom
177
- */
178
76
  declare function dummy(): void;
package/api/typedefs.js CHANGED
@@ -1,30 +1,30 @@
1
- /**
2
- * @typedef {Object} Departure
3
- * @property {number} time Timestamp in ms.
4
- * @property {boolean} no_stop_between
5
- * @property {number} train_number
6
- * @property {string[]} to
7
- * @property {number} ris_aimed_time Timestamp in ms.
8
- * @property {number} updated_at Timestamp in ms.
9
- * @property {boolean} new_to
10
- * @property {number} min_arrival_time Timestamp in ms.
11
- * @property {string[]} next_stoppoints List of next stops. Like value in at_station_ds100.
12
- * @property {number} ris_estimated_time Timestamp in ms.
13
- * @property {NetworkLine} line
14
- * @property {boolean} has_fzo if true this departure has realtime data.
15
- * @property {number} train_id
16
- * @property {string} platform
17
- * @property {?*} state
18
- * @property {number} fzo_estimated_time Timestamp in ms.
19
- * @property {?*} formation
20
- * @property {?*} no_stop_till
21
- * @property {number} train_type
22
- * @property {number} call_id
23
- * @property {string} created_at Timestamp in ms.
24
- * @property {string} at_station_ds100
25
- * @property {number} timediff Timestamp in ms.
26
- *
27
- */
1
+ // /**
2
+ // * @typedef {Object} Departure
3
+ // * @property {number} time Timestamp in ms.
4
+ // * @property {boolean} no_stop_between
5
+ // * @property {number} train_number
6
+ // * @property {string[]} to
7
+ // * @property {number} ris_aimed_time Timestamp in ms.
8
+ // * @property {number} updated_at Timestamp in ms.
9
+ // * @property {boolean} new_to
10
+ // * @property {number} min_arrival_time Timestamp in ms.
11
+ // * @property {string[]} next_stoppoints List of next stops. Like value in at_station_ds100.
12
+ // * @property {number} ris_estimated_time Timestamp in ms.
13
+ // * @property {NetworkLine} line
14
+ // * @property {boolean} has_fzo if true this departure has realtime data.
15
+ // * @property {number} train_id
16
+ // * @property {string} platform
17
+ // * @property {?*} state
18
+ // * @property {number} fzo_estimated_time Timestamp in ms.
19
+ // * @property {?*} formation
20
+ // * @property {?*} no_stop_till
21
+ // * @property {number} train_type
22
+ // * @property {number} call_id
23
+ // * @property {string} created_at Timestamp in ms.
24
+ // * @property {string} at_station_ds100
25
+ // * @property {number} timediff Timestamp in ms.
26
+ // *
27
+ // */
28
28
  /**
29
29
  * @typedef {GeoJSONFeature} Station
30
30
  * @property {StationProperties} properties Returns the station's properties.
@@ -55,21 +55,6 @@
55
55
  * @property {string} mot Mode of transportation (ex: U-Bahn).
56
56
  * @property {string[]} lines Array of lines name (ex: ["U4", "U5"]).
57
57
  */
58
- /**
59
- * @typedef {GeoJSONFeature} StopSequence
60
- */
61
- /**
62
- * @typedef {GeoJSONFeature} RealtimeTrajectory
63
- */
64
- /**
65
- * @typedef {GeoJSONFeature} FullTrajectory
66
- */
67
- /**
68
- * @typedef {GeoJSONFeature} Vehicle
69
- */
70
- /**
71
- * @typedef {GeoJSONFeature} ExtraGeom
72
- */
73
58
  // These lines is to block TypeScript to add "use strict;" in the outputed file.
74
59
  const dummy = () => { };
75
60
  export default dummy;
@@ -2,12 +2,12 @@ import { Feature, FeatureCollection } from 'geojson';
2
2
  import { StopsAPI } from '../../api';
3
3
  import { StopsAPIOptions } from '../../api/StopsAPI';
4
4
  import { StopsParameters } from '../../types';
5
- export type StopFinderControlCommonOptions = StopsAPIOptions & {
6
- element: HTMLElement;
7
- placeholder?: string;
5
+ export type StopFinderControlCommonOptions = {
8
6
  apiParams: StopsParameters;
7
+ element: HTMLElement;
9
8
  onSuggestionClick?: (suggestion: Feature, evt: MouseEvent) => void;
10
- };
9
+ placeholder?: string;
10
+ } & StopsAPIOptions;
11
11
  /**
12
12
  * A class representing a stop finder control to display on map.
13
13
  * This class only draw the html elements.
@@ -16,35 +16,35 @@ export type StopFinderControlCommonOptions = StopsAPIOptions & {
16
16
  * @private
17
17
  */
18
18
  declare class StopFinderControlCommon {
19
- apiParams: StopsParameters;
20
- placeholder: string;
21
- api: StopsAPI;
22
19
  abortController?: AbortController;
23
- suggestionsElt?: HTMLElement;
24
- inputElt?: HTMLInputElement;
20
+ api: StopsAPI;
21
+ apiParams: StopsParameters;
25
22
  clearElt?: HTMLDivElement;
23
+ inputElt?: HTMLInputElement;
26
24
  options?: StopFinderControlCommonOptions;
25
+ placeholder: string;
26
+ suggestionsElt?: HTMLElement;
27
27
  /**
28
28
  * Constructor.
29
29
  *
30
30
  * @param {Object} options Options
31
31
  * @param {HTMLElement} options.element HTML element where to attach input and suggestions.
32
32
  * @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/). See StopsAPI.
33
- * @param {string} [options.url='https://api.geops.io/tracker/v1'] Stops service url. See StopsAPI.
33
+ * @param {string} [options.url='https://api.geops.io/stops/v1/'] Stops service url. See StopsAPI.
34
34
  * @param {string} [options.placeholder='Search for a stop...'] Input field placeholder.
35
35
  * @param {StopsSearchParams} [options.apiParams={ limit: 20 }] Request parameters. See [Stops service documentation](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
36
36
  */
37
37
  constructor(options: StopFinderControlCommonOptions);
38
- render(featureCollection?: FeatureCollection): void;
39
- createElement({ element }: StopFinderControlCommonOptions): void;
40
38
  /**
41
39
  * Clear the search field and close the control.
42
40
  */
43
41
  clear(): void;
42
+ createElement({ element }: StopFinderControlCommonOptions): void;
43
+ render(featureCollection?: FeatureCollection): void;
44
44
  /**
45
45
  * Launch a search.
46
46
  *
47
- * @param {String} query The query to search for.
47
+ * @param {String} q The query to search for.
48
48
  * @param {AbortController} abortController Abort controller used to cancel the request.
49
49
  * @return {Promise<Array<GeoJSONFeature>>} An array of GeoJSON features with coordinates in [EPSG:4326](http://epsg.io/4326).
50
50
  */