camstreamerlib 2.0.6 → 3.0.0

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.
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ResourceManager = exports.Frame = exports.Painter = exports.COORD = void 0;
13
+ const CamOverlayDrawingAPI_1 = require("../CamOverlayDrawingAPI");
14
+ const ResourceManager_1 = require("./ResourceManager");
15
+ exports.ResourceManager = ResourceManager_1.default;
16
+ const Frame_1 = require("./Frame");
17
+ Object.defineProperty(exports, "Frame", { enumerable: true, get: function () { return Frame_1.Frame; } });
18
+ exports.COORD = {
19
+ top_left: [-1, -1],
20
+ center_left: [-1, 0],
21
+ bottom_left: [-1, 1],
22
+ top_center: [0, -1],
23
+ center: [0, 0],
24
+ bottom_center: [0, 1],
25
+ top_right: [1, -1],
26
+ center_right: [1, 0],
27
+ bottom_right: [1, 1],
28
+ };
29
+ class Painter extends Frame_1.Frame {
30
+ get camOverlayDrawingAPI() {
31
+ return this.cod;
32
+ }
33
+ get resourceManager() {
34
+ return this.rm;
35
+ }
36
+ constructor(opt, coopt) {
37
+ super(opt);
38
+ this.coAlignment = exports.COORD[opt.coAlignment];
39
+ this.screenWidth = opt.screenWidth;
40
+ this.screenHeight = opt.screenHeight;
41
+ this.cod = new CamOverlayDrawingAPI_1.CamOverlayDrawingAPI(coopt);
42
+ this.rm = new ResourceManager_1.default(this.cod);
43
+ }
44
+ connect() {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ this.cod.on('open', () => {
47
+ this.rm.clear();
48
+ });
49
+ return this.cod.connect();
50
+ });
51
+ }
52
+ disconnect() {
53
+ this.cod.disconnect();
54
+ }
55
+ registerImage(moniker, fileName) {
56
+ this.rm.registerImage(moniker, fileName);
57
+ }
58
+ registerFont(moniker, fileName) {
59
+ this.rm.registerFont(moniker, fileName);
60
+ }
61
+ setScreenSize(sw, sh) {
62
+ this.screenWidth = sw;
63
+ this.screenHeight = sh;
64
+ }
65
+ setCoAlignment(coa) {
66
+ this.coAlignment = exports.COORD[coa];
67
+ }
68
+ display() {
69
+ return __awaiter(this, arguments, void 0, function* (scale = 1) {
70
+ if (this.enabled) {
71
+ [this.surface, this.cairo] = yield this.prepareDrawing(scale);
72
+ yield this.displayOwnImage(this.cod, this.rm, this.cairo, 0, 0, scale);
73
+ for (const child of this.children) {
74
+ yield child.displayImage(this.cod, this.rm, this.cairo, 0, 0, scale);
75
+ }
76
+ yield this.cod.showCairoImage(this.surface, this.positionConvertor(this.coAlignment[0], this.screenWidth, this.posX, scale * this.width), this.positionConvertor(this.coAlignment[1], this.screenHeight, this.posY, scale * this.height));
77
+ yield this.destroy();
78
+ }
79
+ });
80
+ }
81
+ hide() {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ yield this.cod.removeImage();
84
+ });
85
+ }
86
+ positionConvertor(alignment, screenSize, position, graphicsSize) {
87
+ switch (alignment) {
88
+ case -1:
89
+ return alignment + (2.0 * position) / screenSize;
90
+ case 0:
91
+ return alignment - (2.0 * (position + graphicsSize / 2)) / screenSize;
92
+ case 1:
93
+ return alignment - (2.0 * (position + graphicsSize)) / screenSize;
94
+ default:
95
+ throw new Error('Invalid graphics alignment.');
96
+ }
97
+ }
98
+ prepareDrawing(scale) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ const surface = (yield this.cod.cairo('cairo_image_surface_create', 'CAIRO_FORMAT_ARGB32', Math.floor(this.width * scale), Math.floor(this.height * scale)));
101
+ const cairo = (yield this.cod.cairo('cairo_create', surface.var));
102
+ return [surface.var, cairo.var];
103
+ });
104
+ }
105
+ destroy() {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ yield this.cod.cairo('cairo_surface_destroy', this.surface);
108
+ yield this.cod.cairo('cairo_destroy', this.cairo);
109
+ });
110
+ }
111
+ }
112
+ exports.default = Painter;
113
+ exports.Painter = Painter;
@@ -0,0 +1,14 @@
1
+ import { CamOverlayDrawingAPI, TUploadImageResponse, TCairoCreateResponse } from '../CamOverlayDrawingAPI';
2
+ export default class ResourceManager {
3
+ private co;
4
+ private imgFiles;
5
+ private fontFiles;
6
+ private images;
7
+ private fonts;
8
+ constructor(co: CamOverlayDrawingAPI);
9
+ image(moniker: string): Promise<TUploadImageResponse>;
10
+ font(moniker: string): Promise<TCairoCreateResponse>;
11
+ registerImage(moniker: string, fileName: string): void;
12
+ registerFont(moniker: string, fileName: string): void;
13
+ clear(): void;
14
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const fs = require("fs/promises");
13
+ class ResourceManager {
14
+ constructor(co) {
15
+ this.co = co;
16
+ this.imgFiles = {};
17
+ this.fontFiles = {};
18
+ this.images = {};
19
+ this.fonts = {};
20
+ }
21
+ image(moniker) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ if (moniker in this.images) {
24
+ return this.images[moniker];
25
+ }
26
+ else if (moniker in this.imgFiles) {
27
+ const imgData = yield fs.readFile(this.imgFiles[moniker]);
28
+ this.images[moniker] = yield this.co.uploadImageData(imgData);
29
+ return this.images[moniker];
30
+ }
31
+ else {
32
+ throw new Error('Error! Unknown image requested!');
33
+ }
34
+ });
35
+ }
36
+ font(moniker) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ if (moniker in this.fonts) {
39
+ return this.fonts[moniker];
40
+ }
41
+ else if (moniker in this.fontFiles) {
42
+ const fontData = yield fs.readFile(this.fontFiles[moniker]);
43
+ this.fonts[moniker] = yield this.co.uploadFontData(fontData);
44
+ return this.fonts[moniker];
45
+ }
46
+ else {
47
+ throw new Error('Error! Unknown font requested!');
48
+ }
49
+ });
50
+ }
51
+ registerImage(moniker, fileName) {
52
+ this.imgFiles[moniker] = process.env.INSTALL_PATH + '/images/' + fileName;
53
+ }
54
+ registerFont(moniker, fileName) {
55
+ this.fontFiles[moniker] = process.env.INSTALL_PATH + '/fonts/' + fileName;
56
+ }
57
+ clear() {
58
+ this.images = {};
59
+ this.fonts = {};
60
+ }
61
+ }
62
+ exports.default = ResourceManager;
@@ -1,8 +1,7 @@
1
- /// <reference types="node" />
2
1
  import * as EventEmitter from 'events';
3
- import { Options } from './common';
2
+ import { Options } from './internal/common';
4
3
  export type CamScripterOptions = Options;
5
- export type Declaration = {
4
+ export type TDeclaration = {
6
5
  type?: '' | 'SOURCE' | 'DATA';
7
6
  namespace: string;
8
7
  key: string;
@@ -11,25 +10,25 @@ export type Declaration = {
11
10
  key_nice_name?: string;
12
11
  value_nice_name?: string;
13
12
  };
14
- export type EventDeclaration = {
13
+ export type TEventDeclaration = {
15
14
  declaration_id: string;
16
15
  stateless: boolean;
17
- declaration: Declaration[];
16
+ declaration: TDeclaration[];
18
17
  };
19
- export type EventUndeclaration = {
18
+ export type TEventUndeclaration = {
20
19
  declaration_id: string;
21
20
  };
22
- export type EventData = {
21
+ export type TEventData = {
23
22
  namespace: string;
24
23
  key: string;
25
24
  value: string | boolean | number;
26
25
  value_type: 'STRING' | 'INT' | 'BOOL' | 'DOUBLE';
27
26
  };
28
- export type Event = {
27
+ export type TEvent = {
29
28
  declaration_id: string;
30
- event_data: EventData[];
29
+ event_data: TEventData[];
31
30
  };
32
- export type Response = {
31
+ export type TResponse = {
33
32
  call_id: number;
34
33
  message: string;
35
34
  };
@@ -38,15 +37,16 @@ export declare class CamScripterAPICameraEventsGenerator extends EventEmitter {
38
37
  private tlsInsecure;
39
38
  private ip;
40
39
  private port;
41
- private auth;
40
+ private user;
41
+ private pass;
42
42
  private callId;
43
43
  private sendMessages;
44
- private ws;
44
+ private ws?;
45
45
  constructor(options?: CamScripterOptions);
46
46
  connect(): Promise<void>;
47
- declareEvent(eventDeclaration: EventDeclaration): Promise<Response>;
48
- undeclareEvent(eventUndeclaration: EventUndeclaration): Promise<Response>;
49
- sendEvent(event: Event): Promise<Response>;
47
+ declareEvent(eventDeclaration: TEventDeclaration): Promise<TResponse>;
48
+ undeclareEvent(eventUndeclaration: TEventUndeclaration): Promise<TResponse>;
49
+ sendEvent(event: TEvent): Promise<TResponse>;
50
50
  private sendMessage;
51
51
  private openWebsocket;
52
52
  private reportErr;
@@ -11,17 +11,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CamScripterAPICameraEventsGenerator = void 0;
13
13
  const EventEmitter = require("events");
14
- const WsClient_1 = require("./WsClient");
14
+ const WsClient_1 = require("./internal/WsClient");
15
15
  class CamScripterAPICameraEventsGenerator extends EventEmitter {
16
16
  constructor(options) {
17
- var _a, _b, _c, _d, _e;
17
+ var _a, _b, _c, _d, _e, _f;
18
18
  super();
19
- this.ws = null;
20
19
  this.tls = (_a = options === null || options === void 0 ? void 0 : options.tls) !== null && _a !== void 0 ? _a : false;
21
20
  this.tlsInsecure = (_b = options === null || options === void 0 ? void 0 : options.tlsInsecure) !== null && _b !== void 0 ? _b : false;
22
21
  this.ip = (_c = options === null || options === void 0 ? void 0 : options.ip) !== null && _c !== void 0 ? _c : '127.0.0.1';
23
22
  this.port = (_d = options === null || options === void 0 ? void 0 : options.port) !== null && _d !== void 0 ? _d : (this.tls ? 443 : 80);
24
- this.auth = (_e = options === null || options === void 0 ? void 0 : options.auth) !== null && _e !== void 0 ? _e : '';
23
+ this.user = (_e = options === null || options === void 0 ? void 0 : options.user) !== null && _e !== void 0 ? _e : '';
24
+ this.pass = (_f = options === null || options === void 0 ? void 0 : options.pass) !== null && _f !== void 0 ? _f : '';
25
25
  this.callId = 0;
26
26
  this.sendMessages = {};
27
27
  EventEmitter.call(this);
@@ -60,6 +60,9 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
60
60
  }
61
61
  sendMessage(msgJson) {
62
62
  return new Promise((resolve, reject) => {
63
+ if (this.ws === undefined) {
64
+ throw new Error("Websocket hasn't been opened yet.");
65
+ }
63
66
  try {
64
67
  this.sendMessages[this.callId] = { resolve, reject };
65
68
  msgJson.call_id = this.callId++;
@@ -73,7 +76,8 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
73
76
  openWebsocket() {
74
77
  return new Promise((resolve, reject) => {
75
78
  const options = {
76
- auth: this.auth,
79
+ user: this.user,
80
+ pass: this.pass,
77
81
  tlsInsecure: this.tlsInsecure,
78
82
  tls: this.tls,
79
83
  ip: this.ip,
@@ -87,8 +91,8 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
87
91
  });
88
92
  this.ws.on('message', (data) => {
89
93
  const dataJSON = JSON.parse(data.toString());
90
- if (dataJSON.hasOwnProperty('call_id') && dataJSON['call_id'] in this.sendMessages) {
91
- if (dataJSON.hasOwnProperty('error')) {
94
+ if (Object.hasOwn(dataJSON, 'call_id') && dataJSON['call_id'] in this.sendMessages) {
95
+ if (Object.hasOwn(dataJSON, 'error')) {
92
96
  this.sendMessages[dataJSON['call_id']].reject(new Error(dataJSON.error));
93
97
  }
94
98
  else {
@@ -96,7 +100,7 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
96
100
  }
97
101
  delete this.sendMessages[dataJSON['call_id']];
98
102
  }
99
- if (dataJSON.hasOwnProperty('error')) {
103
+ if (Object.hasOwn(dataJSON, 'error')) {
100
104
  this.reportErr(new Error(dataJSON.error));
101
105
  }
102
106
  });
@@ -111,7 +115,8 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
111
115
  });
112
116
  }
113
117
  reportErr(err) {
114
- this.ws.close();
118
+ var _a;
119
+ (_a = this.ws) === null || _a === void 0 ? void 0 : _a.close();
115
120
  this.emit('error', err);
116
121
  }
117
122
  reportClose() {
@@ -1,11 +1,12 @@
1
- import { Options } from './common';
1
+ import { Options } from './internal/common';
2
2
  export type CamStreamerAPIOptions = Options;
3
3
  export declare class CamStreamerAPI {
4
4
  private tls;
5
5
  private tlsInsecure;
6
6
  private ip;
7
7
  private port;
8
- private auth;
8
+ private user;
9
+ private pass;
9
10
  constructor(options?: CamStreamerAPIOptions);
10
11
  getStreamList(): Promise<any>;
11
12
  getStreamParameter(streamID: string, paramName: string): Promise<any>;
package/CamStreamerAPI.js CHANGED
@@ -10,15 +10,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CamStreamerAPI = void 0;
13
- const HttpRequest_1 = require("./HttpRequest");
13
+ const HttpRequest_1 = require("./internal/HttpRequest");
14
14
  class CamStreamerAPI {
15
15
  constructor(options) {
16
- var _a, _b, _c, _d, _e;
16
+ var _a, _b, _c, _d, _e, _f;
17
17
  this.tls = (_a = options === null || options === void 0 ? void 0 : options.tls) !== null && _a !== void 0 ? _a : false;
18
18
  this.tlsInsecure = (_b = options === null || options === void 0 ? void 0 : options.tlsInsecure) !== null && _b !== void 0 ? _b : false;
19
19
  this.ip = (_c = options === null || options === void 0 ? void 0 : options.ip) !== null && _c !== void 0 ? _c : '127.0.0.1';
20
20
  this.port = (_d = options === null || options === void 0 ? void 0 : options.port) !== null && _d !== void 0 ? _d : (this.tls ? 443 : 80);
21
- this.auth = (_e = options === null || options === void 0 ? void 0 : options.auth) !== null && _e !== void 0 ? _e : '';
21
+ this.user = (_e = options === null || options === void 0 ? void 0 : options.user) !== null && _e !== void 0 ? _e : '';
22
+ this.pass = (_f = options === null || options === void 0 ? void 0 : options.pass) !== null && _f !== void 0 ? _f : '';
22
23
  }
23
24
  getStreamList() {
24
25
  return __awaiter(this, void 0, void 0, function* () {
@@ -45,18 +46,25 @@ class CamStreamerAPI {
45
46
  }
46
47
  get(path) {
47
48
  return __awaiter(this, void 0, void 0, function* () {
48
- const options = this.getBaseConnectionParams();
49
- options.path = encodeURI(path);
50
- const data = (yield (0, HttpRequest_1.httpRequest)(options));
51
- return JSON.parse(data);
49
+ const options = this.getBaseConnectionParams(path);
50
+ const res = yield (0, HttpRequest_1.sendRequest)(options);
51
+ if (res.ok) {
52
+ return yield res.json();
53
+ }
54
+ else {
55
+ throw new Error(JSON.stringify(res));
56
+ }
52
57
  });
53
58
  }
54
- getBaseConnectionParams() {
59
+ getBaseConnectionParams(path, method = 'GET') {
55
60
  return {
61
+ method: method,
56
62
  protocol: this.tls ? 'https:' : 'http:',
57
63
  host: this.ip,
58
64
  port: this.port,
59
- auth: this.auth,
65
+ path: path,
66
+ user: this.user,
67
+ pass: this.pass,
60
68
  rejectUnauthorized: !this.tlsInsecure,
61
69
  };
62
70
  }
@@ -1,14 +1,14 @@
1
- /// <reference types="node" />
2
1
  import * as EventEmitter from 'events';
3
- import { Options } from './common';
2
+ import { Options } from './internal/common';
4
3
  export type CamSwitcherAPIOptions = Options;
5
4
  export declare class CamSwitcherAPI extends EventEmitter {
6
5
  private tls;
7
6
  private tlsInsecure;
8
7
  private ip;
9
8
  private port;
10
- private auth;
11
- private ws;
9
+ private user;
10
+ private pass;
11
+ private ws?;
12
12
  constructor(options?: CamSwitcherAPIOptions);
13
13
  connect(): Promise<void>;
14
14
  getPlaylistList(): Promise<object>;
package/CamSwitcherAPI.js CHANGED
@@ -11,17 +11,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CamSwitcherAPI = void 0;
13
13
  const EventEmitter = require("events");
14
- const WsClient_1 = require("./WsClient");
15
- const HttpRequest_1 = require("./HttpRequest");
14
+ const WsClient_1 = require("./internal/WsClient");
15
+ const HttpRequest_1 = require("./internal/HttpRequest");
16
16
  class CamSwitcherAPI extends EventEmitter {
17
17
  constructor(options) {
18
- var _a, _b, _c, _d, _e;
18
+ var _a, _b, _c, _d, _e, _f;
19
19
  super();
20
20
  this.tls = (_a = options === null || options === void 0 ? void 0 : options.tls) !== null && _a !== void 0 ? _a : false;
21
21
  this.tlsInsecure = (_b = options === null || options === void 0 ? void 0 : options.tlsInsecure) !== null && _b !== void 0 ? _b : false;
22
22
  this.ip = (_c = options === null || options === void 0 ? void 0 : options.ip) !== null && _c !== void 0 ? _c : '127.0.0.1';
23
23
  this.port = (_d = options === null || options === void 0 ? void 0 : options.port) !== null && _d !== void 0 ? _d : (this.tls ? 443 : 80);
24
- this.auth = (_e = options === null || options === void 0 ? void 0 : options.auth) !== null && _e !== void 0 ? _e : '';
24
+ this.user = (_e = options === null || options === void 0 ? void 0 : options.user) !== null && _e !== void 0 ? _e : '';
25
+ this.pass = (_f = options === null || options === void 0 ? void 0 : options.pass) !== null && _f !== void 0 ? _f : '';
25
26
  EventEmitter.call(this);
26
27
  }
27
28
  connect() {
@@ -31,7 +32,8 @@ class CamSwitcherAPI extends EventEmitter {
31
32
  const options = {
32
33
  ip: this.ip,
33
34
  port: this.port,
34
- auth: this.auth,
35
+ user: this.user,
36
+ pass: this.pass,
35
37
  tls: this.tls,
36
38
  tlsInsecure: this.tlsInsecure,
37
39
  address: '/local/camswitcher/events',
@@ -39,7 +41,8 @@ class CamSwitcherAPI extends EventEmitter {
39
41
  };
40
42
  this.ws = new WsClient_1.WsClient(options);
41
43
  this.ws.on('open', () => {
42
- this.ws.send(JSON.stringify({ authorization: token }));
44
+ var _a;
45
+ (_a = this.ws) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify({ authorization: token }));
43
46
  });
44
47
  this.ws.on('message', (data) => {
45
48
  try {
@@ -89,29 +92,31 @@ class CamSwitcherAPI extends EventEmitter {
89
92
  }
90
93
  get(path) {
91
94
  return __awaiter(this, void 0, void 0, function* () {
92
- const options = this.getBaseConnectionParams();
93
- options.path = encodeURI(path);
94
- const data = (yield (0, HttpRequest_1.httpRequest)(options));
95
- try {
96
- const response = JSON.parse(data);
97
- if (response.status == 200) {
98
- return response.data;
95
+ const options = this.getBaseConnectionParams(path);
96
+ const res = yield (0, HttpRequest_1.sendRequest)(options);
97
+ if (res.ok) {
98
+ const responseText = JSON.parse(yield res.text());
99
+ if (responseText.status === 200) {
100
+ return responseText.data;
99
101
  }
100
102
  else {
101
- throw new Error(`Request (${path}) error, response: ${JSON.stringify(response)}`);
103
+ throw new Error(`Request (${path}) error, response: ${JSON.stringify(responseText)}`);
102
104
  }
103
105
  }
104
- catch (err) {
105
- throw new Error(`Request (${path}) error: ${err}, msg: ${data}`);
106
+ else {
107
+ throw new Error(JSON.stringify(res));
106
108
  }
107
109
  });
108
110
  }
109
- getBaseConnectionParams() {
111
+ getBaseConnectionParams(path, method = 'GET') {
110
112
  return {
113
+ method: method,
111
114
  protocol: this.tls ? 'https:' : 'http:',
112
115
  host: this.ip,
113
116
  port: this.port,
114
- auth: this.auth,
117
+ path: path,
118
+ user: this.user,
119
+ pass: this.pass,
115
120
  rejectUnauthorized: !this.tlsInsecure,
116
121
  };
117
122
  }
package/CameraVapix.d.ts CHANGED
@@ -1,20 +1,18 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import * as http from 'http';
1
+ import { WritableStream } from 'node:stream/web';
4
2
  import { EventEmitter2 as EventEmitter } from 'eventemitter2';
5
- import { Options } from './common';
3
+ import { Options } from './internal/common';
6
4
  export type CameraVapixOptions = Options;
7
- export type ApplicationList = {
5
+ export type TApplicationList = {
8
6
  reply: {
9
7
  $: {
10
8
  result: string;
11
9
  };
12
10
  application: {
13
- $: Application;
11
+ $: TApplication;
14
12
  }[];
15
13
  };
16
14
  };
17
- export type Application = {
15
+ export type TApplication = {
18
16
  Name: string;
19
17
  NiceName: string;
20
18
  Vendor: string;
@@ -26,19 +24,19 @@ export type Application = {
26
24
  VendorHomePage?: string;
27
25
  LicenseName?: string;
28
26
  };
29
- export type GuardTour = {
27
+ export type TGuardTour = {
30
28
  id: string;
31
- camNbr: any;
29
+ camNbr: unknown;
32
30
  name: string;
33
- randomEnabled: any;
31
+ randomEnabled: unknown;
34
32
  running: string;
35
- timeBetweenSequences: any;
33
+ timeBetweenSequences: unknown;
36
34
  tour: {
37
- moveSpeed: any;
38
- position: any;
39
- presetNbr: any;
40
- waitTime: any;
41
- waitTimeViewType: any;
35
+ moveSpeed: unknown;
36
+ position: unknown;
37
+ presetNbr: unknown;
38
+ waitTime: unknown;
39
+ waitTimeViewType: unknown;
42
40
  }[];
43
41
  };
44
42
  export declare class CameraVapix extends EventEmitter {
@@ -46,21 +44,22 @@ export declare class CameraVapix extends EventEmitter {
46
44
  private tlsInsecure;
47
45
  private ip;
48
46
  private port;
49
- private auth;
50
- private ws;
47
+ private user;
48
+ private pass;
49
+ private ws?;
51
50
  constructor(options?: CameraVapixOptions);
52
- vapixGet(path: string, noWaitForData?: boolean): Promise<string | http.IncomingMessage>;
53
- vapixPost(path: string, data: string, contentType?: string): Promise<string>;
54
- getParameterGroup(groupNames: string): Promise<{}>;
55
- setParameter(params: object): Promise<string>;
51
+ vapixGet(path: string): Promise<Response>;
52
+ vapixPost(path: string, data: string, contentType?: string): Promise<Response>;
53
+ getParameterGroup(groupNames: string): Promise<Record<string, string>>;
54
+ setParameter(params: Record<string, string>): Promise<Response>;
56
55
  getPTZPresetList(channel: string): Promise<string[]>;
57
- goToPreset(channel: number, presetName: string): Promise<string>;
58
- getGuardTourList(): Promise<GuardTour[]>;
59
- setGuardTourEnabled(gourTourID: string, enable: boolean): Promise<string>;
56
+ goToPreset(channel: number, presetName: string): Promise<Response>;
57
+ getGuardTourList(): Promise<TGuardTour[]>;
58
+ setGuardTourEnabled(gourTourID: string, enable: boolean): Promise<Response>;
60
59
  getInputState(port: number): Promise<boolean>;
61
- setOutputState(port: number, active: boolean): Promise<string>;
62
- getApplicationList(): Promise<Application[]>;
63
- getCameraImage(camera: string, compression: string, resolution: string, outputStream: NodeJS.WritableStream): Promise<NodeJS.WritableStream>;
60
+ setOutputState(port: number, active: boolean): Promise<Response>;
61
+ getApplicationList(): Promise<TApplication[]>;
62
+ getCameraImage(camera: string, compression: string, resolution: string, outputStream: WritableStream): Promise<WritableStream<any>>;
64
63
  getEventDeclarations(): Promise<string>;
65
64
  eventsConnect(): void;
66
65
  eventsDisconnect(): void;