camstreamerlib 4.0.31-e0ed433 → 4.0.32-894be2d

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 (72) hide show
  1. package/README.md +1 -1
  2. package/cjs/CamSwitcherAPI.d.ts +1 -1
  3. package/cjs/CamSwitcherAPI.js +8 -14
  4. package/cjs/PlaneTrackerAPI.d.ts +1 -0
  5. package/cjs/browser.index.d.ts +2 -0
  6. package/cjs/browser.index.js +18 -0
  7. package/cjs/errors/errors.d.ts +3 -0
  8. package/cjs/errors/errors.js +8 -1
  9. package/cjs/internal/types.d.ts +2 -0
  10. package/cjs/node/CamOverlayDrawingAPI.d.ts +2 -1
  11. package/cjs/node/CamOverlayDrawingAPI.js +6 -3
  12. package/cjs/node/CamScripterAPICameraEventsGenerator.d.ts +2 -1
  13. package/cjs/node/CamScripterAPICameraEventsGenerator.js +6 -3
  14. package/cjs/node/DefaultClient.d.ts +4 -3
  15. package/cjs/node/DefaultClient.js +8 -6
  16. package/cjs/node/DeviceConnectClient.d.ts +9 -0
  17. package/cjs/node/DeviceConnectClient.js +15 -0
  18. package/cjs/node/DeviceConnectWsClient.d.ts +12 -0
  19. package/cjs/node/DeviceConnectWsClient.js +21 -0
  20. package/cjs/node/VapixEvents.d.ts +2 -1
  21. package/cjs/node/VapixEvents.js +6 -3
  22. package/cjs/node/WsClient.d.ts +7 -2
  23. package/cjs/node/WsClient.js +3 -3
  24. package/cjs/node/index.d.ts +2 -0
  25. package/cjs/node/index.js +4 -1
  26. package/cjs/types/PlaneTrackerAPI.d.ts +5 -0
  27. package/cjs/types/PlaneTrackerAPI.js +1 -0
  28. package/cjs/types/ws/PlaneTrackerEvents.d.ts +23 -0
  29. package/cjs/web/DefaultClient.d.ts +2 -1
  30. package/cjs/web/DefaultClient.js +5 -3
  31. package/cjs/web/DeviceConnectClient.d.ts +4 -0
  32. package/cjs/web/DeviceConnectClient.js +10 -0
  33. package/cjs/web/DeviceConnectWsClient.d.ts +4 -0
  34. package/cjs/web/DeviceConnectWsClient.js +14 -0
  35. package/cjs/web/index.d.ts +2 -0
  36. package/cjs/web/index.js +5 -1
  37. package/esm/CamSwitcherAPI.js +9 -15
  38. package/esm/browser.index.js +2 -0
  39. package/esm/errors/errors.js +6 -0
  40. package/esm/node/CamOverlayDrawingAPI.js +6 -3
  41. package/esm/node/CamScripterAPICameraEventsGenerator.js +6 -3
  42. package/esm/node/DefaultClient.js +8 -6
  43. package/esm/node/DeviceConnectClient.js +11 -0
  44. package/esm/node/DeviceConnectWsClient.js +17 -0
  45. package/esm/node/VapixEvents.js +6 -3
  46. package/esm/node/WsClient.js +3 -3
  47. package/esm/node/index.js +2 -0
  48. package/esm/types/PlaneTrackerAPI.js +1 -0
  49. package/esm/web/DefaultClient.js +5 -3
  50. package/esm/web/DeviceConnectClient.js +6 -0
  51. package/esm/web/DeviceConnectWsClient.js +10 -0
  52. package/esm/web/index.js +2 -0
  53. package/package.json +5 -2
  54. package/types/CamSwitcherAPI.d.ts +1 -1
  55. package/types/PlaneTrackerAPI.d.ts +1 -0
  56. package/types/browser.index.d.ts +2 -0
  57. package/types/errors/errors.d.ts +3 -0
  58. package/types/internal/types.d.ts +2 -0
  59. package/types/node/CamOverlayDrawingAPI.d.ts +2 -1
  60. package/types/node/CamScripterAPICameraEventsGenerator.d.ts +2 -1
  61. package/types/node/DefaultClient.d.ts +4 -3
  62. package/types/node/DeviceConnectClient.d.ts +9 -0
  63. package/types/node/DeviceConnectWsClient.d.ts +12 -0
  64. package/types/node/VapixEvents.d.ts +2 -1
  65. package/types/node/WsClient.d.ts +7 -2
  66. package/types/node/index.d.ts +2 -0
  67. package/types/types/PlaneTrackerAPI.d.ts +5 -0
  68. package/types/types/ws/PlaneTrackerEvents.d.ts +23 -0
  69. package/types/web/DefaultClient.d.ts +2 -1
  70. package/types/web/DeviceConnectClient.d.ts +4 -0
  71. package/types/web/DeviceConnectWsClient.d.ts +4 -0
  72. package/types/web/index.d.ts +2 -0
@@ -931,6 +931,7 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
931
931
  minSpeedKmph: z.ZodOptional<z.ZodNumber>;
932
932
  maxSpeedKmph: z.ZodOptional<z.ZodNumber>;
933
933
  flightDirection: z.ZodDefault<z.ZodEnum<["all", "arrival", "departure"]>>;
934
+ runwayDirectionDeg: z.ZodOptional<z.ZodNumber>;
934
935
  weight: z.ZodNumber;
935
936
  perimeter: z.ZodDefault<z.ZodEnum<["none", "outer", "inner"]>>;
936
937
  trackingDomains: z.ZodDefault<z.ZodArray<z.ZodEnum<["adsb", "remoteId"]>, "many">>;
@@ -952,6 +953,7 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
952
953
  maxAltitudeAmsl?: number | undefined;
953
954
  minSpeedKmph?: number | undefined;
954
955
  maxSpeedKmph?: number | undefined;
956
+ runwayDirectionDeg?: number | undefined;
955
957
  }, {
956
958
  area: [{
957
959
  lat: number;
@@ -968,6 +970,7 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
968
970
  minSpeedKmph?: number | undefined;
969
971
  maxSpeedKmph?: number | undefined;
970
972
  flightDirection?: "all" | "arrival" | "departure" | undefined;
973
+ runwayDirectionDeg?: number | undefined;
971
974
  perimeter?: "none" | "outer" | "inner" | undefined;
972
975
  trackingDomains?: ("adsb" | "remoteId")[] | undefined;
973
976
  }>, "many">>;
@@ -990,6 +993,7 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
990
993
  maxAltitudeAmsl?: number | undefined;
991
994
  minSpeedKmph?: number | undefined;
992
995
  maxSpeedKmph?: number | undefined;
996
+ runwayDirectionDeg?: number | undefined;
993
997
  }[];
994
998
  }, {
995
999
  zones?: {
@@ -1008,6 +1012,7 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
1008
1012
  minSpeedKmph?: number | undefined;
1009
1013
  maxSpeedKmph?: number | undefined;
1010
1014
  flightDirection?: "all" | "arrival" | "departure" | undefined;
1015
+ runwayDirectionDeg?: number | undefined;
1011
1016
  perimeter?: "none" | "outer" | "inner" | undefined;
1012
1017
  trackingDomains?: ("adsb" | "remoteId")[] | undefined;
1013
1018
  }[] | undefined;
@@ -1040,6 +1045,7 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
1040
1045
  maxAltitudeAmsl?: number | undefined;
1041
1046
  minSpeedKmph?: number | undefined;
1042
1047
  maxSpeedKmph?: number | undefined;
1048
+ runwayDirectionDeg?: number | undefined;
1043
1049
  }[];
1044
1050
  };
1045
1051
  }, {
@@ -1068,6 +1074,7 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
1068
1074
  minSpeedKmph?: number | undefined;
1069
1075
  maxSpeedKmph?: number | undefined;
1070
1076
  flightDirection?: "all" | "arrival" | "departure" | undefined;
1077
+ runwayDirectionDeg?: number | undefined;
1071
1078
  perimeter?: "none" | "outer" | "inner" | undefined;
1072
1079
  trackingDomains?: ("adsb" | "remoteId")[] | undefined;
1073
1080
  }[] | undefined;
@@ -2080,6 +2087,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2080
2087
  minSpeedKmph: z.ZodOptional<z.ZodNumber>;
2081
2088
  maxSpeedKmph: z.ZodOptional<z.ZodNumber>;
2082
2089
  flightDirection: z.ZodDefault<z.ZodEnum<["all", "arrival", "departure"]>>;
2090
+ runwayDirectionDeg: z.ZodOptional<z.ZodNumber>;
2083
2091
  weight: z.ZodNumber;
2084
2092
  perimeter: z.ZodDefault<z.ZodEnum<["none", "outer", "inner"]>>;
2085
2093
  trackingDomains: z.ZodDefault<z.ZodArray<z.ZodEnum<["adsb", "remoteId"]>, "many">>;
@@ -2101,6 +2109,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2101
2109
  maxAltitudeAmsl?: number | undefined;
2102
2110
  minSpeedKmph?: number | undefined;
2103
2111
  maxSpeedKmph?: number | undefined;
2112
+ runwayDirectionDeg?: number | undefined;
2104
2113
  }, {
2105
2114
  area: [{
2106
2115
  lat: number;
@@ -2117,6 +2126,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2117
2126
  minSpeedKmph?: number | undefined;
2118
2127
  maxSpeedKmph?: number | undefined;
2119
2128
  flightDirection?: "all" | "arrival" | "departure" | undefined;
2129
+ runwayDirectionDeg?: number | undefined;
2120
2130
  perimeter?: "none" | "outer" | "inner" | undefined;
2121
2131
  trackingDomains?: ("adsb" | "remoteId")[] | undefined;
2122
2132
  }>, "many">>;
@@ -2139,6 +2149,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2139
2149
  maxAltitudeAmsl?: number | undefined;
2140
2150
  minSpeedKmph?: number | undefined;
2141
2151
  maxSpeedKmph?: number | undefined;
2152
+ runwayDirectionDeg?: number | undefined;
2142
2153
  }[];
2143
2154
  }, {
2144
2155
  zones?: {
@@ -2157,6 +2168,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2157
2168
  minSpeedKmph?: number | undefined;
2158
2169
  maxSpeedKmph?: number | undefined;
2159
2170
  flightDirection?: "all" | "arrival" | "departure" | undefined;
2171
+ runwayDirectionDeg?: number | undefined;
2160
2172
  perimeter?: "none" | "outer" | "inner" | undefined;
2161
2173
  trackingDomains?: ("adsb" | "remoteId")[] | undefined;
2162
2174
  }[] | undefined;
@@ -2189,6 +2201,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2189
2201
  maxAltitudeAmsl?: number | undefined;
2190
2202
  minSpeedKmph?: number | undefined;
2191
2203
  maxSpeedKmph?: number | undefined;
2204
+ runwayDirectionDeg?: number | undefined;
2192
2205
  }[];
2193
2206
  };
2194
2207
  }, {
@@ -2217,6 +2230,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2217
2230
  minSpeedKmph?: number | undefined;
2218
2231
  maxSpeedKmph?: number | undefined;
2219
2232
  flightDirection?: "all" | "arrival" | "departure" | undefined;
2233
+ runwayDirectionDeg?: number | undefined;
2220
2234
  perimeter?: "none" | "outer" | "inner" | undefined;
2221
2235
  trackingDomains?: ("adsb" | "remoteId")[] | undefined;
2222
2236
  }[] | undefined;
@@ -2636,6 +2650,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2636
2650
  maxAltitudeAmsl?: number | undefined;
2637
2651
  minSpeedKmph?: number | undefined;
2638
2652
  maxSpeedKmph?: number | undefined;
2653
+ runwayDirectionDeg?: number | undefined;
2639
2654
  }[];
2640
2655
  };
2641
2656
  } | {
@@ -2896,6 +2911,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2896
2911
  minSpeedKmph?: number | undefined;
2897
2912
  maxSpeedKmph?: number | undefined;
2898
2913
  flightDirection?: "all" | "arrival" | "departure" | undefined;
2914
+ runwayDirectionDeg?: number | undefined;
2899
2915
  perimeter?: "none" | "outer" | "inner" | undefined;
2900
2916
  trackingDomains?: ("adsb" | "remoteId")[] | undefined;
2901
2917
  }[] | undefined;
@@ -3751,6 +3767,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
3751
3767
  minSpeedKmph: z.ZodOptional<z.ZodNumber>;
3752
3768
  maxSpeedKmph: z.ZodOptional<z.ZodNumber>;
3753
3769
  flightDirection: z.ZodDefault<z.ZodEnum<["all", "arrival", "departure"]>>;
3770
+ runwayDirectionDeg: z.ZodOptional<z.ZodNumber>;
3754
3771
  weight: z.ZodNumber;
3755
3772
  perimeter: z.ZodDefault<z.ZodEnum<["none", "outer", "inner"]>>;
3756
3773
  trackingDomains: z.ZodDefault<z.ZodArray<z.ZodEnum<["adsb", "remoteId"]>, "many">>;
@@ -3772,6 +3789,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
3772
3789
  maxAltitudeAmsl?: number | undefined;
3773
3790
  minSpeedKmph?: number | undefined;
3774
3791
  maxSpeedKmph?: number | undefined;
3792
+ runwayDirectionDeg?: number | undefined;
3775
3793
  }, {
3776
3794
  area: [{
3777
3795
  lat: number;
@@ -3788,6 +3806,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
3788
3806
  minSpeedKmph?: number | undefined;
3789
3807
  maxSpeedKmph?: number | undefined;
3790
3808
  flightDirection?: "all" | "arrival" | "departure" | undefined;
3809
+ runwayDirectionDeg?: number | undefined;
3791
3810
  perimeter?: "none" | "outer" | "inner" | undefined;
3792
3811
  trackingDomains?: ("adsb" | "remoteId")[] | undefined;
3793
3812
  }>, "many">>;
@@ -3810,6 +3829,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
3810
3829
  maxAltitudeAmsl?: number | undefined;
3811
3830
  minSpeedKmph?: number | undefined;
3812
3831
  maxSpeedKmph?: number | undefined;
3832
+ runwayDirectionDeg?: number | undefined;
3813
3833
  }[];
3814
3834
  }, {
3815
3835
  zones?: {
@@ -3828,6 +3848,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
3828
3848
  minSpeedKmph?: number | undefined;
3829
3849
  maxSpeedKmph?: number | undefined;
3830
3850
  flightDirection?: "all" | "arrival" | "departure" | undefined;
3851
+ runwayDirectionDeg?: number | undefined;
3831
3852
  perimeter?: "none" | "outer" | "inner" | undefined;
3832
3853
  trackingDomains?: ("adsb" | "remoteId")[] | undefined;
3833
3854
  }[] | undefined;
@@ -3860,6 +3881,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
3860
3881
  maxAltitudeAmsl?: number | undefined;
3861
3882
  minSpeedKmph?: number | undefined;
3862
3883
  maxSpeedKmph?: number | undefined;
3884
+ runwayDirectionDeg?: number | undefined;
3863
3885
  }[];
3864
3886
  };
3865
3887
  }, {
@@ -3888,6 +3910,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
3888
3910
  minSpeedKmph?: number | undefined;
3889
3911
  maxSpeedKmph?: number | undefined;
3890
3912
  flightDirection?: "all" | "arrival" | "departure" | undefined;
3913
+ runwayDirectionDeg?: number | undefined;
3891
3914
  perimeter?: "none" | "outer" | "inner" | undefined;
3892
3915
  trackingDomains?: ("adsb" | "remoteId")[] | undefined;
3893
3916
  }[] | undefined;
@@ -1,7 +1,8 @@
1
1
  import { IClient, TGetParams, TPostParams } from '../internal/types';
2
2
  export declare class DefaultClient implements IClient<Response, FormData | ArrayBuffer> {
3
3
  domain: string;
4
- constructor(domain?: string);
4
+ headers: Record<string, string>;
5
+ constructor(domain?: string, headers?: Record<string, string>);
5
6
  get: (params: TGetParams) => Promise<Response>;
6
7
  post: (params: TPostParams<FormData | ArrayBuffer>) => Promise<Response>;
7
8
  private fetchWithTimeout;
@@ -4,20 +4,22 @@ exports.DefaultClient = void 0;
4
4
  const utils_1 = require("../internal/utils");
5
5
  class DefaultClient {
6
6
  domain;
7
- constructor(domain = '') {
7
+ headers;
8
+ constructor(domain = '', headers = {}) {
8
9
  this.domain = domain;
10
+ this.headers = headers;
9
11
  }
10
12
  get = (params) => {
11
13
  return this.fetchWithTimeout((0, utils_1.addParametersToPath)(params.path, params.parameters), {
12
14
  method: 'GET',
13
- headers: params.headers,
15
+ headers: { ...this.headers, ...params.headers },
14
16
  }, params.timeout);
15
17
  };
16
18
  post = (params) => {
17
19
  return this.fetchWithTimeout((0, utils_1.addParametersToPath)(params.path, params.parameters), {
18
20
  method: 'POST',
19
21
  body: params.data,
20
- headers: params.headers,
22
+ headers: { ...this.headers, ...params.headers },
21
23
  }, params.timeout);
22
24
  };
23
25
  async fetchWithTimeout(path, options, timeout) {
@@ -0,0 +1,4 @@
1
+ import { DefaultClient } from './DefaultClient';
2
+ export declare class DeviceConnectClient extends DefaultClient {
3
+ constructor(deviceAccessToken: string, host: string);
4
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeviceConnectClient = void 0;
4
+ const DefaultClient_1 = require("./DefaultClient");
5
+ class DeviceConnectClient extends DefaultClient_1.DefaultClient {
6
+ constructor(deviceAccessToken, host) {
7
+ super(`https://${host}`, { authorization: `Bearer ${deviceAccessToken}` });
8
+ }
9
+ }
10
+ exports.DeviceConnectClient = DeviceConnectClient;
@@ -0,0 +1,4 @@
1
+ import { WsClient } from './WsClient';
2
+ export declare class DeviceConnectWsClient extends WsClient {
3
+ constructor(deviceAccessToken: string, host: string, getPath: () => string);
4
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeviceConnectWsClient = void 0;
4
+ const WsClient_1 = require("./WsClient");
5
+ class DeviceConnectWsClient extends WsClient_1.WsClient {
6
+ constructor(deviceAccessToken, host, getPath) {
7
+ super(() => {
8
+ const path = getPath();
9
+ const andChar = path.includes('?') ? '&' : '?';
10
+ return `wss://${host}${path}${andChar}DEVICE_ACCESS_TOKEN=${deviceAccessToken}`;
11
+ });
12
+ }
13
+ }
14
+ exports.DeviceConnectWsClient = DeviceConnectWsClient;
@@ -1,2 +1,4 @@
1
1
  export { DefaultClient } from './DefaultClient';
2
+ export { DeviceConnectClient } from './DeviceConnectClient';
3
+ export { DeviceConnectWsClient } from './DeviceConnectWsClient';
2
4
  export { WsClient } from './WsClient';
package/cjs/web/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WsClient = exports.DefaultClient = void 0;
3
+ exports.WsClient = exports.DeviceConnectWsClient = exports.DeviceConnectClient = exports.DefaultClient = void 0;
4
4
  var DefaultClient_1 = require("./DefaultClient");
5
5
  Object.defineProperty(exports, "DefaultClient", { enumerable: true, get: function () { return DefaultClient_1.DefaultClient; } });
6
+ var DeviceConnectClient_1 = require("./DeviceConnectClient");
7
+ Object.defineProperty(exports, "DeviceConnectClient", { enumerable: true, get: function () { return DeviceConnectClient_1.DeviceConnectClient; } });
8
+ var DeviceConnectWsClient_1 = require("./DeviceConnectWsClient");
9
+ Object.defineProperty(exports, "DeviceConnectWsClient", { enumerable: true, get: function () { return DeviceConnectWsClient_1.DeviceConnectWsClient; } });
6
10
  var WsClient_1 = require("./WsClient");
7
11
  Object.defineProperty(exports, "WsClient", { enumerable: true, get: function () { return WsClient_1.WsClient; } });
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { AddNewClipError, ParameterNotFoundError } from './errors/errors';
2
+ import { AddNewClipError, GenerateSilenceError, ParameterNotFoundError } from './errors/errors';
3
3
  import { parseBitrateOptionsToVapixParams, parseVapixParamsToBitrateOptions } from './internal/convertors';
4
4
  import { isClip, isNullish } from './internal/utils';
5
5
  import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, secondaryAudioSettingsSchema, globalAudioSettingsSchema, clipFilesListSchema, cameraOptionsSchema, } from './types/CamSwitcherAPI';
@@ -31,15 +31,13 @@ export class CamSwitcherAPI extends BasicAPI {
31
31
  return networkCameraListSchema.parse(res.data);
32
32
  }
33
33
  async generateSilence(sampleRate, channels, options) {
34
- const agent = this.getClient(options?.proxyParams);
35
- await agent.get({
36
- path: `${BASE_PATH}/generate_silence.cgi`,
37
- parameters: {
38
- sample_rate: sampleRate.toString(),
39
- channels,
40
- },
41
- timeout: options?.timeout,
42
- });
34
+ const res = await this._getJson(`${BASE_PATH}/generate_silence.cgi`, {
35
+ sample_rate: sampleRate.toString(),
36
+ channels,
37
+ }, options);
38
+ if (res.status !== 200) {
39
+ throw new GenerateSilenceError(res.message);
40
+ }
43
41
  }
44
42
  async getMaxFps(source, options) {
45
43
  const res = await this._getJson(`${BASE_PATH}/get_max_framerate.cgi`, {
@@ -201,11 +199,7 @@ export class CamSwitcherAPI extends BasicAPI {
201
199
  async getCamSwitchOptions(options) {
202
200
  const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS, options);
203
201
  if (isNullish(saveData.video)) {
204
- return cameraOptionsSchema.parse({
205
- audioSampleRate: saveData.audio?.sampleRate,
206
- audioChannelCount: saveData.audio?.channelCount,
207
- keyboard: saveData.keyboard,
208
- });
202
+ return;
209
203
  }
210
204
  const settings = {
211
205
  audioSampleRate: saveData.audio?.sampleRate,
@@ -0,0 +1,2 @@
1
+ export * from './index';
2
+ export * from './web/index';
@@ -94,6 +94,12 @@ export class AddNewClipError extends Error {
94
94
  this.name = 'AddNewClipError';
95
95
  }
96
96
  }
97
+ export class GenerateSilenceError extends Error {
98
+ constructor(message) {
99
+ super('Error generating silence clip: ' + message);
100
+ this.name = 'GenerateSilenceError';
101
+ }
102
+ }
97
103
  export class PtzNotSupportedError extends Error {
98
104
  constructor() {
99
105
  super('Ptz not supported.');
@@ -3,10 +3,11 @@ import { WsClient } from './WsClient';
3
3
  export class CamOverlayDrawingAPI extends EventEmitter {
4
4
  tls;
5
5
  tlsInsecure;
6
- ip;
6
+ host;
7
7
  port;
8
8
  user;
9
9
  pass;
10
+ headers;
10
11
  cameraList;
11
12
  zIndex;
12
13
  callId;
@@ -18,10 +19,11 @@ export class CamOverlayDrawingAPI extends EventEmitter {
18
19
  super();
19
20
  this.tls = options?.tls ?? false;
20
21
  this.tlsInsecure = options?.tlsInsecure ?? false;
21
- this.ip = options?.ip ?? '127.0.0.1';
22
+ this.host = options?.host ?? options?.ip ?? '127.0.0.1';
22
23
  this.port = options?.port ?? (this.tls ? 443 : 80);
23
24
  this.user = options?.user ?? '';
24
25
  this.pass = options?.pass ?? '';
26
+ this.headers = options?.headers;
25
27
  this.zIndex = options?.zIndex ?? 0;
26
28
  this.cameraList = [0];
27
29
  if (options && Array.isArray(options.camera)) {
@@ -88,7 +90,7 @@ export class CamOverlayDrawingAPI extends EventEmitter {
88
90
  }
89
91
  createWsClient() {
90
92
  const options = {
91
- ip: this.ip,
93
+ host: this.host,
92
94
  port: this.port,
93
95
  address: '/local/camoverlay/ws',
94
96
  protocol: 'cairo-api',
@@ -96,6 +98,7 @@ export class CamOverlayDrawingAPI extends EventEmitter {
96
98
  pass: this.pass,
97
99
  tls: this.tls,
98
100
  tlsInsecure: this.tlsInsecure,
101
+ headers: this.headers,
99
102
  };
100
103
  this.ws = new WsClient(options);
101
104
  this.ws.onOpen = () => {
@@ -3,10 +3,11 @@ import { WsClient } from './WsClient';
3
3
  export class CamScripterAPICameraEventsGenerator extends EventEmitter {
4
4
  tls;
5
5
  tlsInsecure;
6
- ip;
6
+ host;
7
7
  port;
8
8
  user;
9
9
  pass;
10
+ headers;
10
11
  callId;
11
12
  sendMessages;
12
13
  timeoutCheckTimer;
@@ -16,10 +17,11 @@ export class CamScripterAPICameraEventsGenerator extends EventEmitter {
16
17
  super();
17
18
  this.tls = options?.tls ?? false;
18
19
  this.tlsInsecure = options?.tlsInsecure ?? false;
19
- this.ip = options?.ip ?? '127.0.0.1';
20
+ this.host = options?.host ?? options?.ip ?? '127.0.0.1';
20
21
  this.port = options?.port ?? (this.tls ? 443 : 80);
21
22
  this.user = options?.user ?? '';
22
23
  this.pass = options?.pass ?? '';
24
+ this.headers = options?.headers;
23
25
  this.callId = 0;
24
26
  this.sendMessages = {};
25
27
  this.wsConnected = false;
@@ -61,10 +63,11 @@ export class CamScripterAPICameraEventsGenerator extends EventEmitter {
61
63
  pass: this.pass,
62
64
  tlsInsecure: this.tlsInsecure,
63
65
  tls: this.tls,
64
- ip: this.ip,
66
+ host: this.host,
65
67
  port: this.port,
66
68
  address: `/local/camscripter/ws`,
67
69
  protocol: 'camera-events',
70
+ headers: this.headers,
68
71
  };
69
72
  this.ws = new WsClient(options);
70
73
  this.ws.onOpen = () => {
@@ -2,17 +2,19 @@ import { addParametersToPath } from '../internal/utils';
2
2
  import { HttpRequestSender } from './HttpRequestSender';
3
3
  export class DefaultClient {
4
4
  tls;
5
- ip;
5
+ host;
6
6
  port;
7
7
  user;
8
8
  pass;
9
+ headers;
9
10
  httpRequestSender;
10
11
  constructor(opt = {}) {
11
12
  this.tls = opt.tls ?? false;
12
- this.ip = opt.ip ?? '127.0.0.1';
13
+ this.host = opt.host ?? opt.ip ?? '127.0.0.1';
13
14
  this.port = opt.port ?? (this.tls ? 443 : 80);
14
- this.user = opt.user ?? '';
15
- this.pass = opt.pass ?? '';
15
+ this.user = opt.user;
16
+ this.pass = opt.pass;
17
+ this.headers = opt.headers ?? {};
16
18
  let agentOptions;
17
19
  if (opt.tlsInsecure !== undefined || opt.keepAlive !== undefined) {
18
20
  agentOptions = {
@@ -36,12 +38,12 @@ export class DefaultClient {
36
38
  return {
37
39
  method: method,
38
40
  protocol: this.tls ? 'https:' : 'http:',
39
- host: this.ip,
41
+ host: this.host,
40
42
  port: this.port,
41
43
  path: addParametersToPath(path, params),
42
44
  user: this.user,
43
45
  pass: this.pass,
44
- headers,
46
+ headers: { ...this.headers, ...headers },
45
47
  timeout,
46
48
  };
47
49
  }
@@ -0,0 +1,11 @@
1
+ import { DefaultClient } from './DefaultClient';
2
+ export class DeviceConnectClient extends DefaultClient {
3
+ constructor(deviceAccessToken, host, opt = {}) {
4
+ super({
5
+ ...opt,
6
+ tls: true,
7
+ host: host,
8
+ headers: { authorization: `Bearer ${deviceAccessToken}` },
9
+ });
10
+ }
11
+ }
@@ -0,0 +1,17 @@
1
+ import { WsClient } from './WsClient';
2
+ export class DeviceConnectWsClient extends WsClient {
3
+ constructor(deviceAccessToken, host, opt) {
4
+ const andChar = opt.path.includes('?') ? '&' : '?';
5
+ super({
6
+ ...opt,
7
+ tls: true,
8
+ host: host,
9
+ address: `${opt.path}${andChar}DEVICE_ACCESS_TOKEN=${deviceAccessToken}`,
10
+ });
11
+ this.wsOptions = {
12
+ auth: undefined,
13
+ rejectUnauthorized: !opt.tlsInsecure,
14
+ headers: { ...opt.headers },
15
+ };
16
+ }
17
+ }
@@ -3,19 +3,21 @@ import { WsClient } from './WsClient';
3
3
  export class VapixEvents extends EventEmitter {
4
4
  tls;
5
5
  tlsInsecure;
6
- ip;
6
+ host;
7
7
  port;
8
8
  user;
9
9
  pass;
10
+ headers;
10
11
  ws;
11
12
  constructor(options = {}) {
12
13
  super();
13
14
  this.tls = options.tls ?? false;
14
15
  this.tlsInsecure = options.tlsInsecure ?? false;
15
- this.ip = options.ip ?? '127.0.0.1';
16
+ this.host = options.host ?? options.ip ?? '127.0.0.1';
16
17
  this.port = options.port ?? (this.tls ? 443 : 80);
17
18
  this.user = options.user ?? 'root';
18
19
  this.pass = options.pass ?? '';
20
+ this.headers = options.headers;
19
21
  this.createWsClient();
20
22
  EventEmitter.call(this);
21
23
  }
@@ -31,9 +33,10 @@ export class VapixEvents extends EventEmitter {
31
33
  tlsInsecure: this.tlsInsecure,
32
34
  user: this.user,
33
35
  pass: this.pass,
34
- ip: this.ip,
36
+ host: this.host,
35
37
  port: this.port,
36
38
  address: '/vapix/ws-data-stream?sources=events',
39
+ headers: this.headers,
37
40
  };
38
41
  this.ws = new WsClient(options);
39
42
  this.ws.onOpen = () => {
@@ -15,12 +15,12 @@ export class WsClient {
15
15
  constructor(options) {
16
16
  const tls = options.tls ?? false;
17
17
  const tlsInsecure = options.tlsInsecure ?? false;
18
- const ip = options.ip ?? '127.0.0.1';
18
+ const host = options.host ?? options.ip ?? '127.0.0.1';
19
19
  const port = options.port ?? (tls ? 443 : 80);
20
20
  this.user = options.user ?? '';
21
21
  this.pass = options.pass ?? '';
22
22
  const protocol = tls ? 'wss' : 'ws';
23
- this.address = `${protocol}://${ip}:${port}${options.address}`;
23
+ this.address = `${protocol}://${host}:${port}${options.address}`;
24
24
  this.digestAddress = options.address;
25
25
  this.pingInterval = options.pingInterval ?? 30000;
26
26
  this.protocol = options.protocol;
@@ -58,7 +58,7 @@ export class WsClient {
58
58
  this.isAlive = true;
59
59
  });
60
60
  if (wwwAuthenticateHeader !== undefined) {
61
- this.wsOptions.headers['Authorization'] = new Digest().getAuthHeader(this.user, this.pass, 'GET', this.digestAddress, wwwAuthenticateHeader);
61
+ this.wsOptions.headers['authorization'] = new Digest().getAuthHeader(this.user, this.pass, 'GET', this.digestAddress, wwwAuthenticateHeader);
62
62
  }
63
63
  this.ws.on('unexpected-response', (req, res) => {
64
64
  if (res.statusCode === 401 && res.headers['www-authenticate'] !== undefined) {
package/esm/node/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './DefaultClient';
2
+ export * from './DeviceConnectClient';
3
+ export { DeviceConnectWsClient } from './DeviceConnectWsClient';
2
4
  export * from './WsClient';
3
5
  export * from './HttpServer';
4
6
  export * from './HttpRequestSender';
@@ -369,6 +369,7 @@ export const zonesSchema = z.object({
369
369
  minSpeedKmph: z.number().optional(),
370
370
  maxSpeedKmph: z.number().optional(),
371
371
  flightDirection: z.enum(['all', 'arrival', 'departure']).default('all'),
372
+ runwayDirectionDeg: z.number().min(0).max(360).optional(),
372
373
  weight: z.number(),
373
374
  perimeter: zonePerimeterSchema.default('none'),
374
375
  trackingDomains: z.array(domainIdSchema).default(['adsb', 'remoteId']),
@@ -1,20 +1,22 @@
1
1
  import { addParametersToPath } from '../internal/utils';
2
2
  export class DefaultClient {
3
3
  domain;
4
- constructor(domain = '') {
4
+ headers;
5
+ constructor(domain = '', headers = {}) {
5
6
  this.domain = domain;
7
+ this.headers = headers;
6
8
  }
7
9
  get = (params) => {
8
10
  return this.fetchWithTimeout(addParametersToPath(params.path, params.parameters), {
9
11
  method: 'GET',
10
- headers: params.headers,
12
+ headers: { ...this.headers, ...params.headers },
11
13
  }, params.timeout);
12
14
  };
13
15
  post = (params) => {
14
16
  return this.fetchWithTimeout(addParametersToPath(params.path, params.parameters), {
15
17
  method: 'POST',
16
18
  body: params.data,
17
- headers: params.headers,
19
+ headers: { ...this.headers, ...params.headers },
18
20
  }, params.timeout);
19
21
  };
20
22
  async fetchWithTimeout(path, options, timeout) {
@@ -0,0 +1,6 @@
1
+ import { DefaultClient } from './DefaultClient';
2
+ export class DeviceConnectClient extends DefaultClient {
3
+ constructor(deviceAccessToken, host) {
4
+ super(`https://${host}`, { authorization: `Bearer ${deviceAccessToken}` });
5
+ }
6
+ }
@@ -0,0 +1,10 @@
1
+ import { WsClient } from './WsClient';
2
+ export class DeviceConnectWsClient extends WsClient {
3
+ constructor(deviceAccessToken, host, getPath) {
4
+ super(() => {
5
+ const path = getPath();
6
+ const andChar = path.includes('?') ? '&' : '?';
7
+ return `wss://${host}${path}${andChar}DEVICE_ACCESS_TOKEN=${deviceAccessToken}`;
8
+ });
9
+ }
10
+ }
package/esm/web/index.js CHANGED
@@ -1,2 +1,4 @@
1
1
  export { DefaultClient } from './DefaultClient';
2
+ export { DeviceConnectClient } from './DeviceConnectClient';
3
+ export { DeviceConnectWsClient } from './DeviceConnectWsClient';
2
4
  export { WsClient } from './WsClient';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.31-e0ed433",
3
+ "version": "4.0.32-894be2d",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "engine": {
@@ -24,6 +24,7 @@
24
24
  "@types/ws": "^8.5.10",
25
25
  "@typescript-eslint/eslint-plugin": "^6.8.0",
26
26
  "@typescript-eslint/parser": "^6.8.0",
27
+ "esbuild": "^0.28.2",
27
28
  "eslint": "^8.51.0",
28
29
  "eslint-plugin-deprecation": "^2.0.0",
29
30
  "eslint-plugin-unused-imports": "^3.0.0",
@@ -42,6 +43,7 @@
42
43
  "build": "npm-run-all clean build:cjs build:esm copyPackage",
43
44
  "build:cjs": "tsc --project tsconfig.cjs.json",
44
45
  "build:esm": "tsc --project tsconfig.esm.json",
46
+ "build:browser": "esbuild src/browser.index.ts --bundle --format=esm --platform=browser --target=es2022 --outfile=examples/camstreamerlib.js",
45
47
  "copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/",
46
48
  "publishPackage": "./publish.sh",
47
49
  "lint": "eslint \"src/**/*.ts\"",
@@ -53,7 +55,8 @@
53
55
  },
54
56
  "files": [
55
57
  "/**/*.js",
56
- "/**/*.ts"
58
+ "/**/*.ts",
59
+ "/examples/**/*"
57
60
  ],
58
61
  "main": "./cjs/index.js",
59
62
  "module": "./esm/index.js",