mobility-toolbox-js 3.1.1-beta.7 → 3.1.1

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.
package/api/HttpAPI.d.ts CHANGED
@@ -15,6 +15,6 @@ declare class HttpAPI {
15
15
  *
16
16
  * @private
17
17
  */
18
- fetch<T>(path: string, params: object, config: RequestInit): Promise<T>;
18
+ fetch(path: string, params: object, config: RequestInit): Promise<any>;
19
19
  }
20
20
  export default HttpAPI;
@@ -135,7 +135,7 @@ declare class RealtimeAPI {
135
135
  * @return {Promise<WebSocketAPIMessageEventData<?>>} A websocket response.
136
136
  * @public
137
137
  */
138
- get<T>(channelOrParams: string | WebSocketAPIParameters): Promise<WebSocketAPIMessageEventData<T>>;
138
+ get(channelOrParams: string | WebSocketAPIParameters): Promise<WebSocketAPIMessageEventData<any>>;
139
139
  /**
140
140
  * Get a full trajectory of a vehicule .
141
141
  *
@@ -211,7 +211,7 @@ declare class RealtimeAPI {
211
211
  * @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
212
212
  * @public
213
213
  */
214
- subscribe<T>(channel: string, onSuccess: WebSocketAPIMessageCallback<T>, onError?: EventListener, quiet?: boolean): void;
214
+ subscribe(channel: string, onSuccess: WebSocketAPIMessageCallback<any>, onError?: EventListener, quiet?: boolean): void;
215
215
  /**
216
216
  * Subscribe to deleted_vhicles channel.
217
217
  *
@@ -327,7 +327,7 @@ declare class RealtimeAPI {
327
327
  * @param {function} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
328
328
  * @public
329
329
  */
330
- unsubscribe<T>(channel: string, suffix?: string, onMessage?: WebSocketAPIMessageCallback<T>): void;
330
+ unsubscribe(channel: string, suffix?: string, onMessage?: WebSocketAPIMessageCallback<any>): void;
331
331
  /**
332
332
  * Unsubscribe to deleted_vhicles channels.
333
333
  * @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
@@ -21,8 +21,8 @@ export type WebSocketAPIMessageEventListener = (evt: WebSocketAPIMessageEvent) =
21
21
  * This type represents a function that has been call with each feature returned by the websocket.
22
22
  */
23
23
  export type WebSocketAPIMessageCallback<T> = (data: WebSocketAPIMessageEventData<T>) => void;
24
- export declare interface WebSocketAPISubscription<T> {
25
- cb: WebSocketAPIMessageCallback<T>;
24
+ export declare interface WebSocketAPISubscription {
25
+ cb: WebSocketAPIMessageCallback<any>;
26
26
  errorCb?: EventListener;
27
27
  onErrorCb?: EventListener;
28
28
  onMessageCb: WebSocketAPIMessageEventListener;
@@ -30,8 +30,8 @@ export declare interface WebSocketAPISubscription<T> {
30
30
  quiet: boolean;
31
31
  }
32
32
  export type WebSocketAPISubscribed = Record<string, boolean>;
33
- export declare interface WebSocketAPIRequest<T> {
34
- cb: WebSocketAPIMessageCallback<T>;
33
+ export declare interface WebSocketAPIRequest {
34
+ cb: WebSocketAPIMessageCallback<any>;
35
35
  errorCb?: EventListener;
36
36
  onErrorCb?: EventListener;
37
37
  onMessageCb: WebSocketAPIMessageEventListener;
@@ -50,9 +50,9 @@ declare class WebSocketAPI {
50
50
  connecting?: boolean;
51
51
  messagesOnOpen: string[];
52
52
  open?: boolean;
53
- requests: WebSocketAPIRequest<unknown>[];
53
+ requests: WebSocketAPIRequest[];
54
54
  subscribed: WebSocketAPISubscribed;
55
- subscriptions: WebSocketAPISubscription<unknown>[];
55
+ subscriptions: WebSocketAPISubscription[];
56
56
  websocket?: WebSocket;
57
57
  constructor();
58
58
  /**
@@ -92,7 +92,7 @@ declare class WebSocketAPI {
92
92
  * @param {function} errorCb Callback on error and close event
93
93
  * @private
94
94
  */
95
- get<T>(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<T>, errorCb?: EventListener): void;
95
+ get(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): void;
96
96
  /**
97
97
  * Listen to websocket messages.
98
98
  *
@@ -102,7 +102,7 @@ declare class WebSocketAPI {
102
102
  * @return {{onMessage: function, errorCb: function}} Object with onMessage and error callbacks
103
103
  * @private
104
104
  */
105
- listen<T>(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<T>, errorCb?: EventListener): {
105
+ listen(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): {
106
106
  onErrorCb?: EventListener;
107
107
  onMessageCb: WebSocketAPIMessageEventListener;
108
108
  };
@@ -123,7 +123,7 @@ declare class WebSocketAPI {
123
123
  * @param {boolean} quiet if false, no GET or SUB requests are send, only the callback is registered.
124
124
  * @private
125
125
  */
126
- subscribe<T>(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<T>, errorCb?: EventListener, quiet?: boolean): void;
126
+ subscribe(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener, quiet?: boolean): void;
127
127
  /**
128
128
  * After an auto reconnection we need to re-subscribe to the channels.
129
129
  */
@@ -135,13 +135,13 @@ declare class WebSocketAPI {
135
135
  * @param {function} cb Callback used when listen.
136
136
  * @private
137
137
  */
138
- unlisten<T>(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<T>): void;
138
+ unlisten(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>): void;
139
139
  /**
140
140
  * Unsubscribe from a channel.
141
141
  * @param {string} source source to unsubscribe from
142
142
  * @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
143
143
  * @private
144
144
  */
145
- unsubscribe<T>(source: string, cb?: WebSocketAPIMessageCallback<T>): void;
145
+ unsubscribe(source: string, cb?: WebSocketAPIMessageCallback<any>): void;
146
146
  }
147
147
  export default WebSocketAPI;
@@ -167,11 +167,9 @@ class WebSocketAPI {
167
167
  requestString,
168
168
  };
169
169
  if (index > -1) {
170
- // @ts-expect-error - We know that the requests is an array of WebSocketAPIRequest
171
170
  this.requests[index] = newReq;
172
171
  }
173
172
  else {
174
- // @ts-expect-error - We know that the requests is an array of WebSocketAPIRequest
175
173
  this.requests.push(newReq);
176
174
  }
177
175
  }
@@ -203,7 +201,6 @@ class WebSocketAPI {
203
201
  // Buffer channel message return a list of other channels to propagate to proper callbacks.
204
202
  let contents;
205
203
  if (data.source === 'buffer') {
206
- // @ts-expect-error - We know that the data is a WebSocketAPIBufferMessageEventData
207
204
  contents = data
208
205
  .content;
209
206
  }
@@ -276,11 +273,9 @@ class WebSocketAPI {
276
273
  const index = this.subscriptions.findIndex((subcr) => params.channel === subcr.params.channel && cb === subcr.cb);
277
274
  const newSubscr = { cb, errorCb, onErrorCb, onMessageCb, params, quiet };
278
275
  if (index > -1) {
279
- // @ts-expect-error - We know that the subscriptions is an array of WebSocketAPISubscription
280
276
  this.subscriptions[index] = newSubscr;
281
277
  }
282
278
  else {
283
- // @ts-expect-error - We know that the subscriptions is an array of WebSocketAPISubscription
284
279
  this.subscriptions.push(newSubscr);
285
280
  }
286
281
  if (!this.subscribed[reqStr]) {
@@ -11,7 +11,7 @@ const debounceWebsocketMessages = (onUpdate, getObjectId, timeout = 100) => {
11
11
  const objectsById = {};
12
12
  const objects = [];
13
13
  return (data) => {
14
- const { content, source } = data;
14
+ const { source, content } = data;
15
15
  if (updateTimeout[source]) {
16
16
  window.clearTimeout(updateTimeout[source]);
17
17
  }