camstreamerlib 4.0.31 → 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.
@@ -161,7 +161,7 @@ export declare class CamSwitcherAPI<Client extends IClient<TResponse, any>> exte
161
161
  bitrateVapixParams?: string | null | undefined;
162
162
  audioSampleRate?: number | undefined;
163
163
  audioChannelCount?: 1 | 2 | undefined;
164
- }>;
164
+ } | undefined>;
165
165
  getGlobalAudioSettings(options?: THttpRequestOptions): Promise<{
166
166
  type: "source" | "fromSource";
167
167
  source: string;
@@ -34,15 +34,13 @@ class CamSwitcherAPI extends BasicAPI_1.BasicAPI {
34
34
  return common_1.networkCameraListSchema.parse(res.data);
35
35
  }
36
36
  async generateSilence(sampleRate, channels, options) {
37
- const agent = this.getClient(options?.proxyParams);
38
- await agent.get({
39
- path: `${BASE_PATH}/generate_silence.cgi`,
40
- parameters: {
41
- sample_rate: sampleRate.toString(),
42
- channels,
43
- },
44
- timeout: options?.timeout,
45
- });
37
+ const res = await this._getJson(`${BASE_PATH}/generate_silence.cgi`, {
38
+ sample_rate: sampleRate.toString(),
39
+ channels,
40
+ }, options);
41
+ if (res.status !== 200) {
42
+ throw new errors_1.GenerateSilenceError(res.message);
43
+ }
46
44
  }
47
45
  async getMaxFps(source, options) {
48
46
  const res = await this._getJson(`${BASE_PATH}/get_max_framerate.cgi`, {
@@ -204,11 +202,7 @@ class CamSwitcherAPI extends BasicAPI_1.BasicAPI {
204
202
  async getCamSwitchOptions(options) {
205
203
  const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS, options);
206
204
  if ((0, utils_1.isNullish)(saveData.video)) {
207
- return CamSwitcherAPI_1.cameraOptionsSchema.parse({
208
- audioSampleRate: saveData.audio?.sampleRate,
209
- audioChannelCount: saveData.audio?.channelCount,
210
- keyboard: saveData.keyboard,
211
- });
205
+ return;
212
206
  }
213
207
  const settings = {
214
208
  audioSampleRate: saveData.audio?.sampleRate,
@@ -0,0 +1,2 @@
1
+ export * from './index';
2
+ export * from './web/index';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./index"), exports);
18
+ __exportStar(require("./web/index"), exports);
@@ -49,6 +49,9 @@ export declare class FetchDeviceInfoError extends Error {
49
49
  export declare class AddNewClipError extends Error {
50
50
  constructor(message: string);
51
51
  }
52
+ export declare class GenerateSilenceError extends Error {
53
+ constructor(message: string);
54
+ }
52
55
  export declare class PtzNotSupportedError extends Error {
53
56
  constructor();
54
57
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MigrationError = exports.BadRequestError = exports.ServerError = exports.InvalidAltitudeError = exports.InvalidLatLngError = exports.CannotSetCoordsInAutoModeError = exports.ImportSettingsError = exports.ResetCalibrationError = exports.TimezoneFetchError = exports.TimezoneNotSetupError = exports.UtcTimeFetchError = exports.WsAuthorizationError = exports.StorageDataFetchError = exports.PtzNotSupportedError = exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.SettingParameterError = exports.ParameterNotFoundError = exports.JsonParseError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = exports.ErrorWithResponse = void 0;
3
+ exports.MigrationError = exports.BadRequestError = exports.ServerError = exports.InvalidAltitudeError = exports.InvalidLatLngError = exports.CannotSetCoordsInAutoModeError = exports.ImportSettingsError = exports.ResetCalibrationError = exports.TimezoneFetchError = exports.TimezoneNotSetupError = exports.UtcTimeFetchError = exports.WsAuthorizationError = exports.StorageDataFetchError = exports.PtzNotSupportedError = exports.GenerateSilenceError = exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.SettingParameterError = exports.ParameterNotFoundError = exports.JsonParseError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = exports.ErrorWithResponse = void 0;
4
4
  class ErrorWithResponse extends Error {
5
5
  res;
6
6
  constructor(res) {
@@ -111,6 +111,13 @@ class AddNewClipError extends Error {
111
111
  }
112
112
  }
113
113
  exports.AddNewClipError = AddNewClipError;
114
+ class GenerateSilenceError extends Error {
115
+ constructor(message) {
116
+ super('Error generating silence clip: ' + message);
117
+ this.name = 'GenerateSilenceError';
118
+ }
119
+ }
120
+ exports.GenerateSilenceError = GenerateSilenceError;
114
121
  class PtzNotSupportedError extends Error {
115
122
  constructor() {
116
123
  super('Ptz not supported.');
@@ -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.');
package/package.json CHANGED
@@ -1,110 +1,113 @@
1
1
  {
2
- "name": "camstreamerlib",
3
- "version": "4.0.31",
4
- "description": "Helper library for CamStreamer ACAP applications.",
5
- "prettier": "@camstreamer/prettier-config",
6
- "engine": {
7
- "node": ">=18.0.0"
2
+ "name": "camstreamerlib",
3
+ "version": "4.0.32-894be2d",
4
+ "description": "Helper library for CamStreamer ACAP applications.",
5
+ "prettier": "@camstreamer/prettier-config",
6
+ "engine": {
7
+ "node": ">=18.0.0"
8
+ },
9
+ "dependencies": {
10
+ "adm-zip": "^0.6.0",
11
+ "eventemitter2": "^5.0.1",
12
+ "fast-xml-parser": "^5.3.6",
13
+ "type-fest": "^4.41.0",
14
+ "undici": "^6.28.0",
15
+ "ws": "^8.18.0",
16
+ "zod": "^3.25.76"
17
+ },
18
+ "devDependencies": {
19
+ "@camstreamer/eslint-config": "^1.0.2",
20
+ "@camstreamer/prettier-config": "^2.0.4",
21
+ "@types/adm-zip": "^0.5.5",
22
+ "@types/jest": "^28.0.0",
23
+ "@types/node": "^18.19.127",
24
+ "@types/ws": "^8.5.10",
25
+ "@typescript-eslint/eslint-plugin": "^6.8.0",
26
+ "@typescript-eslint/parser": "^6.8.0",
27
+ "esbuild": "^0.28.2",
28
+ "eslint": "^8.51.0",
29
+ "eslint-plugin-deprecation": "^2.0.0",
30
+ "eslint-plugin-unused-imports": "^3.0.0",
31
+ "jest": "^28.1.3",
32
+ "npm-run-all": "^4.1.5",
33
+ "prettier": "^2.7.1",
34
+ "ts-jest": "^28.0.0",
35
+ "ts-node": "^10.7.0",
36
+ "typescript": "5.3.3"
37
+ },
38
+ "overrides": {
39
+ "js-yaml": "^4.2.0"
40
+ },
41
+ "scripts": {
42
+ "clean": "rimraf dist/*",
43
+ "build": "npm-run-all clean build:cjs build:esm copyPackage",
44
+ "build:cjs": "tsc --project tsconfig.cjs.json",
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",
47
+ "copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/",
48
+ "publishPackage": "./publish.sh",
49
+ "lint": "eslint \"src/**/*.ts\"",
50
+ "lint:fix": "eslint \"src/**/*.ts\" --fix",
51
+ "pretty": "prettier --write \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
52
+ "pretty:check": "prettier --check \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
53
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
54
+ "audit": "npm audit --audit-level=high"
55
+ },
56
+ "files": [
57
+ "/**/*.js",
58
+ "/**/*.ts",
59
+ "/examples/**/*"
60
+ ],
61
+ "main": "./cjs/index.js",
62
+ "module": "./esm/index.js",
63
+ "types": "types/index.d.ts",
64
+ "exports": {
65
+ ".": {
66
+ "import": "./esm/index.js",
67
+ "require": "./cjs/index.js",
68
+ "types": "./types/index.d.ts"
8
69
  },
9
- "dependencies": {
10
- "adm-zip": "^0.6.0",
11
- "eventemitter2": "^5.0.1",
12
- "fast-xml-parser": "^5.3.6",
13
- "type-fest": "^4.41.0",
14
- "undici": "^6.28.0",
15
- "ws": "^8.18.0",
16
- "zod": "^3.25.76"
70
+ "./web": {
71
+ "import": "./esm/web/index.js",
72
+ "require": "./cjs/web/index.js",
73
+ "types": "./types/web/index.d.ts"
17
74
  },
18
- "devDependencies": {
19
- "@camstreamer/eslint-config": "^1.0.2",
20
- "@camstreamer/prettier-config": "^2.0.4",
21
- "@types/adm-zip": "^0.5.5",
22
- "@types/jest": "^28.0.0",
23
- "@types/node": "^18.19.127",
24
- "@types/ws": "^8.5.10",
25
- "@typescript-eslint/eslint-plugin": "^6.8.0",
26
- "@typescript-eslint/parser": "^6.8.0",
27
- "eslint": "^8.51.0",
28
- "eslint-plugin-deprecation": "^2.0.0",
29
- "eslint-plugin-unused-imports": "^3.0.0",
30
- "jest": "^28.1.3",
31
- "npm-run-all": "^4.1.5",
32
- "prettier": "^2.7.1",
33
- "ts-jest": "^28.0.0",
34
- "ts-node": "^10.7.0",
35
- "typescript": "5.3.3"
75
+ "./node": {
76
+ "import": "./esm/node/index.js",
77
+ "require": "./cjs/node/index.js",
78
+ "types": "./types/node/index.d.ts"
36
79
  },
37
- "overrides": {
38
- "js-yaml": "^4.2.0"
80
+ "./cjs/index": {
81
+ "import": "./esm/index.js",
82
+ "require": "./cjs/index.js",
83
+ "types": "./types/index.d.ts"
39
84
  },
40
- "scripts": {
41
- "clean": "rimraf dist/*",
42
- "build": "npm-run-all clean build:cjs build:esm copyPackage",
43
- "build:cjs": "tsc --project tsconfig.cjs.json",
44
- "build:esm": "tsc --project tsconfig.esm.json",
45
- "copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/",
46
- "publishPackage": "./publish.sh",
47
- "lint": "eslint \"src/**/*.ts\"",
48
- "lint:fix": "eslint \"src/**/*.ts\" --fix",
49
- "pretty": "prettier --write \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
50
- "pretty:check": "prettier --check \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
51
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
52
- "audit": "npm audit --audit-level=high"
85
+ "./cjs/node": {
86
+ "import": "./esm/node/index.js",
87
+ "require": "./cjs/node/index.js",
88
+ "types": "./types/node/index.js"
53
89
  },
54
- "files": [
55
- "/**/*.js",
56
- "/**/*.ts"
57
- ],
58
- "main": "./cjs/index.js",
59
- "module": "./esm/index.js",
60
- "types": "types/index.d.ts",
61
- "exports": {
62
- ".": {
63
- "import": "./esm/index.js",
64
- "require": "./cjs/index.js",
65
- "types": "./types/index.d.ts"
66
- },
67
- "./web": {
68
- "import": "./esm/web/index.js",
69
- "require": "./cjs/web/index.js",
70
- "types": "./types/web/index.d.ts"
71
- },
72
- "./node": {
73
- "import": "./esm/node/index.js",
74
- "require": "./cjs/node/index.js",
75
- "types": "./types/node/index.d.ts"
76
- },
77
- "./cjs/index": {
78
- "import": "./esm/index.js",
79
- "require": "./cjs/index.js",
80
- "types": "./types/index.d.ts"
81
- },
82
- "./cjs/node": {
83
- "import": "./esm/node/index.js",
84
- "require": "./cjs/node/index.js",
85
- "types": "./types/node/index.js"
86
- },
87
- "./cjs/node/index": {
88
- "import": "./esm/node/index.js",
89
- "require": "./cjs/node/index.js",
90
- "types": "./types/node/index.js"
91
- }
92
- },
93
- "repository": {
94
- "type": "git",
95
- "url": "git+https://github.com/CamStreamer/CamStreamerLib.git"
96
- },
97
- "keywords": [
98
- "CamStreamer",
99
- "CamOverlay",
100
- "CamScripter",
101
- "Camera",
102
- "Axis"
103
- ],
104
- "author": "CamStreamer s.r.o",
105
- "license": "ISC",
106
- "bugs": {
107
- "url": "https://github.com/CamStreamer/CamStreamerLib/issues"
108
- },
109
- "homepage": "https://github.com/CamStreamer/CamStreamerLib#readme"
90
+ "./cjs/node/index": {
91
+ "import": "./esm/node/index.js",
92
+ "require": "./cjs/node/index.js",
93
+ "types": "./types/node/index.js"
94
+ }
95
+ },
96
+ "repository": {
97
+ "type": "git",
98
+ "url": "git+https://github.com/CamStreamer/CamStreamerLib.git"
99
+ },
100
+ "keywords": [
101
+ "CamStreamer",
102
+ "CamOverlay",
103
+ "CamScripter",
104
+ "Camera",
105
+ "Axis"
106
+ ],
107
+ "author": "CamStreamer s.r.o",
108
+ "license": "ISC",
109
+ "bugs": {
110
+ "url": "https://github.com/CamStreamer/CamStreamerLib/issues"
111
+ },
112
+ "homepage": "https://github.com/CamStreamer/CamStreamerLib#readme"
110
113
  }
@@ -161,7 +161,7 @@ export declare class CamSwitcherAPI<Client extends IClient<TResponse, any>> exte
161
161
  bitrateVapixParams?: string | null | undefined;
162
162
  audioSampleRate?: number | undefined;
163
163
  audioChannelCount?: 1 | 2 | undefined;
164
- }>;
164
+ } | undefined>;
165
165
  getGlobalAudioSettings(options?: THttpRequestOptions): Promise<{
166
166
  type: "source" | "fromSource";
167
167
  source: string;
@@ -0,0 +1,2 @@
1
+ export * from './index';
2
+ export * from './web/index';
@@ -49,6 +49,9 @@ export declare class FetchDeviceInfoError extends Error {
49
49
  export declare class AddNewClipError extends Error {
50
50
  constructor(message: string);
51
51
  }
52
+ export declare class GenerateSilenceError extends Error {
53
+ constructor(message: string);
54
+ }
52
55
  export declare class PtzNotSupportedError extends Error {
53
56
  constructor();
54
57
  }