mobility-toolbox-js 3.0.0-beta.9 → 3.0.1-beta.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 (87) hide show
  1. package/api/HttpAPI.d.ts +5 -16
  2. package/api/HttpAPI.js +0 -11
  3. package/api/RealtimeAPI.d.ts +221 -176
  4. package/api/RealtimeAPI.js +317 -258
  5. package/api/RoutingAPI.d.ts +21 -11
  6. package/api/RoutingAPI.js +17 -7
  7. package/api/StopsAPI.d.ts +20 -14
  8. package/api/StopsAPI.js +17 -11
  9. package/api/WebSocketAPI.d.ts +60 -66
  10. package/api/WebSocketAPI.js +164 -164
  11. package/api/index.js +1 -1
  12. package/api/typedefs.d.ts +0 -102
  13. package/api/typedefs.js +27 -42
  14. package/common/controls/StopFinderControlCommon.d.ts +12 -12
  15. package/common/controls/StopFinderControlCommon.js +31 -31
  16. package/common/index.d.ts +1 -1
  17. package/common/index.js +1 -1
  18. package/common/mixins/RealtimeLayerMixin.d.ts +157 -163
  19. package/common/mixins/RealtimeLayerMixin.js +401 -393
  20. package/common/styles/realtimeDefaultStyle.js +6 -6
  21. package/common/styles/realtimeHeadingStyle.js +5 -5
  22. package/common/typedefs.d.ts +13 -6
  23. package/common/typedefs.js +7 -1
  24. package/common/utils/compareDepartures.d.ts +2 -2
  25. package/common/utils/compareDepartures.js +2 -2
  26. package/common/utils/debounceWebsocketMessages.d.ts +1 -1
  27. package/common/utils/getMapGlCopyrights.d.ts +1 -1
  28. package/common/utils/getMapGlCopyrights.js +3 -3
  29. package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
  30. package/common/utils/getRealtimeModeSuffix.js +1 -0
  31. package/common/utils/getVehiclePosition.d.ts +5 -4
  32. package/common/utils/getVehiclePosition.js +9 -3
  33. package/common/utils/renderTrajectories.d.ts +1 -1
  34. package/common/utils/renderTrajectories.js +6 -6
  35. package/common/utils/sortAndFilterDepartures.d.ts +1 -1
  36. package/common/utils/sortAndFilterDepartures.js +1 -1
  37. package/common/utils/sortByDelay.d.ts +2 -2
  38. package/common/utils/sortByDelay.js +5 -1
  39. package/maplibre/layers/Layer.d.ts +1 -1
  40. package/maplibre/layers/Layer.js +1 -1
  41. package/maplibre/layers/RealtimeLayer.d.ts +87 -66
  42. package/maplibre/layers/RealtimeLayer.js +30 -6
  43. package/maplibre/utils/getSourceCoordinates.js +5 -5
  44. package/mbt.js +20988 -13287
  45. package/mbt.js.map +4 -4
  46. package/mbt.min.js +61 -58
  47. package/mbt.min.js.map +4 -4
  48. package/ol/controls/RoutingControl.d.ts +82 -89
  49. package/ol/controls/RoutingControl.js +217 -219
  50. package/ol/controls/StopFinderControl.d.ts +3 -3
  51. package/ol/controls/StopFinderControl.js +2 -2
  52. package/ol/index.d.ts +1 -0
  53. package/ol/index.js +1 -0
  54. package/ol/layers/Layer.d.ts +101 -0
  55. package/ol/layers/Layer.js +25 -0
  56. package/ol/layers/MaplibreLayer.d.ts +121 -24
  57. package/ol/layers/MaplibreLayer.js +98 -27
  58. package/ol/layers/MaplibreStyleLayer.d.ts +93 -91
  59. package/ol/layers/MaplibreStyleLayer.js +281 -257
  60. package/ol/layers/RealtimeLayer.d.ts +119 -121
  61. package/ol/layers/RealtimeLayer.js +143 -134
  62. package/ol/layers/VectorLayer.d.ts +18 -0
  63. package/ol/layers/VectorLayer.js +32 -0
  64. package/ol/layers/index.d.ts +2 -0
  65. package/ol/layers/index.js +3 -0
  66. package/ol/mixins/MobilityLayerMixin.d.ts +32 -34
  67. package/ol/mixins/PropertiesLayerMixin.d.ts +60 -51
  68. package/ol/mixins/PropertiesLayerMixin.js +114 -79
  69. package/ol/mixins/index.d.ts +1 -0
  70. package/ol/mixins/index.js +2 -0
  71. package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
  72. package/ol/renderers/MaplibreLayerRenderer.js +142 -114
  73. package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
  74. package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
  75. package/ol/renderers/RealtimeLayerRenderer.d.ts +6 -6
  76. package/ol/renderers/RealtimeLayerRenderer.js +56 -51
  77. package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
  78. package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
  79. package/package.json +31 -31
  80. package/setupTests.js +3 -4
  81. package/types/common.d.ts +55 -48
  82. package/types/index.d.ts +1 -1
  83. package/types/realtime.d.ts +91 -93
  84. package/types/routing.d.ts +60 -60
  85. package/types/stops.d.ts +62 -62
  86. package/ol/layers/MapGlLayer.d.ts +0 -144
  87. package/ol/layers/MapGlLayer.js +0 -144
@@ -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
  *
@@ -109,65 +84,94 @@ class WebSocketAPI {
109
84
  this.subscribePreviousSubscriptions();
110
85
  }
111
86
  }
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
- }
87
+ defineProperties() {
88
+ Object.defineProperties(this, {
89
+ closed: {
90
+ get: () => !!(!this.websocket ||
91
+ this.websocket.readyState === this.websocket.CLOSED),
92
+ },
93
+ closing: {
94
+ get: () => !!(this.websocket &&
95
+ this.websocket.readyState === this.websocket.CLOSING),
96
+ },
97
+ connecting: {
98
+ get: () => !!(this.websocket &&
99
+ this.websocket.readyState === this.websocket.CONNECTING),
100
+ },
101
+ /**
102
+ * Array of message to send on open.
103
+ * @type {Array<string>}
104
+ * @private
105
+ */
106
+ messagesOnOpen: {
107
+ value: [],
108
+ writable: true,
109
+ },
110
+ open: {
111
+ get: () => !!(this.websocket && this.websocket.readyState === this.websocket.OPEN),
112
+ },
113
+ /**
114
+ * List of channels subscribed.
115
+ * @type {WebSocketSubscribed}
116
+ * @private
117
+ */
118
+ subscribed: {
119
+ value: {},
120
+ writable: true,
121
+ },
122
+ /**
123
+ * Array of subscriptions.
124
+ * @type {Array<WebSocketSubscription>}
125
+ * @private
126
+ */
127
+ subscriptions: {
128
+ value: [],
129
+ writable: true,
130
+ },
131
+ });
123
132
  }
124
133
  /**
125
- * Sends a message to the websocket.
134
+ * Sends a get request to the websocket.
135
+ * The callback is called only once, when the response is received or when the call returns an error.
126
136
  *
127
- * @param {message} message Message to send.
137
+ * @param {Object} params Parameters for the websocket get request
138
+ * @param {function} cb callback on message event
139
+ * @param {function} errorCb Callback on error and close event
128
140
  * @private
129
141
  */
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);
142
+ get(params, cb, errorCb) {
143
+ const requestString = WebSocketAPI.getRequestString('GET', params);
144
+ this.send(requestString);
145
+ // We wrap the callbacks to make sure they are called only once.
146
+ const once = (callback) =>
147
+ // @ts-expect-error : Spread error
148
+ (...args) => {
149
+ // @ts-expect-error : Spread error
150
+ callback(...args);
151
+ const index = this.requests.findIndex((request) => requestString === request.requestString && cb === request.cb);
152
+ const { onErrorCb, onMessageCb } = this.requests[index];
153
+ this.removeEvents(onMessageCb, onErrorCb);
154
+ this.requests.splice(index, 1);
137
155
  };
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();
156
+ const { onErrorCb, onMessageCb } = this.listen(params, once(cb), errorCb && once(errorCb));
157
+ // Store requests and callbacks to be able to remove them.
158
+ if (!this.requests) {
159
+ this.requests = [];
153
160
  }
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
- }
161
+ const index = this.requests.findIndex((request) => requestString === request.requestString && cb === request.cb);
162
+ const newReq = {
163
+ cb,
164
+ errorCb,
165
+ onErrorCb,
166
+ onMessageCb,
167
+ params,
168
+ requestString,
169
+ };
170
+ if (index > -1) {
171
+ this.requests[index] = newReq;
162
172
  }
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
- }
173
+ else {
174
+ this.requests.push(newReq);
171
175
  }
172
176
  }
173
177
  /**
@@ -213,64 +217,46 @@ class WebSocketAPI {
213
217
  });
214
218
  };
215
219
  this.addEvents(onMessage, errorCb);
216
- return { onMessageCb: onMessage, onErrorCb: errorCb };
220
+ return { onErrorCb: errorCb, onMessageCb: onMessage };
217
221
  }
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
- });
222
+ removeEvents(onMessage, onError) {
223
+ if (this.websocket) {
224
+ this.websocket.removeEventListener('message', onMessage);
225
+ if (onError) {
226
+ this.websocket.removeEventListener('error', onError);
227
+ this.websocket.removeEventListener('close', onError);
228
+ }
229
+ }
231
230
  }
232
231
  /**
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.
232
+ * Sends a message to the websocket.
235
233
  *
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
234
+ * @param {message} message Message to send.
239
235
  * @private
240
236
  */
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 = [];
237
+ send(message) {
238
+ if (!this.websocket || this.closed || this.closing) {
239
+ return;
259
240
  }
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,
241
+ const send = () => {
242
+ var _a;
243
+ (_a = this.websocket) === null || _a === void 0 ? void 0 : _a.send(message);
268
244
  };
269
- if (index > -1) {
270
- this.requests[index] = newReq;
245
+ if (!this.open) {
246
+ // This 'if' avoid sending 2 identical BBOX message on open,
247
+ if (!this.messagesOnOpen.includes(message)) {
248
+ this.messagesOnOpen.push(message);
249
+ this.websocket.addEventListener('open', () => {
250
+ this.messagesOnOpen = [];
251
+ send();
252
+ });
253
+ this.websocket.addEventListener('close', () => {
254
+ this.messagesOnOpen = [];
255
+ });
256
+ }
271
257
  }
272
- else {
273
- this.requests.push(newReq);
258
+ else if (!this.messagesOnOpen.includes(message)) {
259
+ send();
274
260
  }
275
261
  }
276
262
  /**
@@ -283,10 +269,10 @@ class WebSocketAPI {
283
269
  * @private
284
270
  */
285
271
  subscribe(params, cb, errorCb, quiet = false) {
286
- const { onMessageCb, onErrorCb } = this.listen(params, cb, errorCb);
272
+ const { onErrorCb, onMessageCb } = this.listen(params, cb, errorCb);
287
273
  const reqStr = WebSocketAPI.getRequestString('', params);
288
274
  const index = this.subscriptions.findIndex((subcr) => params.channel === subcr.params.channel && cb === subcr.cb);
289
- const newSubscr = { params, cb, errorCb, onMessageCb, onErrorCb, quiet };
275
+ const newSubscr = { cb, errorCb, onErrorCb, onMessageCb, params, quiet };
290
276
  if (index > -1) {
291
277
  this.subscriptions[index] = newSubscr;
292
278
  }
@@ -301,6 +287,35 @@ class WebSocketAPI {
301
287
  this.subscribed[reqStr] = true;
302
288
  }
303
289
  }
290
+ /**
291
+ * After an auto reconnection we need to re-subscribe to the channels.
292
+ */
293
+ subscribePreviousSubscriptions() {
294
+ // Before to subscribe previous subscriptions we make sure they
295
+ // are all defined as unsubscribed, because this code is asynchrone
296
+ // and a subscription could have been added in between.
297
+ Object.keys(this.subscribed).forEach((key) => {
298
+ this.subscribed[key] = false;
299
+ });
300
+ // Subscribe all previous subscriptions.
301
+ [...this.subscriptions].forEach((s) => {
302
+ this.subscribe(s.params, s.cb, s.errorCb, s.quiet);
303
+ });
304
+ }
305
+ /**
306
+ * Unlisten websocket messages.
307
+ *
308
+ * @param {Object} params Parameters for the websocket get request.
309
+ * @param {function} cb Callback used when listen.
310
+ * @private
311
+ */
312
+ unlisten(params, cb) {
313
+ [...(this.subscriptions || []), ...(this.requests || [])]
314
+ .filter((s) => s.params.channel === params.channel && (!cb || s.cb === cb))
315
+ .forEach(({ onErrorCb, onMessageCb }) => {
316
+ this.removeEvents(onMessageCb, onErrorCb);
317
+ });
318
+ }
304
319
  /**
305
320
  * Unsubscribe from a channel.
306
321
  * @param {string} source source to unsubscribe from
@@ -309,7 +324,7 @@ class WebSocketAPI {
309
324
  */
310
325
  unsubscribe(source, cb) {
311
326
  const toRemove = this.subscriptions.filter((s) => s.params.channel === source && (!cb || s.cb === cb));
312
- toRemove.forEach(({ onMessageCb, onErrorCb }) => {
327
+ toRemove.forEach(({ onErrorCb, onMessageCb }) => {
313
328
  this.removeEvents(onMessageCb, onErrorCb);
314
329
  });
315
330
  this.subscriptions = this.subscriptions.filter((s) => s.params.channel !== source || (cb && s.cb !== cb));
@@ -323,20 +338,5 @@ class WebSocketAPI {
323
338
  this.subscribed[source] = false;
324
339
  }
325
340
  }
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
341
  }
342
342
  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,14 +16,14 @@ 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
  *
@@ -35,16 +35,16 @@ declare class StopFinderControlCommon {
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
  */