camstreamerlib 4.0.29 → 4.0.30

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.
@@ -9,6 +9,7 @@ const CamSwitcherAPI_1 = require("./types/CamSwitcherAPI");
9
9
  const common_1 = require("./types/common");
10
10
  const VapixAPI_1 = require("./VapixAPI");
11
11
  const BasicAPI_1 = require("./internal/BasicAPI");
12
+ const helpers_1 = require("./helpers");
12
13
  const BASE_PATH = '/local/camswitcher/api';
13
14
  class CamSwitcherAPI extends BasicAPI_1.BasicAPI {
14
15
  CustomFormData;
@@ -273,20 +274,7 @@ class CamSwitcherAPI extends BasicAPI_1.BasicAPI {
273
274
  if (data[paramName] === undefined) {
274
275
  throw new errors_1.ParameterNotFoundError(paramName);
275
276
  }
276
- if (data[paramName] === '') {
277
- return {};
278
- }
279
- try {
280
- return JSON.parse(data[paramName] + '');
281
- }
282
- catch {
283
- try {
284
- return JSON.parse(decodeURIComponent((data[paramName] + '').replaceAll('\\', '')));
285
- }
286
- catch (e) {
287
- throw new errors_1.JsonParseError(paramName, data[paramName]);
288
- }
289
- }
277
+ return (0, helpers_1.jsonParseCameraParam)(data[paramName] + '', paramName);
290
278
  }
291
279
  async getUploadedFileList(clipName, storage, options) {
292
280
  const res = await this._getJson(`${BASE_PATH}/clip_files.cgi`, { clip_name: clipName, storage }, options);
@@ -0,0 +1 @@
1
+ export declare const jsonParseCameraParam: (param: string, paramName: string) => any;
package/cjs/helpers.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jsonParseCameraParam = void 0;
4
+ const errors_1 = require("./errors/errors");
5
+ const jsonParseCameraParam = (param, paramName) => {
6
+ if (param === '') {
7
+ return {};
8
+ }
9
+ try {
10
+ return JSON.parse(param);
11
+ }
12
+ catch {
13
+ try {
14
+ return JSON.parse(decodeURIComponent(param.replaceAll('\\', '')));
15
+ }
16
+ catch (e) {
17
+ throw new errors_1.JsonParseError(paramName, param);
18
+ }
19
+ }
20
+ };
21
+ exports.jsonParseCameraParam = jsonParseCameraParam;
package/cjs/index.d.ts CHANGED
@@ -26,3 +26,4 @@ export { CamScripterAPI } from './CamScripterAPI';
26
26
  export * from './types/CamScripterAPI';
27
27
  export { VapixAPI } from './VapixAPI';
28
28
  export * from './types/VapixAPI';
29
+ export * from './helpers';
package/cjs/index.js CHANGED
@@ -53,3 +53,4 @@ __exportStar(require("./types/CamScripterAPI"), exports);
53
53
  var VapixAPI_1 = require("./VapixAPI");
54
54
  Object.defineProperty(exports, "VapixAPI", { enumerable: true, get: function () { return VapixAPI_1.VapixAPI; } });
55
55
  __exportStar(require("./types/VapixAPI"), exports);
56
+ __exportStar(require("./helpers"), exports);
@@ -1,11 +1,12 @@
1
1
  import { z } from 'zod';
2
- import { AddNewClipError, JsonParseError, ParameterNotFoundError } from './errors/errors';
2
+ import { AddNewClipError, 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, } from './types/CamSwitcherAPI';
6
6
  import { networkCameraListSchema, } from './types/common';
7
7
  import { VapixAPI } from './VapixAPI';
8
8
  import { BasicAPI } from './internal/BasicAPI';
9
+ import { jsonParseCameraParam } from './helpers';
9
10
  const BASE_PATH = '/local/camswitcher/api';
10
11
  export class CamSwitcherAPI extends BasicAPI {
11
12
  CustomFormData;
@@ -270,20 +271,7 @@ export class CamSwitcherAPI extends BasicAPI {
270
271
  if (data[paramName] === undefined) {
271
272
  throw new ParameterNotFoundError(paramName);
272
273
  }
273
- if (data[paramName] === '') {
274
- return {};
275
- }
276
- try {
277
- return JSON.parse(data[paramName] + '');
278
- }
279
- catch {
280
- try {
281
- return JSON.parse(decodeURIComponent((data[paramName] + '').replaceAll('\\', '')));
282
- }
283
- catch (e) {
284
- throw new JsonParseError(paramName, data[paramName]);
285
- }
286
- }
274
+ return jsonParseCameraParam(data[paramName] + '', paramName);
287
275
  }
288
276
  async getUploadedFileList(clipName, storage, options) {
289
277
  const res = await this._getJson(`${BASE_PATH}/clip_files.cgi`, { clip_name: clipName, storage }, options);
package/esm/helpers.js ADDED
@@ -0,0 +1,17 @@
1
+ import { JsonParseError } from './errors/errors';
2
+ export const jsonParseCameraParam = (param, paramName) => {
3
+ if (param === '') {
4
+ return {};
5
+ }
6
+ try {
7
+ return JSON.parse(param);
8
+ }
9
+ catch {
10
+ try {
11
+ return JSON.parse(decodeURIComponent(param.replaceAll('\\', '')));
12
+ }
13
+ catch (e) {
14
+ throw new JsonParseError(paramName, param);
15
+ }
16
+ }
17
+ };
package/esm/index.js CHANGED
@@ -26,3 +26,4 @@ export { CamScripterAPI } from './CamScripterAPI';
26
26
  export * from './types/CamScripterAPI';
27
27
  export { VapixAPI } from './VapixAPI';
28
28
  export * from './types/VapixAPI';
29
+ export * from './helpers';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.29",
3
+ "version": "4.0.30",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "engine": {
@@ -0,0 +1 @@
1
+ export declare const jsonParseCameraParam: (param: string, paramName: string) => any;
package/types/index.d.ts CHANGED
@@ -26,3 +26,4 @@ export { CamScripterAPI } from './CamScripterAPI';
26
26
  export * from './types/CamScripterAPI';
27
27
  export { VapixAPI } from './VapixAPI';
28
28
  export * from './types/VapixAPI';
29
+ export * from './helpers';