mobility-toolbox-js 3.0.0-beta.8 → 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 (130) hide show
  1. package/README.md +11 -3
  2. package/api/HttpAPI.d.ts +20 -0
  3. package/api/HttpAPI.js +1 -14
  4. package/api/RealtimeAPI.d.ts +404 -0
  5. package/api/RealtimeAPI.js +265 -206
  6. package/api/RoutingAPI.d.ts +47 -0
  7. package/api/RoutingAPI.js +17 -7
  8. package/api/StopsAPI.d.ts +44 -0
  9. package/api/StopsAPI.js +17 -11
  10. package/api/WebSocketAPI.d.ts +147 -0
  11. package/api/WebSocketAPI.js +164 -165
  12. package/api/index.d.ts +3 -0
  13. package/api/index.js +1 -1
  14. package/api/typedefs.d.ts +76 -0
  15. package/api/typedefs.js +27 -42
  16. package/common/controls/StopFinderControlCommon.d.ts +53 -0
  17. package/common/controls/StopFinderControlCommon.js +32 -32
  18. package/common/index.d.ts +2 -0
  19. package/common/index.js +1 -1
  20. package/common/styles/index.d.ts +4 -0
  21. package/common/styles/realtimeDefaultStyle.d.ts +36 -0
  22. package/common/styles/realtimeDefaultStyle.js +6 -11
  23. package/common/styles/realtimeDelayStyle.d.ts +12 -0
  24. package/common/styles/realtimeHeadingStyle.d.ts +12 -0
  25. package/common/styles/realtimeHeadingStyle.js +5 -10
  26. package/common/styles/realtimeSimpleStyle.d.ts +3 -0
  27. package/common/styles/realtimeSimpleStyle.js +0 -1
  28. package/common/typedefs.d.ts +102 -0
  29. package/common/typedefs.js +6 -31
  30. package/common/utils/RealtimeEngine.d.ts +214 -0
  31. package/common/utils/RealtimeEngine.js +554 -0
  32. package/common/utils/compareDepartures.d.ts +10 -0
  33. package/common/utils/compareDepartures.js +2 -2
  34. package/common/utils/constants.d.ts +5 -0
  35. package/common/utils/createCanvas.d.ts +10 -0
  36. package/common/utils/createDefaultCopyrightElt.d.ts +5 -0
  37. package/common/utils/createDefaultStopFinderElt.d.ts +5 -0
  38. package/common/utils/createRealtimeFilters.d.ts +12 -0
  39. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  40. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  41. package/common/utils/getLayersAsFlatArray.d.ts +2 -0
  42. package/common/utils/getLayersAsFlatArray.js +0 -1
  43. package/common/utils/getMapGlCopyrights.d.ts +17 -0
  44. package/common/utils/getMapGlCopyrights.js +3 -3
  45. package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
  46. package/common/utils/getRealtimeModeSuffix.js +1 -0
  47. package/common/utils/getUrlWithParams.d.ts +8 -0
  48. package/common/utils/getVehiclePosition.d.ts +17 -0
  49. package/common/utils/getVehiclePosition.js +6 -3
  50. package/common/utils/index.d.ts +16 -0
  51. package/common/utils/realtimeConfig.d.ts +64 -0
  52. package/common/utils/realtimeConfig.js +0 -1
  53. package/common/utils/removeDuplicate.d.ts +9 -0
  54. package/common/utils/renderTrajectories.d.ts +17 -0
  55. package/common/utils/renderTrajectories.js +7 -6
  56. package/common/utils/sortAndFilterDepartures.d.ts +16 -0
  57. package/common/utils/sortAndFilterDepartures.js +2 -1
  58. package/common/utils/sortByDelay.d.ts +3 -0
  59. package/common/utils/sortByDelay.js +5 -1
  60. package/common/utils/timeUtils.d.ts +23 -0
  61. package/common/utils/toMercatorExtent.d.ts +5 -0
  62. package/iife.d.ts +2 -0
  63. package/index.d.ts +9 -0
  64. package/maplibre/controls/CopyrightControl.d.ts +38 -0
  65. package/maplibre/controls/CopyrightControl.js +11 -8
  66. package/maplibre/controls/index.d.ts +1 -0
  67. package/maplibre/index.d.ts +5 -0
  68. package/maplibre/layers/Layer.d.ts +29 -0
  69. package/maplibre/layers/Layer.js +2 -3
  70. package/maplibre/layers/RealtimeLayer.d.ts +124 -0
  71. package/maplibre/layers/RealtimeLayer.js +154 -118
  72. package/maplibre/layers/index.d.ts +2 -0
  73. package/maplibre/utils/getMercatorResolution.d.ts +7 -0
  74. package/maplibre/utils/getSourceCoordinates.d.ts +8 -0
  75. package/maplibre/utils/getSourceCoordinates.js +6 -5
  76. package/maplibre/utils/index.d.ts +2 -0
  77. package/mbt.js +14585 -14557
  78. package/mbt.js.map +4 -4
  79. package/mbt.min.js +75 -75
  80. package/mbt.min.js.map +4 -4
  81. package/ol/controls/CopyrightControl.d.ts +39 -0
  82. package/ol/controls/CopyrightControl.js +13 -5
  83. package/ol/controls/RoutingControl.d.ts +213 -0
  84. package/ol/controls/RoutingControl.js +250 -264
  85. package/ol/controls/StopFinderControl.d.ts +56 -0
  86. package/ol/controls/StopFinderControl.js +24 -5
  87. package/ol/controls/index.d.ts +3 -0
  88. package/ol/index.d.ts +6 -0
  89. package/ol/layers/Layer.d.ts +26 -0
  90. package/ol/layers/Layer.js +39 -0
  91. package/ol/layers/MaplibreLayer.d.ts +91 -0
  92. package/ol/layers/MaplibreLayer.js +154 -31
  93. package/ol/layers/MaplibreStyleLayer.d.ts +157 -0
  94. package/ol/layers/MaplibreStyleLayer.js +281 -210
  95. package/ol/layers/RealtimeLayer.d.ts +150 -0
  96. package/ol/layers/RealtimeLayer.js +210 -206
  97. package/ol/layers/VectorLayer.d.ts +17 -0
  98. package/ol/layers/VectorLayer.js +33 -0
  99. package/ol/layers/index.d.ts +5 -0
  100. package/ol/layers/index.js +3 -0
  101. package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -0
  102. package/ol/renderers/MaplibreLayerRenderer.js +142 -114
  103. package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
  104. package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
  105. package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
  106. package/ol/renderers/RealtimeLayerRenderer.js +50 -70
  107. package/ol/styles/fullTrajectoryDelayStyle.d.ts +6 -0
  108. package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
  109. package/ol/styles/fullTrajectoryStyle.d.ts +4 -0
  110. package/ol/styles/fullTrajectoryStyle.js +5 -7
  111. package/ol/styles/index.d.ts +3 -0
  112. package/ol/styles/routingStyle.d.ts +3 -0
  113. package/ol/styles/routingStyle.js +13 -10
  114. package/ol/utils/defineDeprecatedProperties.d.ts +10 -0
  115. package/ol/utils/defineDeprecatedProperties.js +180 -0
  116. package/ol/utils/getFeatureInfoAtCoordinate.d.ts +8 -0
  117. package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
  118. package/ol/utils/index.d.ts +1 -0
  119. package/package.json +44 -44
  120. package/setupTests.d.ts +1 -0
  121. package/setupTests.js +17 -4
  122. package/types/common.d.ts +53 -69
  123. package/types/index.d.ts +1 -1
  124. package/types/realtime.d.ts +98 -95
  125. package/types/routing.d.ts +60 -60
  126. package/types/stops.d.ts +62 -62
  127. package/common/mixins/RealtimeLayerMixin.js +0 -743
  128. package/ol/layers/MapGlLayer.js +0 -142
  129. package/ol/mixins/MobilityLayerMixin.js +0 -9
  130. package/ol/mixins/PropertiesLayerMixin.js +0 -142
package/README.md CHANGED
@@ -10,7 +10,7 @@ The tools in this library have been inspired by many projects realized for publi
10
10
 
11
11
  ## Documentation and examples
12
12
 
13
- Visit https://mobility-toolbox-js.vercel.app/
13
+ Visit https://mobility-toolbox-js.geops.io/
14
14
 
15
15
  ## Demos
16
16
 
@@ -24,7 +24,7 @@ Visit https://mobility-toolbox-js.vercel.app/
24
24
  Install the library and the peer dependencies:
25
25
 
26
26
  ```bash
27
- yarn add mobility-toolbox-js ol maplibre-gl
27
+ yarn add ol maplibre-gl mobility-toolbox-js
28
28
  ```
29
29
 
30
30
  ## Development
@@ -34,9 +34,17 @@ yarn install
34
34
  yarn dev
35
35
  ```
36
36
 
37
+ `yarn dev` starts a vite server using the `index.html` file at the root of the project.
38
+ This html file loads the `dev.js` file. Use this file to develop the library.
39
+ Each time you modifiy the library code you have to run `yarn build:tsc` to see the changes.
40
+
41
+ ## Development documentation
42
+
43
+ The documentations website is located in the `doc/` folder.
44
+ It's a nextJS website that use the mobility-toolbox-js library built from the `build/` folder.
45
+
37
46
  ## Deploy
38
47
 
39
48
  This library website is deployed automatically using [Vercel](https://vercel.com/geops).
40
49
  For Vercel we have to add the nextjs and raw-loader modules in the dev dependencies of the main package.json.
41
50
  But those 2 librairies are not needed to build the library.
42
-
@@ -0,0 +1,20 @@
1
+ export interface HttpAPIOptions {
2
+ apiKey?: string;
3
+ url: string;
4
+ }
5
+ /**
6
+ * Common class to access to a geOps api using http.
7
+ * @private
8
+ */
9
+ declare class HttpAPI {
10
+ apiKey?: string;
11
+ url: string;
12
+ constructor(options: HttpAPIOptions);
13
+ /**
14
+ * Append the apiKey before sending the request.
15
+ *
16
+ * @private
17
+ */
18
+ fetch(path: string, params: object, config: RequestInit): Promise<any>;
19
+ }
20
+ export default HttpAPI;
package/api/HttpAPI.js CHANGED
@@ -10,24 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import getUrlWithParams from '../common/utils/getUrlWithParams';
11
11
  /**
12
12
  * Common class to access to a geOps api using http.
13
- *
14
- * @example
15
- * import { API } from 'mobility-toolbox-js/api';
16
- *
17
- * const api = new HttpApi({
18
- * url: [yourUrl],
19
- * apiKey: [yourApiKey]
20
- * });
21
- *
22
- * @classproperty {string} url Url of the service.
23
- * @classproperty {string} apiKey Api key to access the service.
24
13
  * @private
25
14
  */
26
15
  class HttpAPI {
27
16
  constructor(options) {
28
- /** @private */
29
17
  this.url = options.url;
30
- /** @private */
31
18
  this.apiKey = options.apiKey;
32
19
  }
33
20
  /**
@@ -40,7 +27,7 @@ class HttpAPI {
40
27
  if (!this.url) {
41
28
  throw new Error(`No url defined for request to ${this.url}/${path}`);
42
29
  }
43
- if (!this.url && !this.apiKey && !/key=/.test(this.url)) {
30
+ if (!this.url && !this.apiKey && !this.url.includes('key=')) {
44
31
  // eslint-disable-next-line no-console
45
32
  throw new Error(`No apiKey defined for request to ${this.url}`);
46
33
  }
@@ -0,0 +1,404 @@
1
+ import WebSocketAPI, { WebSocketAPIMessageCallback, WebSocketAPIMessageEventData, WebSocketAPIParameters } from './WebSocketAPI';
2
+ import type { RealtimeBbox, RealtimeDeparture, RealtimeExtraGeom, RealtimeFullTrajectory, RealtimeGeneralizationLevel, RealtimeMode, RealtimeNews, RealtimeStation, RealtimeStationId, RealtimeStopSequence, RealtimeTenant, RealtimeTrainId, RealtimeTrajectory, RealtimeVersion } from '../types';
3
+ /**
4
+ * @typedef RealtimeAPIOptions
5
+ */
6
+ export interface RealtimeAPIOptions {
7
+ apiKey?: string;
8
+ bbox?: RealtimeBbox;
9
+ buffer?: number[];
10
+ pingIntervalMs?: number;
11
+ reconnectTimeoutMs?: number;
12
+ url?: string;
13
+ version?: RealtimeVersion;
14
+ }
15
+ export type RealtimeAPIExtraGeomsById = Record<string, RealtimeExtraGeom>;
16
+ export type RealtimeAPIDeparturesById = Record<string, RealtimeDeparture>;
17
+ export interface RealtimeModesType {
18
+ RAW: RealtimeMode;
19
+ SCHEMATIC: RealtimeMode;
20
+ TOPOGRAPHIC: RealtimeMode;
21
+ }
22
+ /**
23
+ * Enum for Realtime modes.
24
+ * @readonly
25
+ * @typedef {string} RealtimeMode
26
+ * @property {string} RAW "raw"
27
+ * @property {string} SCHEMATIC "schematic"
28
+ * @property {string} TOPOGRAPHIC "topographic"
29
+ * @enum {RealtimeMode}
30
+ * @public
31
+ */
32
+ export declare const RealtimeModes: {
33
+ RAW: RealtimeMode;
34
+ SCHEMATIC: RealtimeMode;
35
+ TOPOGRAPHIC: RealtimeMode;
36
+ };
37
+ /**
38
+ * This class provides convenience methods to use to the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
39
+ *
40
+ * @example
41
+ * import { RealtimeAPI } from 'mobility-toolbox-js/api';
42
+ *
43
+ * const api = new RealtimeAPI({
44
+ * apiKey: "yourApiKey",
45
+ * bbox: [782001, 5888803, 923410, 5923660, 11, "mots=rail"],
46
+ * // url: "wss://api.geops.io/tracker-ws/v1/",
47
+ * });
48
+ *
49
+ * // Open the websocket connection
50
+ * api.open();
51
+ *
52
+ * // Subscribe to channel
53
+ * api.subscribeTrajectory('topographic', (data) => {
54
+ * console.log('Log trajectories:', JSON.stringify(data.content));
55
+ * });
56
+ *
57
+ * // Close the websocket connection
58
+ * api.close();
59
+ *
60
+ * @public
61
+ */
62
+ declare class RealtimeAPI {
63
+ _bbox?: RealtimeBbox;
64
+ _buffer?: number[];
65
+ _url: string;
66
+ version: RealtimeVersion;
67
+ wsApi: WebSocketAPI;
68
+ /**
69
+ * This callback type is called `requestCallback` and is displayed as a global symbol.
70
+ *
71
+ * @callback onFullTrajectoryMessageCallback
72
+ * @param {number} responseCode
73
+ * @param {string} responseMessage
74
+ */
75
+ /**
76
+ * The bounding box to receive data from.\
77
+ * Example: [minX, minY, maxX, maxY, zoom, mots , gen_level, tenant, ...]\
78
+ * &nbsp;\
79
+ * Where:
80
+ * - **minX**: a string representation of an integer (not a float) representing the minimal X coordinate (in EPSG:3857) of a bounding box\
81
+ * &nbsp;
82
+ * - **minY**: a string representation of an integer (not a float) representing the minimal Y coordinate (in EPSG:3857) of a bounding box\
83
+ * &nbsp;
84
+ * - **maxX**: a string representation of an integer (not a float) representing the maximal X coordinate (in EPSG:3857) of a bounding box\
85
+ * &nbsp;
86
+ * - **maxY**: a string representation of an integer (not a float) representing the maximal Y coordinate (in EPSG:3857) of a bounding box\
87
+ * &nbsp;
88
+ * - **zoom**: a string representation of an integer representing the zoom level (from 4 to 22). When zoom < 8 only the trains are displayed for performance reasons.\
89
+ * &nbsp;
90
+ * - **mots**: A comma separated list of modes of transport. **Optional**.\
91
+ * Example: "mots=rail,subway".\
92
+ * &nbsp;
93
+ * - **gen_level**: An integer representing the generalization level. **Optional**.\
94
+ * Example: "gen_level=5"\
95
+ * &nbsp;
96
+ * - **tenant**: A string representing the tenant. **Optional**.\
97
+ * Example: "tenant=sbb"\
98
+ * &nbsp;
99
+ * - ...: Any other values added to the bbox will be send to the server
100
+ *
101
+ * @type {string[]}
102
+ *
103
+ * @public
104
+ */
105
+ get bbox(): RealtimeBbox | undefined;
106
+ set bbox(newBbox: RealtimeBbox | undefined);
107
+ get buffer(): number[] | undefined;
108
+ set buffer(newBuffer: number[] | undefined);
109
+ get url(): string;
110
+ set url(newUrl: string);
111
+ private pingInterval;
112
+ private pingIntervalMs;
113
+ private reconnectTimeout?;
114
+ private reconnectTimeoutMs?;
115
+ /**
116
+ * Constructor
117
+ *
118
+ * @param {Object} options Options.
119
+ * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
120
+ * @param {string[]} options.bbox The bounding box to receive data from.
121
+ * @param {string} [options.url='wss://api.geops.io/tracker-ws/v1/'] Url of the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
122
+ * @public
123
+ */
124
+ constructor(options?: RealtimeAPIOptions);
125
+ /**
126
+ * Close the websocket connection without reconnection.
127
+ *
128
+ * @public
129
+ */
130
+ close(): void;
131
+ /**
132
+ * Send GET to a channel.
133
+ *
134
+ * @param {string | WebSocketAPIParameters} channelOrParams Name of the websocket channel to send GET or an object representing parameters to send
135
+ * @return {Promise<WebSocketAPIMessageEventData<?>>} A websocket response.
136
+ * @public
137
+ */
138
+ get(channelOrParams: string | WebSocketAPIParameters): Promise<WebSocketAPIMessageEventData<any>>;
139
+ /**
140
+ * Get a full trajectory of a vehicule .
141
+ *
142
+ * @param {string} id A vehicle id.
143
+ * @param {RealtimeMode} mode Realtime mode.
144
+ * @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
145
+ * @return {Promise<{data: { content: RealtimeFullTrajectory }}>} Return a full trajectory.
146
+ * @public
147
+ */
148
+ getFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, generalizationLevel: RealtimeGeneralizationLevel | undefined): Promise<WebSocketAPIMessageEventData<RealtimeFullTrajectory>>;
149
+ /**
150
+ * Return a station with a given uic number and a mode.
151
+ *
152
+ * @param {number} uic UIC of the station.
153
+ * @param {RealtimeMode} mode Realtime mode.
154
+ * @return {Promise<{data: { content: RealtimeStation }}>} A station.
155
+ * @public
156
+ */
157
+ getStation(uic: RealtimeStationId, mode: RealtimeMode): Promise<WebSocketAPIMessageEventData<RealtimeStation>>;
158
+ /**
159
+ * Get the list of ststions available for a specifc mode. The promise is resolved every 100ms
160
+ * @param {RealtimeMode} mode Realtime mode.
161
+ * @param {number} timeout = 100 Duration in ms between each promise resolve calls.
162
+ * @return {Promise<RealtimeStation[]>} An array of stations.
163
+ * @public
164
+ */
165
+ getStations(mode: RealtimeMode, timeout?: number): Promise<RealtimeStation[]>;
166
+ /**
167
+ * Get the list of stops for this vehicle.
168
+ *
169
+ * @param {string} id A vehicle id.
170
+ * @return {Promise<{data: { content: RealtimeStopSequence[] }}>} Returns a stop sequence object.
171
+ * @public
172
+ */
173
+ getStopSequence(id: RealtimeTrainId): Promise<WebSocketAPIMessageEventData<RealtimeStopSequence[]>>;
174
+ /**
175
+ * Return a partial trajectory with a given id and a mode.
176
+ *
177
+ * @param {number} id The identifier of a trajectory.
178
+ * @param {RealtimeMode} mode Realtime mode.
179
+ * @return {Promise<{data: { content: RealtimeTrajectory }}>} A trajectory.
180
+ * @public
181
+ */
182
+ getTrajectory(id: RealtimeTrainId, mode: RealtimeMode): Promise<WebSocketAPIMessageEventData<RealtimeTrajectory>>;
183
+ /**
184
+ * Callback when the websocket is closed by the server.
185
+ * It auto reconnects after a timeout.
186
+ * @private
187
+ */
188
+ onClose(): void;
189
+ /**
190
+ * Callback when the websocket is opened and ready.
191
+ * It applies the bbox and the projection.
192
+ * @private
193
+ */
194
+ onOpen(): void;
195
+ /**
196
+ * Open the websocket connection.
197
+ *
198
+ * @public
199
+ */
200
+ open(): void;
201
+ /**
202
+ * Unsubscribe trajectory and deleted_vehicles channels. To resubscribe you have to set a new BBOX.
203
+ */
204
+ reset(): void;
205
+ /**
206
+ * Subscribe to a channel.
207
+ *
208
+ * @param {string} channel Name of the websocket channel to subscribe.
209
+ * @param {function} onSuccess Callback when the subscription succeeds.
210
+ * @param {function} onError Callback when the subscription fails.
211
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
212
+ * @public
213
+ */
214
+ subscribe(channel: string, onSuccess: WebSocketAPIMessageCallback<any>, onError?: EventListener, quiet?: boolean): void;
215
+ /**
216
+ * Subscribe to deleted_vhicles channel.
217
+ *
218
+ * @param {RealtimeMode} mode Realtime mode.
219
+ * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
220
+ * @param {function} onError Callback when the subscription fails.
221
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
222
+ * @public
223
+ */
224
+ subscribeDeletedVehicles(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrainId>, onError?: EventListener, quiet?: boolean): void;
225
+ /**
226
+ * Subscribe to departures channel of a given station.
227
+ *
228
+ * @param {number} stationId UIC of the station.
229
+ * @param {function(departures: RealtimeDeparture[])} onMessage Function called on each message of the channel.
230
+ * @param {function} onError Callback when the subscription fails.
231
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
232
+ * @deprecated Use subscribeTimetable instead.
233
+ */
234
+ subscribeDepartures(stationId: number, onMessage: WebSocketAPIMessageCallback<RealtimeDeparture>, onError?: EventListener, quiet?: boolean): void;
235
+ /**
236
+ * Subscribe to the disruptions channel for tenant.
237
+ *
238
+ * @param {RealtimeTenant} tenant Tenant's id
239
+ * @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
240
+ * @param {function} onError Callback when the subscription fails.
241
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
242
+ * @deprecated Use subscribeNewsticker instead.
243
+ */
244
+ subscribeDisruptions(tenant: RealtimeTenant, onMessage: WebSocketAPIMessageCallback<RealtimeNews>, onError?: EventListener, quiet?: boolean): void;
245
+ /**
246
+ * Subscribe to extra_geoms channel.
247
+ *
248
+ * @param {function(data: { content: RealtimeExtraGeom })} onMessage Function called on each message of the channel.
249
+ * @param {function} onError Callback when the subscription fails.
250
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
251
+ */
252
+ subscribeExtraGeoms(onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>, onError?: EventListener, quiet?: boolean): void;
253
+ /**
254
+ * Subscribe to full_trajectory channel of a given vehicle.
255
+ *
256
+ * @param {string} id A vehicle id.
257
+ * @param {RealtimeMode} mode Realtime mode.
258
+ * @param {function(data:{content: RealtimeFullTrajectory})} onMessage Function called on each message of the channel.
259
+ * @param {function} onError Callback when the subscription fails.
260
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
261
+ * @public
262
+ */
263
+ subscribeFullTrajectory(id: RealtimeTrainId, mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeFullTrajectory>, onError?: EventListener, quiet?: boolean): void;
264
+ /**
265
+ * Subscribe to healthcheck channel.
266
+ * @param {function(data: { content: string })} onMessage Callback when the subscribe to healthcheck channel succeeds.
267
+ * @param {function} onError Callback when the subscription fails.
268
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
269
+ */
270
+ subscribeHealthCheck(onMessage: WebSocketAPIMessageCallback<string>, onError?: EventListener, quiet?: boolean): void;
271
+ /**
272
+ * Subscribe to the newsticker channel for tenant.
273
+ *
274
+ * @param {RealtimeTenant} tenant Tenant's id
275
+ * @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
276
+ * @param {function} onError Callback when the subscription fails.
277
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
278
+ * @public
279
+ */
280
+ subscribeNewsticker(tenant: RealtimeTenant, onMessage: WebSocketAPIMessageCallback<RealtimeNews>, onError?: EventListener, quiet?: boolean): void;
281
+ /**
282
+ * Subscribe to stations channel.
283
+ * One message pro station.
284
+ *
285
+ * @param {RealtimeMode} mode Realtime mode.
286
+ * @param {function(data: { content: RealtimeStation })} onMessage Function called on each message of the channel.
287
+ * @param {function} onError Callback when the subscription fails.
288
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
289
+ * @public
290
+ */
291
+ subscribeStations(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeStation>, onError?: EventListener, quiet?: boolean): void;
292
+ /**
293
+ * Subscribe to stopsequence channel of a given vehicle.
294
+ *
295
+ * @param {string} id A vehicle id.
296
+ * @param {function(data: { content: RealtimeStopSequence[] })} onMessage Function called on each message of the channel.
297
+ * @param {function} onError Callback when the subscription fails.
298
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
299
+ * @public
300
+ */
301
+ subscribeStopSequence(id: RealtimeTrainId, onMessage: WebSocketAPIMessageCallback<RealtimeStopSequence[]>, onError?: EventListener, quiet?: boolean): void;
302
+ /**
303
+ * Subscribe to timetable channel of a given station.
304
+ *
305
+ * @param {number} stationId UIC of the station.
306
+ * @param {function(departures: RealtimeDeparture[])} onMessage Function called on each message of the channel.
307
+ * @param {function} onError Callback when the subscription fails.
308
+ * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
309
+ * @public
310
+ */
311
+ subscribeTimetable(stationId: number, onMessage: WebSocketAPIMessageCallback<RealtimeDeparture>, onError?: EventListener, quiet?: boolean): void;
312
+ /**
313
+ * Subscribe to trajectory channel.
314
+ *
315
+ * @param {RealtimeMode} mode Realtime mode.
316
+ * @param {function(data: { content: RealtimeTrajectory })} 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.
319
+ * @public
320
+ */
321
+ subscribeTrajectory(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrajectory>, onError?: EventListener, quiet?: boolean): void;
322
+ /**
323
+ * Unsubscribe both modes of a channel.
324
+ *
325
+ * @param {string} channel Name of the websocket channel to unsubscribe.
326
+ * @param {string} suffix Suffix to add to the channel name.
327
+ * @param {function} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
328
+ * @public
329
+ */
330
+ unsubscribe(channel: string, suffix?: string, onMessage?: WebSocketAPIMessageCallback<any>): void;
331
+ /**
332
+ * Unsubscribe to deleted_vhicles channels.
333
+ * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
334
+ * @public
335
+ */
336
+ unsubscribeDeletedVehicles(onMessage: WebSocketAPIMessageCallback<RealtimeTrainId>): void;
337
+ /**
338
+ * Unsubscribe from current departures channel.
339
+ * @param {number} stationId UIC of the station.
340
+ * @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
341
+ * @deprecated Use RealtimeAPI.unsubscribeTimetabe instead.
342
+ */
343
+ unsubscribeDepartures(stationId: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
344
+ /**
345
+ * Unsubscribe disruptions.
346
+ * @param {RealtimeTenant} tenant Tenant's id
347
+ * @param {Function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
348
+ * @deprecated Use unsubscribeNewsticker instead.
349
+ */
350
+ unsubscribeDisruptions(tenant: RealtimeTenant, onMessage?: WebSocketAPIMessageCallback<RealtimeNews>): void;
351
+ /**
352
+ * Unsubscribe to extra_geoms channel.
353
+ * @param {function(data: { content: RealtimeExtraGeom })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
354
+ */
355
+ unsubscribeExtraGeoms(onMessage: WebSocketAPIMessageCallback<RealtimeExtraGeom>): void;
356
+ /**
357
+ * Unsubscribe from full_trajectory channel
358
+ *
359
+ * @param {string} id A vehicle id.
360
+ * @param {onFullTrajectoryMessageCallback} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
361
+ * @public
362
+ */
363
+ unsubscribeFullTrajectory(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<RealtimeFullTrajectory>): void;
364
+ /**
365
+ * Unsubscribe to healthcheck channel.
366
+ * @param {function(data: { content: string })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
367
+ */
368
+ unsubscribeHealthCheck(onMessage?: WebSocketAPIMessageCallback<string>): void;
369
+ /**
370
+ * Unsubscribe disruptions.
371
+ * @param {RealtimeTenant} tenant Tenant's id
372
+ * @param {Function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
373
+ * @public
374
+ */
375
+ unsubscribeNewsticker(tenant: RealtimeTenant, onMessage?: WebSocketAPIMessageCallback<RealtimeNews>): void;
376
+ /**
377
+ * Unsubscribe to stations channel.
378
+ * @param {function(data: { content: RealtimeStation })} onMessage The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
379
+ * @public
380
+ */
381
+ unsubscribeStations(onMessage?: WebSocketAPIMessageCallback<RealtimeStation>): void;
382
+ /**
383
+ * Unsubscribe from stopsequence channel
384
+ *
385
+ * @param {string} id A vehicle id.
386
+ * @param {function(data: { content: RealtimeStopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
387
+ * @public
388
+ */
389
+ unsubscribeStopSequence(id: RealtimeTrainId, onMessage?: WebSocketAPIMessageCallback<RealtimeStopSequence[]>): void;
390
+ /**
391
+ * Unsubscribe from current departures channel.
392
+ * @param {number} stationId UIC of the station.
393
+ * @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
394
+ * @public
395
+ */
396
+ unsubscribeTimetable(stationId: RealtimeStationId, onMessage?: WebSocketAPIMessageCallback<RealtimeDeparture>): void;
397
+ /**
398
+ * Unsubscribe to trajectory channels.
399
+ * @param {function(data: { content: RealtimeTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
400
+ * @public
401
+ */
402
+ unsubscribeTrajectory(onMessage: WebSocketAPIMessageCallback<RealtimeTrajectory>): void;
403
+ }
404
+ export default RealtimeAPI;