camstreamerlib 1.6.2 → 1.7.2

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.
@@ -2,13 +2,13 @@
2
2
  /// <reference types="node" />
3
3
  import * as EventEmitter from 'events';
4
4
  export declare type CamOverlayOptions = {
5
- protocol: string;
6
- ip: string;
7
- port: number;
8
- auth: string;
9
- serviceName: string;
10
- serviceID: number;
11
- camera: number;
5
+ protocol?: string;
6
+ ip?: string;
7
+ port?: number;
8
+ auth?: string;
9
+ serviceName?: string;
10
+ serviceID?: number;
11
+ camera?: number;
12
12
  };
13
13
  export declare type Field = {
14
14
  field_name: string;
package/CamOverlayAPI.js CHANGED
@@ -267,7 +267,7 @@ class CamOverlayAPI extends EventEmitter {
267
267
  setEnabled(enabled) {
268
268
  return __awaiter(this, void 0, void 0, function* () {
269
269
  const value = enabled ? 1 : 0;
270
- const path = encodeURI(`/local/camoverlay/api/enabled.cgi?id${this.serviceID}=${value}`);
270
+ const path = encodeURI(`/local/camoverlay/api/enabled.cgi?id_${this.serviceID}=${value}`);
271
271
  const options = {
272
272
  method: 'POST',
273
273
  host: this.ip,
@@ -1,8 +1,8 @@
1
1
  export declare type CamStreamerAPIOptions = {
2
- protocol: string;
3
- ip: string;
4
- port: number;
5
- auth: string;
2
+ protocol?: string;
3
+ ip?: string;
4
+ port?: number;
5
+ auth?: string;
6
6
  };
7
7
  export declare class CamStreamerAPI {
8
8
  private protocol;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs = require("fs");
4
+ const Path = require("path");
5
+ const AdmZip = require("adm-zip");
6
+ function isDirectory(path) {
7
+ const stat = fs.statSync(path);
8
+ return stat.isDirectory();
9
+ }
10
+ function createZipArchive(zip, folder, options) {
11
+ const files = fs.readdirSync(folder);
12
+ for (let file of files) {
13
+ const path = Path.join(folder, file);
14
+ const isDir = isDirectory(path);
15
+ if (file[0] == '.' ||
16
+ (file == 'node_modules' && !options.includeNodeModules) ||
17
+ (file == 'src' && options.typeScriptPackage)) {
18
+ continue;
19
+ }
20
+ else if (file == 'dist' && options.typeScriptPackage) {
21
+ zip.addLocalFolder(path);
22
+ }
23
+ else if (isDir) {
24
+ zip.addLocalFolder(path, file);
25
+ }
26
+ else {
27
+ zip.addLocalFile(path);
28
+ }
29
+ }
30
+ }
31
+ function main(args) {
32
+ const folder = Path.resolve('.');
33
+ const zipFile = Path.basename(folder) + '.zip';
34
+ const options = {
35
+ includeNodeModules: false,
36
+ typeScriptPackage: false,
37
+ };
38
+ for (let arg of args) {
39
+ if (arg == '-i' || arg == '-includeNodeModules') {
40
+ options.includeNodeModules = true;
41
+ }
42
+ }
43
+ if (fs.existsSync('dist')) {
44
+ options.typeScriptPackage = true;
45
+ }
46
+ if (fs.existsSync(zipFile)) {
47
+ try {
48
+ fs.unlinkSync(zipFile);
49
+ }
50
+ catch (error) {
51
+ console.log('An error occured: ', error);
52
+ process.exit(1);
53
+ }
54
+ }
55
+ const zip = new AdmZip();
56
+ createZipArchive(zip, folder, options);
57
+ zip.writeZip(zipFile);
58
+ }
59
+ main(process.argv.slice(2));
package/README.md CHANGED
@@ -334,3 +334,17 @@ np
334
334
  ```
335
335
  The utility will ask you for the prefered version raise and if you are lucky, everything will run just fine.
336
336
  Finally, edit GitHub release form.
337
+
338
+ ### Preparing a package to upload to CamScripter
339
+ If you want to create your own package and upload it to CamScripter App, you can use the script CreatePackage. It creates a zip file which contains all required files and directories in your package folder. The script accepts source code written either in JavaScript or TypeScript if the package has the correct structure (more information in https://github.com/CamStreamer/CamScripterApp_examples/#readme). To include this script in your package add the following lines in the file package.json:
340
+ ```json
341
+ "scripts": {
342
+ "create-package": "node node_modules/camstreamerlib/CreatePackage.js"
343
+ }
344
+ ```
345
+ By default, the zipped package does not contain node_modules directory. If you want to include it (required when uploading to CamScripter App on Axis camera), add this:
346
+ ```json
347
+ "scripts": {
348
+ "create-package": "node node_modules/camstreamerlib/CreatePackage.js -includeNodeModules"
349
+ }
350
+ ```
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "1.6.2",
3
+ "version": "1.7.2",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "dependencies": {
7
7
  "crypto": "^1.0.1",
8
8
  "eventemitter2": "^5.0.1",
9
9
  "prettify-xml": "^1.2.0",
10
- "typescript": "^4.7.4",
11
10
  "ws": "^7.4.2",
12
11
  "xml2js": "^0.4.19"
13
12
  },
@@ -15,6 +14,8 @@
15
14
  "@camstreamer/prettier-config": "^2.0.4",
16
15
  "@types/jest": "^28.0.0",
17
16
  "@types/node": "^18.0.6",
17
+ "adm-zip": "^0.5.9",
18
+ "typescript": "^4.7.4",
18
19
  "ts-jest": "^28.0.0",
19
20
  "ts-node": "^10.7.0",
20
21
  "jest": "^28.1.3",