mobility-toolbox-js 3.0.0-beta.2 → 3.0.0-beta.21
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 +20 -0
- package/api/HttpAPI.js +0 -11
- package/api/RealtimeAPI.d.ts +404 -0
- package/api/RealtimeAPI.js +342 -276
- package/api/RoutingAPI.d.ts +47 -0
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +44 -0
- package/api/StopsAPI.js +16 -10
- package/api/WebSocketAPI.d.ts +147 -0
- package/api/WebSocketAPI.js +164 -164
- package/api/index.d.ts +3 -0
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +76 -0
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +53 -0
- package/common/controls/StopFinderControlCommon.js +31 -31
- package/common/index.d.ts +2 -0
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +267 -0
- package/common/mixins/RealtimeLayerMixin.js +401 -393
- package/common/styles/index.d.ts +4 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/typedefs.d.ts +219 -0
- package/common/typedefs.js +7 -1
- package/common/utils/compareDepartures.d.ts +10 -0
- package/common/utils/compareDepartures.js +2 -2
- package/common/utils/constants.d.ts +5 -0
- package/common/utils/createCanvas.d.ts +10 -0
- package/common/utils/createDefaultCopyrightElt.d.ts +5 -0
- package/common/utils/createDefaultStopFinderElt.d.ts +5 -0
- package/common/utils/createRealtimeFilters.d.ts +12 -0
- package/common/utils/debounceDeparturesMessages.d.ts +12 -0
- package/common/utils/debounceWebsocketMessages.d.ts +11 -0
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.js +5 -1
- package/common/utils/getMapGlCopyrights.d.ts +17 -0
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getUrlWithParams.d.ts +8 -0
- package/common/utils/getVehiclePosition.d.ts +17 -0
- package/common/utils/getVehiclePosition.js +9 -3
- package/common/utils/index.d.ts +16 -0
- package/common/utils/realtimeConfig.d.ts +64 -0
- package/common/utils/removeDuplicate.d.ts +9 -0
- package/common/utils/renderTrajectories.d.ts +16 -0
- package/common/utils/renderTrajectories.js +6 -6
- package/common/utils/sortAndFilterDepartures.d.ts +15 -0
- package/common/utils/sortAndFilterDepartures.js +1 -1
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.js +5 -1
- package/common/utils/timeUtils.d.ts +23 -0
- package/common/utils/toMercatorExtent.d.ts +5 -0
- package/iife.d.ts +2 -0
- package/index.d.ts +9 -0
- package/maplibre/controls/CopyrightControl.d.ts +35 -0
- package/maplibre/controls/index.d.ts +1 -0
- package/maplibre/index.d.ts +5 -0
- package/maplibre/layers/Layer.d.ts +28 -0
- package/maplibre/layers/Layer.js +1 -1
- package/maplibre/layers/RealtimeLayer.d.ts +181 -0
- package/maplibre/layers/RealtimeLayer.js +29 -5
- package/maplibre/layers/index.d.ts +2 -0
- package/maplibre/utils/getMercatorResolution.d.ts +7 -0
- package/maplibre/utils/getSourceCoordinates.d.ts +7 -0
- package/maplibre/utils/getSourceCoordinates.js +5 -5
- package/maplibre/utils/index.d.ts +2 -0
- package/mbt.js +22103 -14430
- package/mbt.js.map +4 -4
- package/mbt.min.js +61 -58
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.js +18 -8
- package/ol/controls/RoutingControl.d.ts +202 -0
- package/ol/controls/RoutingControl.js +220 -219
- package/ol/controls/StopFinderControl.d.ts +37 -0
- package/ol/controls/StopFinderControl.js +4 -1
- package/ol/controls/index.d.ts +3 -0
- package/ol/index.d.ts +7 -0
- package/ol/index.js +1 -0
- package/ol/layers/Layer.d.ts +101 -0
- package/ol/layers/Layer.js +25 -0
- package/ol/layers/MaplibreLayer.d.ts +160 -0
- package/ol/layers/MaplibreLayer.js +97 -27
- package/ol/layers/MaplibreStyleLayer.d.ts +237 -0
- package/ol/layers/MaplibreStyleLayer.js +291 -267
- package/ol/layers/RealtimeLayer.d.ts +283 -0
- package/ol/layers/RealtimeLayer.js +143 -128
- package/ol/layers/VectorLayer.d.ts +18 -0
- package/ol/layers/VectorLayer.js +31 -0
- package/ol/layers/index.d.ts +5 -0
- package/ol/layers/index.js +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +96 -0
- package/ol/mixins/MobilityLayerMixin.js +1 -4
- package/ol/mixins/PropertiesLayerMixin.d.ts +135 -0
- package/ol/mixins/PropertiesLayerMixin.js +112 -140
- package/ol/mixins/index.d.ts +1 -0
- package/ol/mixins/index.js +2 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -0
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
- package/ol/renderers/RealtimeLayerRenderer.js +58 -53
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +6 -0
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/routingStyle.d.ts +4 -0
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +8 -0
- package/ol/utils/getFeatureInfoAtCoordinate.js +12 -18
- package/ol/utils/index.d.ts +1 -0
- package/package.json +31 -31
- package/setupTests.d.ts +1 -0
- package/setupTests.js +3 -4
- package/types/common.d.ts +55 -48
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +91 -93
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
- package/ol/layers/MapGlLayer.js +0 -142
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { RoutingParameters, RoutingResponse } from '../types';
|
|
2
|
+
import HttpAPI from './HttpAPI';
|
|
3
|
+
export interface RoutingAPIOptions {
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* This class provides convenience methods to use to the [geOps Routing API](https://developer.geops.io/apis/routing).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { RoutingAPI } from 'mobility-toolbox-js';
|
|
12
|
+
*
|
|
13
|
+
* const api = new RoutingAPI({
|
|
14
|
+
* apiKey: [yourApiKey],
|
|
15
|
+
* // url: 'https://api.geops.io/routing/v1/',
|
|
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
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
declare class RoutingAPI extends HttpAPI {
|
|
28
|
+
/**
|
|
29
|
+
* Constructor
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} options Options.
|
|
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
|
|
35
|
+
*/
|
|
36
|
+
constructor(options?: RoutingAPIOptions);
|
|
37
|
+
/**
|
|
38
|
+
* Calculate a route.
|
|
39
|
+
*
|
|
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.
|
|
42
|
+
* @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
route(params: RoutingParameters, config: RequestInit): Promise<RoutingResponse>;
|
|
46
|
+
}
|
|
47
|
+
export default RoutingAPI;
|
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);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { StopsParameters, StopsResponse } from '../types';
|
|
2
|
+
import HttpAPI from './HttpAPI';
|
|
3
|
+
export interface StopsAPIOptions {
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* This class provides convenience methods to use to the [geOps Stops API](https://developer.geops.io/apis/stops/).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { StopsAPI } from 'mobility-toolbox-js/api';
|
|
12
|
+
*
|
|
13
|
+
* const api = new StopsAPI({
|
|
14
|
+
* apiKey: [yourApiKey],
|
|
15
|
+
* // url: 'https://api.geops.io/stops/v1/',
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* const stops = await api.search({ q:"Bern" });
|
|
19
|
+
*
|
|
20
|
+
* console.log('Log stops:', JSON.stringify(stops));
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
declare class StopsAPI extends HttpAPI {
|
|
25
|
+
/**
|
|
26
|
+
* Constructor
|
|
27
|
+
*
|
|
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
|
|
32
|
+
*/
|
|
33
|
+
constructor(options?: StopsAPIOptions);
|
|
34
|
+
/**
|
|
35
|
+
* Search for stops.
|
|
36
|
+
*
|
|
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
|
|
41
|
+
*/
|
|
42
|
+
search(params: StopsParameters, config: RequestInit): Promise<StopsResponse>;
|
|
43
|
+
}
|
|
44
|
+
export default StopsAPI;
|
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
29
|
super(Object.assign({ url: 'https://api.geops.io/stops/v1/' }, options));
|
|
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);
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { RealtimeTrajectoryResponse } from '../types';
|
|
2
|
+
export declare interface WebSocketAPIParameters {
|
|
3
|
+
args?: number | string;
|
|
4
|
+
channel?: string;
|
|
5
|
+
id?: number | string;
|
|
6
|
+
}
|
|
7
|
+
export declare interface WebSocketAPIMessageEventData<T> {
|
|
8
|
+
client_reference: null | number | string;
|
|
9
|
+
content: T;
|
|
10
|
+
source: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
}
|
|
13
|
+
export type WebSocketAPIBufferMessageEventData = {
|
|
14
|
+
source: 'buffer';
|
|
15
|
+
} & WebSocketAPIMessageEventData<RealtimeTrajectoryResponse[]>;
|
|
16
|
+
export type WebSocketAPIMessageEvent = {
|
|
17
|
+
data: string;
|
|
18
|
+
} & Event;
|
|
19
|
+
export type WebSocketAPIMessageEventListener = (evt: WebSocketAPIMessageEvent) => void;
|
|
20
|
+
/**
|
|
21
|
+
* This type represents a function that has been call with each feature returned by the websocket.
|
|
22
|
+
*/
|
|
23
|
+
export type WebSocketAPIMessageCallback<T> = (data: WebSocketAPIMessageEventData<T>) => void;
|
|
24
|
+
export declare interface WebSocketAPISubscription {
|
|
25
|
+
cb: WebSocketAPIMessageCallback<any>;
|
|
26
|
+
errorCb?: EventListener;
|
|
27
|
+
onErrorCb?: EventListener;
|
|
28
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
29
|
+
params: WebSocketAPIParameters;
|
|
30
|
+
quiet: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type WebSocketAPISubscribed = Record<string, boolean>;
|
|
33
|
+
export declare interface WebSocketAPIRequest {
|
|
34
|
+
cb: WebSocketAPIMessageCallback<any>;
|
|
35
|
+
errorCb?: EventListener;
|
|
36
|
+
onErrorCb?: EventListener;
|
|
37
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
38
|
+
params: WebSocketAPIParameters;
|
|
39
|
+
requestString: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Class used to facilitate connection to a WebSocketAPI and
|
|
43
|
+
* also to manage properly messages send to the WebSocketAPI.
|
|
44
|
+
* This class must not contain any specific implementation.
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
declare class WebSocketAPI {
|
|
48
|
+
closed?: boolean;
|
|
49
|
+
closing?: boolean;
|
|
50
|
+
connecting?: boolean;
|
|
51
|
+
messagesOnOpen: string[];
|
|
52
|
+
open?: boolean;
|
|
53
|
+
requests: WebSocketAPIRequest[];
|
|
54
|
+
subscribed: WebSocketAPISubscribed;
|
|
55
|
+
subscriptions: WebSocketAPISubscription[];
|
|
56
|
+
websocket?: WebSocket;
|
|
57
|
+
constructor();
|
|
58
|
+
/**
|
|
59
|
+
* Get the websocket request string.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} method Request mehtod {GET, SUB}.
|
|
62
|
+
* @param {WebSocketParameters} params Request parameters.
|
|
63
|
+
* @param {string} params.channel Channel name
|
|
64
|
+
* @param {string} [params.args] Request arguments
|
|
65
|
+
* @param {Number|string} [params.id] Request identifier
|
|
66
|
+
* @return {string} request string
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
static getRequestString(method: string, params?: WebSocketAPIParameters): string;
|
|
70
|
+
addEvents(onMessage: WebSocketAPIMessageEventListener, onError?: EventListener): void;
|
|
71
|
+
/**
|
|
72
|
+
* Close the websocket definitively.
|
|
73
|
+
*
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
close(): void;
|
|
77
|
+
/**
|
|
78
|
+
* (Re)connect the websocket.
|
|
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.
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
connect(url: string, onOpen?: () => void): void;
|
|
85
|
+
defineProperties(): void;
|
|
86
|
+
/**
|
|
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.
|
|
89
|
+
*
|
|
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
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
get(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): void;
|
|
96
|
+
/**
|
|
97
|
+
* Listen to websocket messages.
|
|
98
|
+
*
|
|
99
|
+
* @param {WebSocketParameters} params Parameters for the websocket get request
|
|
100
|
+
* @param {function} cb callback on listen
|
|
101
|
+
* @param {function} errorCb Callback on error
|
|
102
|
+
* @return {{onMessage: function, errorCb: function}} Object with onMessage and error callbacks
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
listen(params: WebSocketAPIParameters, cb: WebSocketAPIMessageCallback<any>, errorCb?: EventListener): {
|
|
106
|
+
onErrorCb?: EventListener;
|
|
107
|
+
onMessageCb: WebSocketAPIMessageEventListener;
|
|
108
|
+
};
|
|
109
|
+
removeEvents(onMessage: WebSocketAPIMessageEventListener, onError?: EventListener): void;
|
|
110
|
+
/**
|
|
111
|
+
* Sends a message to the websocket.
|
|
112
|
+
*
|
|
113
|
+
* @param {message} message Message to send.
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
send(message: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Subscribe to a given channel.
|
|
119
|
+
*
|
|
120
|
+
* @param {Object} params Parameters for the websocket get request
|
|
121
|
+
* @param {function} cb callback on listen
|
|
122
|
+
* @param {function} errorCb Callback on error
|
|
123
|
+
* @param {boolean} quiet if false, no GET or SUB requests are send, only the callback is registered.
|
|
124
|
+
* @private
|
|
125
|
+
*/
|
|
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;
|
|
139
|
+
/**
|
|
140
|
+
* Unsubscribe from a channel.
|
|
141
|
+
* @param {string} source source to unsubscribe from
|
|
142
|
+
* @param {function} cb Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
unsubscribe(source: string, cb?: WebSocketAPIMessageCallback<any>): void;
|
|
146
|
+
}
|
|
147
|
+
export default WebSocketAPI;
|