camstreamerlib 4.0.0-beta.47 → 4.0.0-beta.49

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 (70) hide show
  1. package/README.md +123 -30
  2. package/cjs/CamSwitcherAPI.js +1 -1
  3. package/cjs/PlaneTrackerAPI.js +7 -2
  4. package/cjs/index.js +18 -9
  5. package/cjs/internal/WsEvents.js +6 -5
  6. package/cjs/node/CamOverlayDrawingAPI.js +10 -10
  7. package/cjs/node/CamScripterAPICameraEventsGenerator.js +9 -9
  8. package/cjs/node/Digest.test.js +13 -0
  9. package/cjs/node/VapixEvents.js +9 -9
  10. package/cjs/node/WsClient.js +20 -13
  11. package/cjs/types/CamOverlayAPI/pipSchema.js +1 -1
  12. package/cjs/types/PlaneTrackerAPI.js +4 -1
  13. package/cjs/types/ws/CamOverlayEvents.js +19 -0
  14. package/cjs/types/ws/CamStreamerEvents.js +32 -0
  15. package/cjs/types/ws/PlaneTrackerEvents.js +103 -0
  16. package/cjs/web/DefaultClient.js +6 -2
  17. package/cjs/web/WsClient.js +13 -15
  18. package/cjs/ws/CamOverlayEvents.js +24 -0
  19. package/cjs/ws/CamStreamerEvents.js +24 -0
  20. package/cjs/ws/CamSwitcherEvents.js +24 -0
  21. package/cjs/ws/PlaneTrackerEvents.js +22 -0
  22. package/esm/CamSwitcherAPI.js +1 -1
  23. package/esm/PlaneTrackerAPI.js +8 -3
  24. package/esm/index.js +12 -6
  25. package/esm/internal/WsEvents.js +6 -5
  26. package/esm/node/CamOverlayDrawingAPI.js +10 -10
  27. package/esm/node/CamScripterAPICameraEventsGenerator.js +9 -9
  28. package/esm/node/Digest.test.js +11 -0
  29. package/esm/node/VapixEvents.js +9 -9
  30. package/esm/node/WsClient.js +20 -13
  31. package/esm/types/CamOverlayAPI/pipSchema.js +1 -1
  32. package/esm/types/PlaneTrackerAPI.js +3 -0
  33. package/esm/types/ws/CamOverlayEvents.js +16 -0
  34. package/esm/types/ws/CamStreamerEvents.js +29 -0
  35. package/esm/types/ws/PlaneTrackerEvents.js +100 -0
  36. package/esm/web/DefaultClient.js +6 -2
  37. package/esm/web/WsClient.js +13 -15
  38. package/esm/ws/CamOverlayEvents.js +20 -0
  39. package/esm/ws/CamStreamerEvents.js +20 -0
  40. package/esm/ws/CamSwitcherEvents.js +20 -0
  41. package/esm/ws/PlaneTrackerEvents.js +18 -0
  42. package/package.json +1 -1
  43. package/types/CamSwitcherAPI.d.ts +1 -1
  44. package/types/PlaneTrackerAPI.d.ts +4 -2
  45. package/types/index.d.ts +12 -6
  46. package/types/internal/WsEvents.d.ts +3 -5
  47. package/types/internal/types.d.ts +7 -6
  48. package/types/node/CamScripterAPICameraEventsGenerator.d.ts +2 -2
  49. package/types/node/Digest.test.d.ts +1 -0
  50. package/types/node/VapixEvents.d.ts +2 -2
  51. package/types/node/WsClient.d.ts +9 -19
  52. package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +5 -5
  53. package/types/types/CamOverlayAPI/pipSchema.d.ts +2 -2
  54. package/types/types/CamOverlayDrawingAPI.d.ts +2 -2
  55. package/types/types/PlaneTrackerAPI.d.ts +8 -0
  56. package/types/types/ws/CamOverlayEvents.d.ts +88 -0
  57. package/types/types/ws/CamStreamerEvents.d.ts +249 -0
  58. package/types/types/ws/PlaneTrackerEvents.d.ts +960 -0
  59. package/types/web/DefaultClient.d.ts +2 -0
  60. package/types/web/WsClient.d.ts +9 -5
  61. package/types/ws/CamOverlayEvents.d.ts +8 -0
  62. package/types/ws/CamStreamerEvents.d.ts +8 -0
  63. package/types/ws/CamSwitcherEvents.d.ts +8 -0
  64. package/types/ws/PlaneTrackerEvents.d.ts +9 -0
  65. package/cjs/CamSwitcherEvents.js +0 -11
  66. package/esm/CamSwitcherEvents.js +0 -7
  67. package/types/CamSwitcherEvents.d.ts +0 -8
  68. /package/cjs/types/{CamSwitcherEvents.js → ws/CamSwitcherEvents.js} +0 -0
  69. /package/esm/types/{CamSwitcherEvents.js → ws/CamSwitcherEvents.js} +0 -0
  70. /package/types/types/{CamSwitcherEvents.d.ts → ws/CamSwitcherEvents.d.ts} +0 -0
@@ -1,7 +1,6 @@
1
- import EventEmitter from 'events';
2
1
  import WebSocket from 'ws';
3
2
  import { Digest } from './Digest';
4
- export class WsClient extends EventEmitter {
3
+ export class WsClient {
5
4
  user;
6
5
  pass;
7
6
  address;
@@ -14,7 +13,6 @@ export class WsClient extends EventEmitter {
14
13
  ws;
15
14
  isClosed = false;
16
15
  constructor(options) {
17
- super();
18
16
  const tls = options.tls ?? false;
19
17
  const tlsInsecure = options.tlsInsecure ?? false;
20
18
  const ip = options.ip ?? '127.0.0.1';
@@ -46,10 +44,10 @@ export class WsClient extends EventEmitter {
46
44
  }
47
45
  this.ws.binaryType = 'arraybuffer';
48
46
  this.isAlive = true;
49
- this.pingTimer = setInterval(async () => {
47
+ this.pingTimer = setInterval(() => {
50
48
  if ((this.ws && this.ws.readyState !== WebSocket.OPEN) || this.isAlive === false) {
51
- this.emit('error', new Error('Connection timeout'));
52
- await this.closeWsConnection();
49
+ this.onError(new Error('Connection timeout'));
50
+ this.closeWsConnection();
53
51
  }
54
52
  else {
55
53
  this.isAlive = false;
@@ -72,23 +70,32 @@ export class WsClient extends EventEmitter {
72
70
  this.open(res.headers['www-authenticate']);
73
71
  }
74
72
  else {
75
- this.emit('error', new Error('Status code: ' + res.statusCode));
73
+ this.onError(new Error('Status code: ' + res.statusCode));
76
74
  this.closeWsConnection();
77
75
  }
78
76
  });
79
- this.ws.on('open', () => this.emit('open'));
80
- this.ws.on('message', (data) => this.emit('message', data));
77
+ this.ws.on('open', () => this.onOpen());
78
+ this.ws.on('message', (data, isBinary) => {
79
+ const message = isBinary ? data : data.toString();
80
+ this.onMessage(message);
81
+ });
81
82
  this.ws.on('error', (error) => {
82
- this.emit('error', error);
83
+ this.onError(error);
83
84
  this.closeWsConnection();
84
85
  });
85
86
  this.ws.on('close', () => this.closeWsConnection());
86
87
  }
87
88
  catch (error) {
88
- this.emit('error', error instanceof Error ? error : new Error('Unknown error'));
89
+ this.onError(error instanceof Error ? error : new Error('Unknown error'));
89
90
  this.closeWsConnection();
90
91
  }
91
92
  }
93
+ onMessage = (_) => { };
94
+ onOpen = () => { };
95
+ onClose = () => { };
96
+ onError = (error) => {
97
+ console.error(error);
98
+ };
92
99
  send(data) {
93
100
  if (this.ws === undefined) {
94
101
  throw new Error("This websocket hasn't been opened yet.");
@@ -97,7 +104,7 @@ export class WsClient extends EventEmitter {
97
104
  this.ws.send(data);
98
105
  }
99
106
  }
100
- close() {
107
+ destroy() {
101
108
  if (this.isClosed) {
102
109
  return;
103
110
  }
@@ -127,7 +134,7 @@ export class WsClient extends EventEmitter {
127
134
  wsCopy.terminate();
128
135
  }
129
136
  }, 5000);
130
- this.emit('close');
137
+ this.onClose();
131
138
  }
132
139
  catch (err) {
133
140
  console.error(err);
@@ -24,7 +24,7 @@ export const pipSchema = serviceCommonSchema.extend({
24
24
  z.literal('overlays=image'),
25
25
  z.literal('overlays=application'),
26
26
  ]),
27
- rotate: z.union([z.literal(0), z.literal(90), z.literal(180), z.literal(270)]),
27
+ rotate: z.union([z.literal(0), z.literal(90), z.literal(180), z.literal(270)]).default(0),
28
28
  dewarping: z.object({
29
29
  enabled: z.boolean(),
30
30
  rectangle: z.array(z.tuple([z.number(), z.number()])),
@@ -231,6 +231,9 @@ export const serverSettingsSchema = z.object({
231
231
  tiltRealKnownPoint: 90,
232
232
  }),
233
233
  });
234
+ export const getIcaoSchema = z.object({
235
+ icao: z.string(),
236
+ });
234
237
  export const trackingModeSchema = z.object({
235
238
  mode: z.union([z.literal('MANUAL'), z.literal('AUTOMATIC')]),
236
239
  });
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ const coEventsDataSchema = z.discriminatedUnion('type', [
3
+ z.object({ type: z.literal('authorization'), state: z.string() }),
4
+ z.object({
5
+ type: z.literal('ServiceStart'),
6
+ serviceId: z.number(),
7
+ }),
8
+ z.object({
9
+ type: z.literal('ServiceStop'),
10
+ serviceId: z.number(),
11
+ }),
12
+ ]);
13
+ export const coEventsSchema = z.discriminatedUnion('type', [
14
+ z.object({ type: z.literal('init'), data: coEventsDataSchema }),
15
+ ...coEventsDataSchema.options,
16
+ ]);
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ const csEventsDataSchema = z.discriminatedUnion('type', [
3
+ z.object({ type: z.literal('authorization'), state: z.string() }),
4
+ z.object({
5
+ type: z.literal('StreamState'),
6
+ streamID: z.number(),
7
+ enabled: z.union([z.literal(0), z.literal(1)]),
8
+ active: z.union([z.literal(0), z.literal(1)]),
9
+ automationState: z.union([z.literal(0), z.literal(1)]),
10
+ isStreaming: z.union([z.literal(0), z.literal(1)]),
11
+ }),
12
+ z.object({
13
+ type: z.literal('CS_API_SUCCESS'),
14
+ apiCall: z.string(),
15
+ message: z.string(),
16
+ streamID: z.string(),
17
+ }),
18
+ z.object({
19
+ type: z.literal('CS_API_ERROR'),
20
+ apiCall: z.string(),
21
+ message: z.string(),
22
+ streamID: z.string(),
23
+ code: z.string(),
24
+ }),
25
+ ]);
26
+ export const csEventsSchema = z.discriminatedUnion('type', [
27
+ z.object({ type: z.literal('init'), data: csEventsDataSchema }),
28
+ ...csEventsDataSchema.options,
29
+ ]);
@@ -0,0 +1,100 @@
1
+ import { z } from 'zod';
2
+ const apiFlightDataSchema = z.object({
3
+ icao: z.string(),
4
+ lat: z.number(),
5
+ lon: z.number(),
6
+ heading: z.number(),
7
+ groundSpeed: z.number(),
8
+ altitudeAMSL: z.number(),
9
+ cameraDistance: z.number(),
10
+ autoTrackingOrder: z.number(),
11
+ whiteListed: z.boolean(),
12
+ blackListed: z.boolean(),
13
+ priorityListed: z.boolean(),
14
+ autoSelectionIgnored: z.boolean(),
15
+ signalQuality: z.number(),
16
+ emergencyState: z.boolean(),
17
+ emergencyStatusMessage: z.string(),
18
+ });
19
+ const apiUserSchema = z.object({
20
+ userId: z.string(),
21
+ userName: z.string(),
22
+ userPriority: z.string(),
23
+ ip: z.string(),
24
+ });
25
+ export var EUserActions;
26
+ (function (EUserActions) {
27
+ EUserActions["TRACK_ICAO"] = "trackIcao.cgi";
28
+ EUserActions["RESET_ICAO"] = "resetIcao.cgi";
29
+ EUserActions["SET_PRIORITY_LIST"] = "setPriorityList.cgi";
30
+ EUserActions["SET_BLACK_LIST"] = "setBlackList.cgi";
31
+ EUserActions["SET_WHITE_LIST"] = "setWhiteList.cgi";
32
+ EUserActions["GO_TO_COORDINATES"] = "goToCoordinates.cgi";
33
+ EUserActions["SET_TRACKING_MODE"] = "setTrackingMode.cgi";
34
+ EUserActions["SET_ZONES"] = "setZones.cgi";
35
+ EUserActions["RESET_PTZ_CALIBRATION"] = "resetPtzCalibration.cgi";
36
+ EUserActions["LOCK_API"] = "lockApi.cgi";
37
+ EUserActions["UNLOCK_API"] = "unlockApi.cgi";
38
+ })(EUserActions || (EUserActions = {}));
39
+ const ptrEventsDataSchema = z.discriminatedUnion('type', [
40
+ z.object({
41
+ type: z.literal('CAMERA_POSITION'),
42
+ lat: z.number(),
43
+ lon: z.number(),
44
+ azimuth: z.number().min(0).max(360),
45
+ elevation: z.number().min(-90).max(90),
46
+ fov: z.number(),
47
+ }),
48
+ z.object({
49
+ type: z.literal('TRACKING_START'),
50
+ icao: z.string(),
51
+ }),
52
+ z.object({
53
+ type: z.literal('TRACKING_STOP'),
54
+ }),
55
+ z.object({
56
+ type: z.literal('FLIGHT_LIST'),
57
+ list: z.array(apiFlightDataSchema),
58
+ }),
59
+ z.object({
60
+ type: z.literal('USER_ACTION'),
61
+ ip: z.string(),
62
+ params: z.object({
63
+ userId: z.string(),
64
+ userName: z.string(),
65
+ userPriority: z.number(),
66
+ }),
67
+ cgi: z.enum([
68
+ EUserActions.TRACK_ICAO,
69
+ EUserActions.RESET_ICAO,
70
+ EUserActions.SET_PRIORITY_LIST,
71
+ EUserActions.SET_BLACK_LIST,
72
+ EUserActions.SET_WHITE_LIST,
73
+ EUserActions.GO_TO_COORDINATES,
74
+ EUserActions.SET_TRACKING_MODE,
75
+ EUserActions.SET_ZONES,
76
+ EUserActions.RESET_PTZ_CALIBRATION,
77
+ EUserActions.LOCK_API,
78
+ EUserActions.UNLOCK_API,
79
+ ]),
80
+ postJsonBody: z.any(),
81
+ }),
82
+ z.object({
83
+ type: z.literal('CONNECTED_USERS'),
84
+ users: z.array(apiUserSchema),
85
+ }),
86
+ z.object({
87
+ type: z.literal('FORCE_TRACKING_STATUS'),
88
+ enabled: z.boolean(),
89
+ icao: z.string().optional(),
90
+ }),
91
+ z.object({
92
+ type: z.literal('API_LOCK_STATUS'),
93
+ isLocked: z.boolean(),
94
+ user: apiUserSchema.optional(),
95
+ }),
96
+ ]);
97
+ export const ptrEventsSchema = z.discriminatedUnion('type', [
98
+ z.object({ type: z.literal('init'), data: ptrEventsDataSchema }),
99
+ ...ptrEventsDataSchema.options,
100
+ ]);
@@ -1,5 +1,9 @@
1
1
  import { addParametersToPath } from '../internal/utils';
2
2
  export class DefaultClient {
3
+ domain;
4
+ constructor(domain = '') {
5
+ this.domain = domain;
6
+ }
3
7
  get = (params) => {
4
8
  return this.fetchWithTimeout(addParametersToPath(params.path, params.parameters), {
5
9
  method: 'GET',
@@ -13,11 +17,11 @@ export class DefaultClient {
13
17
  headers: params.headers,
14
18
  }, params.timeout);
15
19
  };
16
- async fetchWithTimeout(url, options, timeout) {
20
+ async fetchWithTimeout(path, options, timeout) {
17
21
  const controller = new AbortController();
18
22
  const timeoutId = timeout !== undefined ? setTimeout(() => controller.abort(), timeout) : null;
19
23
  try {
20
- return await fetch(url, { ...options, signal: controller.signal });
24
+ return await fetch(`${this.domain}${path}`, { ...options, signal: controller.signal });
21
25
  }
22
26
  finally {
23
27
  if (timeoutId) {
@@ -1,13 +1,11 @@
1
1
  const REFRESH_TIMEOUT = 5000;
2
2
  export class WsClient {
3
3
  getUrl;
4
- getAuthToken;
5
4
  isDestroyed = false;
6
5
  ws = null;
7
6
  restartTimeout = null;
8
- constructor(getUrl, getAuthToken) {
7
+ constructor(getUrl) {
9
8
  this.getUrl = getUrl;
10
- this.getAuthToken = getAuthToken;
11
9
  }
12
10
  init() {
13
11
  if (this.isDestroyed) {
@@ -15,17 +13,9 @@ export class WsClient {
15
13
  }
16
14
  this.destroyWebsocket();
17
15
  const ws = new WebSocket(this.getUrl(), 'events');
18
- ws.onopen = async () => {
19
- try {
20
- const token = await this.getAuthToken();
21
- ws.send(JSON.stringify({ authorization: token }));
22
- }
23
- catch (error) {
24
- console.error('Error sending auth token:', error);
25
- ws.close();
26
- }
27
- };
28
- ws.onmessage = (e) => this.onmessage(e);
16
+ ws.binaryType = 'arraybuffer';
17
+ ws.onopen = () => this.onOpen();
18
+ ws.onmessage = (e) => this.onMessage(e.data);
29
19
  ws.onclose = () => {
30
20
  this.restartTimeout = window.setTimeout(() => this.init(), REFRESH_TIMEOUT);
31
21
  };
@@ -34,7 +24,15 @@ export class WsClient {
34
24
  send = (msg) => {
35
25
  this.ws?.send(msg);
36
26
  };
37
- onmessage = (_) => { };
27
+ onMessage = (_) => { };
28
+ onOpen = () => { };
29
+ onClose = () => { };
30
+ onError = (error) => {
31
+ console.error(error);
32
+ };
33
+ reconnect = () => {
34
+ this.ws?.close();
35
+ };
38
36
  destroy = () => {
39
37
  this.isDestroyed = true;
40
38
  this.destroyWebsocket();
@@ -0,0 +1,20 @@
1
+ import { WsEvents } from '../internal/WsEvents';
2
+ import { coEventsSchema } from '../types/ws/CamOverlayEvents';
3
+ export class CamOverlayEvents extends WsEvents {
4
+ getAuthToken;
5
+ constructor(ws, getAuthToken) {
6
+ super(coEventsSchema, ws);
7
+ this.getAuthToken = getAuthToken;
8
+ this.ws.onOpen = this.sendInitMsg;
9
+ }
10
+ sendInitMsg = async () => {
11
+ try {
12
+ const token = await this.getAuthToken();
13
+ this.ws.send(JSON.stringify({ authorization: token }));
14
+ }
15
+ catch (error) {
16
+ console.error('Error on open:', error);
17
+ this.ws.reconnect();
18
+ }
19
+ };
20
+ }
@@ -0,0 +1,20 @@
1
+ import { WsEvents } from '../internal/WsEvents';
2
+ import { csEventsSchema } from '../types/ws/CamStreamerEvents';
3
+ export class CamStreamerEvents extends WsEvents {
4
+ getAuthToken;
5
+ constructor(ws, getAuthToken) {
6
+ super(csEventsSchema, ws);
7
+ this.getAuthToken = getAuthToken;
8
+ this.ws.onOpen = this.sendInitMsg;
9
+ }
10
+ sendInitMsg = async () => {
11
+ try {
12
+ const token = await this.getAuthToken();
13
+ this.ws.send(JSON.stringify({ authorization: token }));
14
+ }
15
+ catch (error) {
16
+ console.error('Error on open:', error);
17
+ this.ws.reconnect();
18
+ }
19
+ };
20
+ }
@@ -0,0 +1,20 @@
1
+ import { WsEvents } from '../internal/WsEvents';
2
+ import { cswEventsSchema } from '../types/ws/CamSwitcherEvents';
3
+ export class CamSwitcherEvents extends WsEvents {
4
+ getAuthToken;
5
+ constructor(ws, getAuthToken) {
6
+ super(cswEventsSchema, ws);
7
+ this.getAuthToken = getAuthToken;
8
+ this.ws.onOpen = this.sendInitMsg;
9
+ }
10
+ sendInitMsg = async () => {
11
+ try {
12
+ const token = await this.getAuthToken();
13
+ this.ws.send(JSON.stringify({ authorization: token }));
14
+ }
15
+ catch (error) {
16
+ console.error('Error on open:', error);
17
+ this.ws.reconnect();
18
+ }
19
+ };
20
+ }
@@ -0,0 +1,18 @@
1
+ import { WsEvents } from '../internal/WsEvents';
2
+ import { ptrEventsSchema } from '../types/ws/PlaneTrackerEvents';
3
+ export class PlaneTrackerEvents extends WsEvents {
4
+ _apiUser;
5
+ constructor(ws, _apiUser) {
6
+ super(ptrEventsSchema, ws);
7
+ this._apiUser = _apiUser;
8
+ this.ws.onOpen = this.sendInitMsg;
9
+ }
10
+ sendInitMsg = () => {
11
+ this.ws.send(JSON.stringify({
12
+ type: 'USER_INFO',
13
+ userId: this._apiUser.userId,
14
+ userName: this._apiUser.userName,
15
+ userPriority: this._apiUser.userPriority,
16
+ }));
17
+ };
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.0-beta.47",
3
+ "version": "4.0.0-beta.49",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "engine": {
@@ -12,7 +12,7 @@ export declare class CamSwitcherAPI<Client extends IClient<TResponse, any>> {
12
12
  });
13
13
  static getProxyPath: () => string;
14
14
  static getWsEventsPath: () => string;
15
- static getClipPreviewPath: (id: string, storage: TStorageType) => string;
15
+ static getClipPreviewPath: (clipId: string, storage: TStorageType) => string;
16
16
  getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
17
17
  checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
18
18
  getNetworkCameraList(options?: THttpRequestOptions): Promise<{
@@ -1,5 +1,5 @@
1
1
  import { IClient, TBlobResponse, TParameters, TResponse } from './internal/types';
2
- import { ICAO, TApiUser, TBlackList, TCameraSettings, TExportDataType, TImportDataType, TPriorityList, TTrackingMode, TWhiteList, TZones } from './types/PlaneTrackerAPI';
2
+ import { ICAO, TApiUser, TBlackList, TCameraSettings, TExportDataType, TGetIcaoByOption, TImportDataType, TPriorityList, TTrackingMode, TWhiteList, TZones } from './types/PlaneTrackerAPI';
3
3
  import { THttpRequestOptions, TProxyParams } from './types/common';
4
4
  import { ProxyClient } from './internal/ProxyClient';
5
5
  export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> {
@@ -7,6 +7,7 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> {
7
7
  private apiUser;
8
8
  constructor(client: Client, apiUser: TApiUser);
9
9
  static getProxyPath: () => string;
10
+ static getWsEventsPath: () => string;
10
11
  getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
11
12
  checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
12
13
  serverRunCheck(options?: THttpRequestOptions): Promise<TResponse>;
@@ -177,6 +178,7 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> {
177
178
  setTrackingMode(mode: TTrackingMode['mode'], options?: THttpRequestOptions): Promise<void>;
178
179
  startTrackingPlane(icao: ICAO, options?: THttpRequestOptions): Promise<void>;
179
180
  stopTrackingPlane(options?: THttpRequestOptions): Promise<void>;
181
+ getIcao(by: TGetIcaoByOption, value: string, options?: THttpRequestOptions): Promise<string>;
180
182
  getPriorityList(options?: THttpRequestOptions): Promise<{
181
183
  priorityList: string[];
182
184
  }>;
@@ -214,7 +216,7 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> {
214
216
  }[];
215
217
  }>;
216
218
  setZones(zones: TZones, options?: THttpRequestOptions): Promise<void>;
217
- goToCoordinates(lat: number, lon: number, alt?: number, options?: THttpRequestOptions): Promise<TResponse>;
219
+ goToCoordinates(lat: number, lon: number, alt?: number, options?: THttpRequestOptions): Promise<ReturnType<Client["get"]>>;
218
220
  checkGenetecConnection(params: TParameters, options?: THttpRequestOptions): Promise<TResponse>;
219
221
  getGenetecCameraList(params: TParameters, options?: THttpRequestOptions): Promise<{
220
222
  value: string;
package/types/index.d.ts CHANGED
@@ -4,17 +4,23 @@ export * from './internal/utils';
4
4
  export * from './internal/versionCompare';
5
5
  export * from './internal/ProxyClient';
6
6
  export * from './types/common';
7
- export { CamOverlayAPI } from './CamOverlayAPI';
8
- export * from './types/CamOverlayAPI';
9
- export { CamScripterAPI } from './CamScripterAPI';
10
- export * from './types/CamScripterAPI';
11
7
  export { CamStreamerAPI } from './CamStreamerAPI';
12
8
  export * from './types/CamStreamerAPI';
9
+ export { CamStreamerEvents } from './ws/CamStreamerEvents';
10
+ export * from './types/ws/CamStreamerEvents';
11
+ export { CamOverlayAPI } from './CamOverlayAPI';
12
+ export * from './types/CamOverlayAPI';
13
+ export { CamOverlayEvents } from './ws/CamOverlayEvents';
14
+ export * from './types/ws/CamOverlayEvents';
13
15
  export { CamSwitcherAPI } from './CamSwitcherAPI';
14
16
  export * from './types/CamSwitcherAPI';
15
- export { CamSwitcherEvents } from './CamSwitcherEvents';
16
- export * from './types/CamSwitcherEvents';
17
+ export { CamSwitcherEvents } from './ws/CamSwitcherEvents';
18
+ export * from './types/ws/CamSwitcherEvents';
17
19
  export { PlaneTrackerAPI } from './PlaneTrackerAPI';
18
20
  export * from './types/PlaneTrackerAPI';
21
+ export { PlaneTrackerEvents } from './ws/PlaneTrackerEvents';
22
+ export * from './types/ws/PlaneTrackerEvents';
23
+ export { CamScripterAPI } from './CamScripterAPI';
24
+ export * from './types/CamScripterAPI';
19
25
  export { VapixAPI } from './VapixAPI';
20
26
  export * from './types/VapixAPI';
@@ -1,4 +1,4 @@
1
- import { IWebsocket } from './types';
1
+ import { IWsClient } from './types';
2
2
  type TEventType<T extends {
3
3
  type: string;
4
4
  }> = T extends {
@@ -22,14 +22,12 @@ type TListenerFunction<T extends {
22
22
  }, Type extends TEventType<T>> = (data: TEvent<T, Type>, isInit: boolean) => void;
23
23
  export declare class WsEvents<T extends {
24
24
  type: string;
25
- }, Event extends {
26
- data: string;
27
25
  }> {
28
26
  private zodSchema;
29
- ws: IWebsocket<Event>;
27
+ ws: IWsClient;
30
28
  private _isDestroyed;
31
29
  private listeners;
32
- constructor(zodSchema: TZodSchema<T>, ws: IWebsocket<Event>);
30
+ constructor(zodSchema: TZodSchema<T>, ws: IWsClient);
33
31
  get isDestroyed(): boolean;
34
32
  resendInitData(): void;
35
33
  addListener<Type extends TEventType<T>>(type: Type, listener: TListenerFunction<T, Type>, id: string): void;
@@ -9,7 +9,6 @@ export type Options = {
9
9
  export type HttpOptions = Options & {
10
10
  keepAlive?: boolean;
11
11
  };
12
- export type WsOptions = Options;
13
12
  export type TParameters = Record<string, string | number | boolean | null | undefined>;
14
13
  export type TResponse = {
15
14
  json: () => Promise<any>;
@@ -36,10 +35,12 @@ export interface IClient<TRes extends TResponse, Data> {
36
35
  post: (params: TPostParams<Data>) => Promise<TRes>;
37
36
  }
38
37
  export type TBlobResponse<Client extends IClient<TResponse, any>> = Awaited<ReturnType<Awaited<ReturnType<Client['get']>>['blob']>>;
39
- export interface IWebsocket<Event extends {
40
- readonly data: string;
41
- }> {
38
+ export interface IWsClient {
39
+ onMessage: null | ((data: ArrayBuffer | string) => void);
40
+ onOpen: () => void;
41
+ onClose: () => void;
42
+ onError: (error: Error) => void;
43
+ send: (data: ArrayBuffer | string) => void;
44
+ reconnect: () => void;
42
45
  destroy: () => void;
43
- onmessage: null | ((event: Event) => void);
44
- send: (data: string) => void;
45
46
  }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import EventEmitter from 'events';
3
- import { WsOptions } from '../internal/types';
3
+ import { Options } from '../internal/types';
4
4
  import { TCamScripterEvent, TEventDeclaration, TEventUndeclaration, TCamScripterResponse } from '../types/CamScripterAPICameraEventsGenerator';
5
5
  export declare class CamScripterAPICameraEventsGenerator extends EventEmitter {
6
6
  private tls;
@@ -14,7 +14,7 @@ export declare class CamScripterAPICameraEventsGenerator extends EventEmitter {
14
14
  private timeoutCheckTimer;
15
15
  private wsConnected;
16
16
  private ws;
17
- constructor(options?: WsOptions);
17
+ constructor(options?: Options);
18
18
  connect(): void;
19
19
  disconnect(): void;
20
20
  declareEvent(eventDeclaration: TEventDeclaration): Promise<TCamScripterResponse>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter2 as EventEmitter } from 'eventemitter2';
2
- import { WsOptions } from '../internal/types';
2
+ import { Options } from '../internal/types';
3
3
  export declare class VapixEvents extends EventEmitter {
4
4
  private tls;
5
5
  private tlsInsecure;
@@ -8,7 +8,7 @@ export declare class VapixEvents extends EventEmitter {
8
8
  private user;
9
9
  private pass;
10
10
  private ws;
11
- constructor(options?: WsOptions);
11
+ constructor(options?: Options);
12
12
  connect(): void;
13
13
  disconnect(): void;
14
14
  private createWsClient;
@@ -1,25 +1,11 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import EventEmitter from 'events';
5
- import { WsOptions } from '../internal/types';
6
- export type WsClientOptions = WsOptions & {
1
+ import { IWsClient, Options } from '../internal/types';
2
+ export type WsClientOptions = Options & {
7
3
  address: string;
8
4
  headers?: Record<string, string>;
9
5
  pingInterval?: number;
10
6
  protocol?: string;
11
7
  };
12
- export interface WsClient {
13
- on(event: 'open', listener: () => void): this;
14
- on(event: 'close', listener: () => void): this;
15
- on(event: 'message', listener: (data: Buffer) => void): this;
16
- on(event: 'error', listener: (err: Error) => void): this;
17
- emit(event: 'open'): boolean;
18
- emit(event: 'close'): boolean;
19
- emit(event: 'message', data: Buffer): boolean;
20
- emit(event: 'error', err: Error): boolean;
21
- }
22
- export declare class WsClient extends EventEmitter {
8
+ export declare class WsClient implements IWsClient {
23
9
  private user;
24
10
  private pass;
25
11
  private address;
@@ -33,8 +19,12 @@ export declare class WsClient extends EventEmitter {
33
19
  private isClosed;
34
20
  constructor(options: WsClientOptions);
35
21
  open(wwwAuthenticateHeader?: string): void;
36
- send(data: Buffer | string): void;
37
- close(): void;
22
+ onMessage: (_: ArrayBuffer | string) => void;
23
+ onOpen: () => void;
24
+ onClose: () => void;
25
+ onError: (error: Error) => void;
26
+ send(data: ArrayBuffer | string): void;
27
+ destroy(): void;
38
28
  reconnect(): void;
39
29
  private closeWsConnection;
40
30
  }