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.
- package/README.md +11 -3
- package/api/HttpAPI.d.ts +5 -16
- package/api/HttpAPI.js +1 -14
- package/api/RealtimeAPI.d.ts +188 -143
- package/api/RealtimeAPI.js +265 -206
- package/api/RoutingAPI.d.ts +21 -11
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +20 -14
- package/api/StopsAPI.js +17 -11
- package/api/WebSocketAPI.d.ts +60 -66
- package/api/WebSocketAPI.js +164 -165
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +0 -102
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +13 -13
- package/common/controls/StopFinderControlCommon.js +32 -32
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/common/styles/realtimeDefaultStyle.js +6 -11
- package/common/styles/realtimeHeadingStyle.js +5 -10
- package/common/styles/realtimeSimpleStyle.d.ts +0 -1
- package/common/styles/realtimeSimpleStyle.js +0 -1
- package/common/typedefs.d.ts +11 -121
- package/common/typedefs.js +6 -31
- package/common/utils/RealtimeEngine.d.ts +214 -0
- package/common/utils/RealtimeEngine.js +554 -0
- package/common/utils/compareDepartures.d.ts +2 -2
- package/common/utils/compareDepartures.js +2 -2
- package/common/utils/debounceWebsocketMessages.d.ts +1 -1
- package/common/utils/getLayersAsFlatArray.d.ts +0 -1
- package/common/utils/getLayersAsFlatArray.js +0 -1
- package/common/utils/getMapGlCopyrights.d.ts +1 -1
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getVehiclePosition.d.ts +5 -4
- package/common/utils/getVehiclePosition.js +6 -3
- package/common/utils/realtimeConfig.d.ts +1 -1
- package/common/utils/realtimeConfig.js +0 -1
- package/common/utils/renderTrajectories.d.ts +2 -1
- package/common/utils/renderTrajectories.js +7 -6
- package/common/utils/sortAndFilterDepartures.d.ts +2 -1
- package/common/utils/sortAndFilterDepartures.js +2 -1
- package/common/utils/sortByDelay.d.ts +2 -2
- package/common/utils/sortByDelay.js +5 -1
- package/maplibre/controls/CopyrightControl.d.ts +9 -6
- package/maplibre/controls/CopyrightControl.js +11 -8
- package/maplibre/layers/Layer.d.ts +8 -7
- package/maplibre/layers/Layer.js +2 -3
- package/maplibre/layers/RealtimeLayer.d.ts +82 -118
- package/maplibre/layers/RealtimeLayer.js +154 -118
- package/maplibre/utils/getSourceCoordinates.d.ts +1 -0
- package/maplibre/utils/getSourceCoordinates.js +6 -5
- package/mbt.js +14611 -14591
- package/mbt.js.map +4 -4
- package/mbt.min.js +75 -75
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +13 -5
- package/ol/controls/CopyrightControl.js +13 -5
- package/ol/controls/RoutingControl.d.ts +105 -101
- package/ol/controls/RoutingControl.js +250 -264
- package/ol/controls/StopFinderControl.d.ts +24 -5
- package/ol/controls/StopFinderControl.js +24 -5
- package/ol/layers/Layer.d.ts +26 -0
- package/ol/layers/Layer.js +39 -0
- package/ol/layers/MaplibreLayer.d.ts +56 -28
- package/ol/layers/MaplibreLayer.js +154 -31
- package/ol/layers/MaplibreStyleLayer.d.ts +71 -149
- package/ol/layers/MaplibreStyleLayer.js +281 -210
- package/ol/layers/RealtimeLayer.d.ts +95 -230
- package/ol/layers/RealtimeLayer.js +209 -211
- package/ol/layers/VectorLayer.d.ts +17 -0
- package/ol/layers/VectorLayer.js +33 -0
- package/ol/layers/index.d.ts +2 -0
- package/ol/layers/index.js +3 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +7 -7
- package/ol/renderers/RealtimeLayerRenderer.js +46 -66
- package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
- package/ol/styles/fullTrajectoryStyle.d.ts +1 -2
- package/ol/styles/fullTrajectoryStyle.js +5 -7
- package/ol/styles/routingStyle.d.ts +0 -1
- package/ol/styles/routingStyle.js +13 -10
- package/ol/utils/defineDeprecatedProperties.d.ts +10 -0
- package/ol/utils/defineDeprecatedProperties.js +180 -0
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
- package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
- package/package.json +44 -44
- package/setupTests.js +17 -4
- package/types/common.d.ts +53 -69
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +98 -95
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
- package/common/mixins/RealtimeLayerMixin.d.ts +0 -273
- package/common/mixins/RealtimeLayerMixin.js +0 -743
- package/ol/layers/MapGlLayer.d.ts +0 -144
- package/ol/layers/MapGlLayer.js +0 -144
- package/ol/mixins/MobilityLayerMixin.d.ts +0 -98
- package/ol/mixins/MobilityLayerMixin.js +0 -6
- package/ol/mixins/PropertiesLayerMixin.d.ts +0 -127
- package/ol/mixins/PropertiesLayerMixin.js +0 -143
package/api/RoutingAPI.d.ts
CHANGED
|
@@ -1,36 +1,46 @@
|
|
|
1
|
-
import HttpAPI from './HttpAPI';
|
|
2
1
|
import { RoutingParameters, RoutingResponse } from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import HttpAPI from './HttpAPI';
|
|
3
|
+
export interface RoutingAPIOptions {
|
|
5
4
|
apiKey?: string;
|
|
6
|
-
|
|
5
|
+
url?: string;
|
|
6
|
+
}
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* This class provides convenience methods to use to the [geOps Routing API](https://developer.geops.io/apis/routing).
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* import { RoutingAPI } from 'mobility-toolbox-js';
|
|
12
12
|
*
|
|
13
13
|
* const api = new RoutingAPI({
|
|
14
|
-
* apiKey: [yourApiKey]
|
|
14
|
+
* apiKey: [yourApiKey],
|
|
15
|
+
* // url: 'https://api.geops.io/routing/v1/',
|
|
15
16
|
* });
|
|
16
17
|
*
|
|
18
|
+
* const route = await api.route({
|
|
19
|
+
* via: "freiburg|basel%20sbb|bern",
|
|
20
|
+
* mot: "rail"
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* console.log('Log route:', JSON.stringify(route));
|
|
24
|
+
*
|
|
17
25
|
* @public
|
|
18
26
|
*/
|
|
19
27
|
declare class RoutingAPI extends HttpAPI {
|
|
20
28
|
/**
|
|
21
29
|
* Constructor
|
|
22
30
|
*
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
31
|
+
* @param {Object} options Options.
|
|
25
32
|
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
33
|
+
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
34
|
+
* @public
|
|
26
35
|
*/
|
|
27
36
|
constructor(options?: RoutingAPIOptions);
|
|
28
37
|
/**
|
|
29
|
-
*
|
|
38
|
+
* Calculate a route.
|
|
30
39
|
*
|
|
31
|
-
* @param {RoutingParameters} params Request parameters. See [Routing
|
|
32
|
-
* @param {
|
|
40
|
+
* @param {RoutingParameters} params Request parameters. See [geOps Routing API](https://developer.geops.io/apis/routing/).
|
|
41
|
+
* @param {FetchOptions} config Options for the fetch request.
|
|
33
42
|
* @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
43
|
+
* @public
|
|
34
44
|
*/
|
|
35
45
|
route(params: RoutingParameters, config: RequestInit): Promise<RoutingResponse>;
|
|
36
46
|
}
|
package/api/RoutingAPI.js
CHANGED
|
@@ -1,33 +1,43 @@
|
|
|
1
1
|
import HttpAPI from './HttpAPI';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* This class provides convenience methods to use to the [geOps Routing API](https://developer.geops.io/apis/routing).
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* import { RoutingAPI } from 'mobility-toolbox-js';
|
|
7
7
|
*
|
|
8
8
|
* const api = new RoutingAPI({
|
|
9
|
-
* apiKey: [yourApiKey]
|
|
9
|
+
* apiKey: [yourApiKey],
|
|
10
|
+
* // url: 'https://api.geops.io/routing/v1/',
|
|
10
11
|
* });
|
|
11
12
|
*
|
|
13
|
+
* const route = await api.route({
|
|
14
|
+
* via: "freiburg|basel%20sbb|bern",
|
|
15
|
+
* mot: "rail"
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* console.log('Log route:', JSON.stringify(route));
|
|
19
|
+
*
|
|
12
20
|
* @public
|
|
13
21
|
*/
|
|
14
22
|
class RoutingAPI extends HttpAPI {
|
|
15
23
|
/**
|
|
16
24
|
* Constructor
|
|
17
25
|
*
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
26
|
+
* @param {Object} options Options.
|
|
20
27
|
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
28
|
+
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
29
|
+
* @public
|
|
21
30
|
*/
|
|
22
31
|
constructor(options = {}) {
|
|
23
32
|
super(Object.assign({ url: 'https://api.geops.io/routing/v1/' }, options));
|
|
24
33
|
}
|
|
25
34
|
/**
|
|
26
|
-
*
|
|
35
|
+
* Calculate a route.
|
|
27
36
|
*
|
|
28
|
-
* @param {RoutingParameters} params Request parameters. See [Routing
|
|
29
|
-
* @param {
|
|
37
|
+
* @param {RoutingParameters} params Request parameters. See [geOps Routing API](https://developer.geops.io/apis/routing/).
|
|
38
|
+
* @param {FetchOptions} config Options for the fetch request.
|
|
30
39
|
* @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
40
|
+
* @public
|
|
31
41
|
*/
|
|
32
42
|
route(params, config) {
|
|
33
43
|
return this.fetch('', params, config);
|
package/api/StopsAPI.d.ts
CHANGED
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
import HttpAPI from './HttpAPI';
|
|
2
1
|
import { StopsParameters, StopsResponse } from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import HttpAPI from './HttpAPI';
|
|
3
|
+
export interface StopsAPIOptions {
|
|
5
4
|
apiKey?: string;
|
|
6
|
-
|
|
5
|
+
url?: string;
|
|
6
|
+
}
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* This class provides convenience methods to use to the [geOps Stops API](https://developer.geops.io/apis/stops/).
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* import { StopsAPI } from 'mobility-toolbox-js/api';
|
|
12
12
|
*
|
|
13
13
|
* const api = new StopsAPI({
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* apiKey: [yourApiKey],
|
|
15
|
+
* // url: 'https://api.geops.io/stops/v1/',
|
|
16
16
|
* });
|
|
17
17
|
*
|
|
18
|
+
* const stops = await api.search({ q:"Bern" });
|
|
19
|
+
*
|
|
20
|
+
* console.log('Log stops:', JSON.stringify(stops));
|
|
21
|
+
*
|
|
18
22
|
* @public
|
|
19
23
|
*/
|
|
20
24
|
declare class StopsAPI extends HttpAPI {
|
|
21
25
|
/**
|
|
22
26
|
* Constructor
|
|
23
27
|
*
|
|
24
|
-
* @param {
|
|
25
|
-
* @param {string}
|
|
26
|
-
* @param {string} options.
|
|
28
|
+
* @param {Object} options Options.
|
|
29
|
+
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
30
|
+
* @param {string} [options.url='https://api.geops.io/stops/v1/'] Url of the [geOps stops API](https://developer.geops.io/apis/stops/).
|
|
31
|
+
* @public
|
|
27
32
|
*/
|
|
28
33
|
constructor(options?: StopsAPIOptions);
|
|
29
34
|
/**
|
|
30
|
-
* Search
|
|
35
|
+
* Search for stops.
|
|
31
36
|
*
|
|
32
|
-
* @param {StopsParameters} params Request parameters. See [Stops
|
|
33
|
-
* @param {
|
|
34
|
-
* @
|
|
37
|
+
* @param {StopsParameters} params Request parameters. See [Stops API documentation](https://developer.geops.io/apis/stops).
|
|
38
|
+
* @param {FetchOptions} config Options for the fetch request.
|
|
39
|
+
* @returns {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326). See [Stops API documentation](https://developer.geops.io/apis/stops).
|
|
40
|
+
* @public
|
|
35
41
|
*/
|
|
36
42
|
search(params: StopsParameters, config: RequestInit): Promise<StopsResponse>;
|
|
37
43
|
}
|
package/api/StopsAPI.js
CHANGED
|
@@ -1,34 +1,40 @@
|
|
|
1
1
|
import HttpAPI from './HttpAPI';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* This class provides convenience methods to use to the [geOps Stops API](https://developer.geops.io/apis/stops/).
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* import { StopsAPI } from 'mobility-toolbox-js/api';
|
|
7
7
|
*
|
|
8
8
|
* const api = new StopsAPI({
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* apiKey: [yourApiKey],
|
|
10
|
+
* // url: 'https://api.geops.io/stops/v1/',
|
|
11
11
|
* });
|
|
12
12
|
*
|
|
13
|
+
* const stops = await api.search({ q:"Bern" });
|
|
14
|
+
*
|
|
15
|
+
* console.log('Log stops:', JSON.stringify(stops));
|
|
16
|
+
*
|
|
13
17
|
* @public
|
|
14
18
|
*/
|
|
15
19
|
class StopsAPI extends HttpAPI {
|
|
16
20
|
/**
|
|
17
21
|
* Constructor
|
|
18
22
|
*
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {string}
|
|
21
|
-
* @param {string} options.
|
|
23
|
+
* @param {Object} options Options.
|
|
24
|
+
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
25
|
+
* @param {string} [options.url='https://api.geops.io/stops/v1/'] Url of the [geOps stops API](https://developer.geops.io/apis/stops/).
|
|
26
|
+
* @public
|
|
22
27
|
*/
|
|
23
28
|
constructor(options = {}) {
|
|
24
|
-
super(Object.assign({ url: 'https://api.geops.io/stops/v1/' }
|
|
29
|
+
super(Object.assign(Object.assign({}, options), { url: options.url || 'https://api.geops.io/stops/v1/' }));
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
27
|
-
* Search
|
|
32
|
+
* Search for stops.
|
|
28
33
|
*
|
|
29
|
-
* @param {StopsParameters} params Request parameters. See [Stops
|
|
30
|
-
* @param {
|
|
31
|
-
* @
|
|
34
|
+
* @param {StopsParameters} params Request parameters. See [Stops API documentation](https://developer.geops.io/apis/stops).
|
|
35
|
+
* @param {FetchOptions} config Options for the fetch request.
|
|
36
|
+
* @returns {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326). See [Stops API documentation](https://developer.geops.io/apis/stops).
|
|
37
|
+
* @public
|
|
32
38
|
*/
|
|
33
39
|
search(params, config) {
|
|
34
40
|
return this.fetch('', params, config);
|
package/api/WebSocketAPI.d.ts
CHANGED
|
@@ -1,49 +1,43 @@
|
|
|
1
1
|
import { RealtimeTrajectoryResponse } from '../types';
|
|
2
|
-
export declare
|
|
2
|
+
export declare interface WebSocketAPIParameters {
|
|
3
|
+
args?: number | string;
|
|
3
4
|
channel?: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
timestamp: number;
|
|
9
|
-
source: string;
|
|
5
|
+
id?: number | string;
|
|
6
|
+
}
|
|
7
|
+
export declare interface WebSocketAPIMessageEventData<T> {
|
|
8
|
+
client_reference: null | number | string;
|
|
10
9
|
content: T;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
source: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
}
|
|
13
|
+
export type WebSocketAPIBufferMessageEventData = {
|
|
14
14
|
source: 'buffer';
|
|
15
|
-
}
|
|
16
|
-
export type WebSocketAPIMessageEvent =
|
|
15
|
+
} & WebSocketAPIMessageEventData<RealtimeTrajectoryResponse[]>;
|
|
16
|
+
export type WebSocketAPIMessageEvent = {
|
|
17
17
|
data: string;
|
|
18
|
-
};
|
|
19
|
-
export
|
|
20
|
-
(evt: WebSocketAPIMessageEvent): void;
|
|
21
|
-
}
|
|
18
|
+
} & Event;
|
|
19
|
+
export type WebSocketAPIMessageEventListener = (evt: WebSocketAPIMessageEvent) => void;
|
|
22
20
|
/**
|
|
23
21
|
* This type represents a function that has been call with each feature returned by the websocket.
|
|
24
22
|
*/
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
export declare type WebSocketAPISubscription = {
|
|
29
|
-
params: WebSocketAPIParameters;
|
|
23
|
+
export type WebSocketAPIMessageCallback<T> = (data: WebSocketAPIMessageEventData<T>) => void;
|
|
24
|
+
export declare interface WebSocketAPISubscription {
|
|
30
25
|
cb: WebSocketAPIMessageCallback<any>;
|
|
31
26
|
errorCb?: EventListener;
|
|
32
|
-
onMessageCb: WebSocketAPIMessageEventListener;
|
|
33
27
|
onErrorCb?: EventListener;
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
export declare type WebSocketAPISubscribed = {
|
|
37
|
-
[index: string]: boolean;
|
|
38
|
-
};
|
|
39
|
-
export declare type WebSocketAPIRequest = {
|
|
28
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
40
29
|
params: WebSocketAPIParameters;
|
|
30
|
+
quiet: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type WebSocketAPISubscribed = Record<string, boolean>;
|
|
33
|
+
export declare interface WebSocketAPIRequest {
|
|
41
34
|
cb: WebSocketAPIMessageCallback<any>;
|
|
42
35
|
errorCb?: EventListener;
|
|
43
|
-
onMessageCb: WebSocketAPIMessageEventListener;
|
|
44
36
|
onErrorCb?: EventListener;
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
38
|
+
params: WebSocketAPIParameters;
|
|
39
|
+
requestString: string;
|
|
40
|
+
}
|
|
47
41
|
/**
|
|
48
42
|
* Class used to facilitate connection to a WebSocketAPI and
|
|
49
43
|
* also to manage properly messages send to the WebSocketAPI.
|
|
@@ -51,17 +45,16 @@ export declare type WebSocketAPIRequest = {
|
|
|
51
45
|
* @private
|
|
52
46
|
*/
|
|
53
47
|
declare class WebSocketAPI {
|
|
54
|
-
websocket?: WebSocket;
|
|
55
48
|
closed?: boolean;
|
|
56
49
|
closing?: boolean;
|
|
57
50
|
connecting?: boolean;
|
|
51
|
+
messagesOnOpen: string[];
|
|
58
52
|
open?: boolean;
|
|
59
|
-
|
|
60
|
-
subscriptions: Array<WebSocketAPISubscription>;
|
|
53
|
+
requests: WebSocketAPIRequest[];
|
|
61
54
|
subscribed: WebSocketAPISubscribed;
|
|
62
|
-
|
|
55
|
+
subscriptions: WebSocketAPISubscription[];
|
|
56
|
+
websocket?: WebSocket;
|
|
63
57
|
constructor();
|
|
64
|
-
defineProperties(): void;
|
|
65
58
|
/**
|
|
66
59
|
* Get the websocket request string.
|
|
67
60
|
*
|
|
@@ -74,29 +67,32 @@ declare class WebSocketAPI {
|
|
|
74
67
|
* @private
|
|
75
68
|
*/
|
|
76
69
|
static getRequestString(method: string, params?: WebSocketAPIParameters): string;
|
|
70
|
+
addEvents(onMessage: WebSocketAPIMessageEventListener, onError?: EventListener): void;
|
|
77
71
|
/**
|
|
78
|
-
*
|
|
72
|
+
* Close the websocket definitively.
|
|
79
73
|
*
|
|
80
|
-
* @param {string} url Websocket url.
|
|
81
|
-
* @param {function} onOpen Callback called when the websocket connection is opened and before subscriptions of previous subscriptions.
|
|
82
74
|
* @private
|
|
83
75
|
*/
|
|
84
|
-
|
|
76
|
+
close(): void;
|
|
85
77
|
/**
|
|
86
|
-
*
|
|
78
|
+
* (Re)connect the websocket.
|
|
87
79
|
*
|
|
80
|
+
* @param {string} url Websocket url.
|
|
81
|
+
* @param {function} onOpen Callback called when the websocket connection is opened and before subscriptions of previous subscriptions.
|
|
88
82
|
* @private
|
|
89
83
|
*/
|
|
90
|
-
|
|
84
|
+
connect(url: string, onOpen?: () => void): void;
|
|
85
|
+
defineProperties(): void;
|
|
91
86
|
/**
|
|
92
|
-
* Sends a
|
|
87
|
+
* Sends a get request to the websocket.
|
|
88
|
+
* The callback is called only once, when the response is received or when the call returns an error.
|
|
93
89
|
*
|
|
94
|
-
* @param {
|
|
90
|
+
* @param {Object} params Parameters for the websocket get request
|
|
91
|
+
* @param {function} cb callback on message event
|
|
92
|
+
* @param {function} errorCb Callback on error and close event
|
|
95
93
|
* @private
|
|
96
94
|
*/
|
|
97
|
-
|
|
98
|
-
addEvents(onMessage: WebSocketAPIMessageEventListener, onError?: EventListener): void;
|
|
99
|
-
removeEvents(onMessage: WebSocketAPIMessageEventListener, onError?: EventListener): void;
|
|
95
|
+
get(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): void;
|
|
100
96
|
/**
|
|
101
97
|
* Listen to websocket messages.
|
|
102
98
|
*
|
|
@@ -107,27 +103,17 @@ declare class WebSocketAPI {
|
|
|
107
103
|
* @private
|
|
108
104
|
*/
|
|
109
105
|
listen(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): {
|
|
110
|
-
onMessageCb: WebSocketAPIMessageEventListener;
|
|
111
106
|
onErrorCb?: EventListener;
|
|
107
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
112
108
|
};
|
|
109
|
+
removeEvents(onMessage: WebSocketAPIMessageEventListener, onError?: EventListener): void;
|
|
113
110
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* @param {Object} params Parameters for the websocket get request.
|
|
117
|
-
* @param {function} cb Callback used when listen.
|
|
118
|
-
* @private
|
|
119
|
-
*/
|
|
120
|
-
unlisten(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>): void;
|
|
121
|
-
/**
|
|
122
|
-
* Sends a get request to the websocket.
|
|
123
|
-
* The callback is called only once, when the response is received or when the call returns an error.
|
|
111
|
+
* Sends a message to the websocket.
|
|
124
112
|
*
|
|
125
|
-
* @param {
|
|
126
|
-
* @param {function} onMessage callback on message event
|
|
127
|
-
* @param {function} onError Callback on error and close event
|
|
113
|
+
* @param {message} message Message to send.
|
|
128
114
|
* @private
|
|
129
115
|
*/
|
|
130
|
-
|
|
116
|
+
send(message: string): void;
|
|
131
117
|
/**
|
|
132
118
|
* Subscribe to a given channel.
|
|
133
119
|
*
|
|
@@ -138,6 +124,18 @@ declare class WebSocketAPI {
|
|
|
138
124
|
* @private
|
|
139
125
|
*/
|
|
140
126
|
subscribe(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener, quiet?: boolean): void;
|
|
127
|
+
/**
|
|
128
|
+
* After an auto reconnection we need to re-subscribe to the channels.
|
|
129
|
+
*/
|
|
130
|
+
subscribePreviousSubscriptions(): void;
|
|
131
|
+
/**
|
|
132
|
+
* Unlisten websocket messages.
|
|
133
|
+
*
|
|
134
|
+
* @param {Object} params Parameters for the websocket get request.
|
|
135
|
+
* @param {function} cb Callback used when listen.
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
unlisten(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>): void;
|
|
141
139
|
/**
|
|
142
140
|
* Unsubscribe from a channel.
|
|
143
141
|
* @param {string} source source to unsubscribe from
|
|
@@ -145,9 +143,5 @@ declare class WebSocketAPI {
|
|
|
145
143
|
* @private
|
|
146
144
|
*/
|
|
147
145
|
unsubscribe(source: string, cb?: WebSocketAPIMessageCallback<any>): void;
|
|
148
|
-
/**
|
|
149
|
-
* After an auto reconnection we need to re-subscribe to the channels.
|
|
150
|
-
*/
|
|
151
|
-
subscribePreviousSubscriptions(): void;
|
|
152
146
|
}
|
|
153
147
|
export default WebSocketAPI;
|