camstreamerlib 1.8.2 → 1.8.4

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.
package/CamOverlayAPI.js CHANGED
@@ -142,12 +142,16 @@ class CamOverlayAPI extends EventEmitter {
142
142
  this.ws.on('message', (data) => {
143
143
  let dataJSON = JSON.parse(data);
144
144
  if (dataJSON.hasOwnProperty('call_id') && dataJSON['call_id'] in this.sendMessages) {
145
- this.sendMessages[dataJSON['call_id']].resolve(dataJSON);
145
+ if (dataJSON.hasOwnProperty('error')) {
146
+ this.sendMessages[dataJSON['call_id']].reject(new Error(dataJSON.error));
147
+ }
148
+ else {
149
+ this.sendMessages[dataJSON['call_id']].resolve(dataJSON);
150
+ }
146
151
  delete this.sendMessages[dataJSON['call_id']];
147
152
  }
148
153
  if (dataJSON.hasOwnProperty('error')) {
149
- let error = new Error(JSON.stringify(data));
150
- this.reportErr(error);
154
+ this.reportErr(new Error(dataJSON.error));
151
155
  }
152
156
  else {
153
157
  this.reportMsg(data);
@@ -240,7 +244,6 @@ class CamOverlayAPI extends EventEmitter {
240
244
  var _a;
241
245
  (_a = this.ws) === null || _a === void 0 ? void 0 : _a.terminate();
242
246
  this.emit('error', err);
243
- this.emit('close');
244
247
  }
245
248
  reportClose() {
246
249
  for (const callId in this.sendMessages) {
package/CreatePackage.js CHANGED
@@ -7,6 +7,16 @@ function isDirectory(path) {
7
7
  const stat = fs.statSync(path);
8
8
  return stat.isDirectory();
9
9
  }
10
+ function getPackageVersion(folder) {
11
+ try {
12
+ const manifest = fs.readFileSync(Path.join(folder, 'manifest.json'));
13
+ const manifestParsed = JSON.parse(manifest.toString());
14
+ return manifestParsed.package_version.replace(/\./g, '_');
15
+ }
16
+ catch (err) {
17
+ console.error('Get package version:', err);
18
+ }
19
+ }
10
20
  function createZipArchive(zip, folder, options) {
11
21
  const files = fs.readdirSync(folder);
12
22
  for (let file of files) {
@@ -29,8 +39,6 @@ function createZipArchive(zip, folder, options) {
29
39
  }
30
40
  }
31
41
  function main(args) {
32
- const folder = Path.resolve('.');
33
- const zipFile = Path.basename(folder) + '.zip';
34
42
  const options = {
35
43
  includeNodeModules: false,
36
44
  typeScriptPackage: false,
@@ -43,6 +51,9 @@ function main(args) {
43
51
  if (fs.existsSync('dist')) {
44
52
  options.typeScriptPackage = true;
45
53
  }
54
+ const folder = Path.resolve('.');
55
+ const packageVersion = getPackageVersion(folder);
56
+ const zipFile = `${Path.basename(folder)}_${packageVersion}.zip`;
46
57
  if (fs.existsSync(zipFile)) {
47
58
  try {
48
59
  fs.unlinkSync(zipFile);
package/HttpServer.js CHANGED
@@ -35,8 +35,8 @@ class HttpServer extends EventEmitter {
35
35
  '.pdf': 'application/pdf',
36
36
  '.doc': 'application/msword',
37
37
  };
38
- fs.access(pathname, (exist) => {
39
- if (!exist) {
38
+ fs.access(pathname, fs.constants.R_OK, (err) => {
39
+ if (err) {
40
40
  res.statusCode = 404;
41
41
  res.end(`File ${pathname} not found!`);
42
42
  this.emit('error', `File ${pathname} not found!`);
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "dependencies": {
7
+ "adm-zip": "^0.5.9",
7
8
  "crypto": "^1.0.1",
8
9
  "eventemitter2": "^5.0.1",
9
10
  "prettify-xml": "^1.2.0",
10
11
  "ws": "^7.4.2",
11
- "xml2js": "^0.4.19",
12
- "adm-zip": "^0.5.9"
12
+ "xml2js": "^0.5.0"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@camstreamer/prettier-config": "^2.0.4",
16
16
  "@types/jest": "^28.0.0",
17
17
  "@types/node": "^18.0.6",
18
- "typescript": "^4.7.4",
19
- "ts-jest": "^28.0.0",
20
- "ts-node": "^10.7.0",
21
18
  "jest": "^28.1.3",
22
19
  "npm-run-all": "^4.1.5",
23
20
  "prettier": "^2.7.1",
24
- "rimraf": "^3.0.2"
21
+ "rimraf": "^3.0.2",
22
+ "ts-jest": "^28.0.0",
23
+ "ts-node": "^10.7.0",
24
+ "typescript": "^4.7.4"
25
25
  },
26
26
  "scripts": {
27
27
  "clean": "rimraf dist/*",
@@ -32,7 +32,10 @@
32
32
  "pretty:check": "prettier --check \"./src/*.{ts,tsx}\"",
33
33
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
34
34
  },
35
- "files": ["*.js", "*.ts"],
35
+ "files": [
36
+ "*.js",
37
+ "*.ts"
38
+ ],
36
39
  "repository": {
37
40
  "type": "git",
38
41
  "url": "git+https://github.com/CamStreamer/CamStreamerLib.git"