camstreamerlib 4.0.0-beta.65 → 4.0.0-beta.66
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/cjs/bin/CreatePackage.js +45 -22
- package/cjs/node/CamOverlayDrawingAPI.d.ts +1 -1
- package/cjs/node/CamOverlayDrawingAPI.js +3 -6
- package/cjs/node/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/cjs/node/CamScripterAPICameraEventsGenerator.js +3 -6
- package/cjs/node/Digest.js +27 -7
- package/cjs/node/HttpServer.d.ts +2 -2
- package/cjs/node/HttpServer.js +34 -14
- package/cjs/node/WsClient.js +6 -9
- package/esm/bin/CreatePackage.js +16 -16
- package/esm/node/CamOverlayDrawingAPI.js +1 -1
- package/esm/node/CamScripterAPICameraEventsGenerator.js +1 -1
- package/esm/node/Digest.js +1 -1
- package/esm/node/HttpServer.js +5 -5
- package/esm/node/WsClient.js +1 -1
- package/package.json +1 -1
- package/types/node/CamOverlayDrawingAPI.d.ts +1 -1
- package/types/node/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/types/node/HttpServer.d.ts +2 -2
package/cjs/bin/CreatePackage.js
CHANGED
|
@@ -1,20 +1,43 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
7
|
-
const
|
|
8
|
-
const
|
|
30
|
+
const path = __importStar(require("path"));
|
|
31
|
+
const fs = __importStar(require("fs"));
|
|
9
32
|
const child_process_1 = require("child_process");
|
|
10
33
|
const productionModulesFolder = 'production_modules';
|
|
11
|
-
function isDirectory(
|
|
12
|
-
const stat =
|
|
34
|
+
function isDirectory(filePath) {
|
|
35
|
+
const stat = fs.statSync(filePath);
|
|
13
36
|
return stat.isDirectory();
|
|
14
37
|
}
|
|
15
38
|
function getPackageInfo(folder) {
|
|
16
39
|
try {
|
|
17
|
-
const manifest =
|
|
40
|
+
const manifest = fs.readFileSync(path.join(folder, 'manifest.json'));
|
|
18
41
|
const manifestParsed = JSON.parse(manifest.toString());
|
|
19
42
|
return {
|
|
20
43
|
packageName: manifestParsed.package_name,
|
|
@@ -26,11 +49,11 @@ function getPackageInfo(folder) {
|
|
|
26
49
|
}
|
|
27
50
|
}
|
|
28
51
|
function createZipArchive(zip, folder, options) {
|
|
29
|
-
const zipFileRegex = new RegExp(`${
|
|
30
|
-
const files =
|
|
52
|
+
const zipFileRegex = new RegExp(`${path.basename(folder)}(_[0-9]){3}\\.zip`);
|
|
53
|
+
const files = fs.readdirSync(folder);
|
|
31
54
|
for (const file of files) {
|
|
32
|
-
const
|
|
33
|
-
const isDir = isDirectory(
|
|
55
|
+
const filePath = path.join(folder, file);
|
|
56
|
+
const isDir = isDirectory(filePath);
|
|
34
57
|
if (file[0] === '.' ||
|
|
35
58
|
zipFileRegex.test(file) ||
|
|
36
59
|
file === 'node_modules' ||
|
|
@@ -39,27 +62,27 @@ function createZipArchive(zip, folder, options) {
|
|
|
39
62
|
continue;
|
|
40
63
|
}
|
|
41
64
|
else if (file === 'dist' && options.typeScriptPackage) {
|
|
42
|
-
zip.addLocalFolder(
|
|
65
|
+
zip.addLocalFolder(filePath);
|
|
43
66
|
}
|
|
44
67
|
else if (file === productionModulesFolder && options.includeNodeModules) {
|
|
45
|
-
zip.addLocalFolder(
|
|
68
|
+
zip.addLocalFolder(path.join(productionModulesFolder, 'node_modules'), 'node_modules');
|
|
46
69
|
}
|
|
47
70
|
else if (isDir) {
|
|
48
|
-
zip.addLocalFolder(
|
|
71
|
+
zip.addLocalFolder(filePath, file);
|
|
49
72
|
}
|
|
50
73
|
else {
|
|
51
|
-
zip.addLocalFile(
|
|
74
|
+
zip.addLocalFile(filePath);
|
|
52
75
|
}
|
|
53
76
|
}
|
|
54
77
|
}
|
|
55
78
|
function installDependencies() {
|
|
56
|
-
if (!
|
|
57
|
-
|
|
79
|
+
if (!fs.existsSync(productionModulesFolder)) {
|
|
80
|
+
fs.mkdirSync(productionModulesFolder, {});
|
|
58
81
|
}
|
|
59
|
-
|
|
60
|
-
|
|
82
|
+
fs.cpSync('package.json', path.join(productionModulesFolder, 'package.json'));
|
|
83
|
+
fs.cpSync('package-lock.json', path.join(productionModulesFolder, 'package-lock.json'));
|
|
61
84
|
(0, child_process_1.execSync)(`npm ci --omit=dev`, {
|
|
62
|
-
cwd:
|
|
85
|
+
cwd: path.join(process.cwd(), productionModulesFolder),
|
|
63
86
|
});
|
|
64
87
|
}
|
|
65
88
|
function main(args) {
|
|
@@ -83,19 +106,19 @@ function main(args) {
|
|
|
83
106
|
if (options.includeNodeModules) {
|
|
84
107
|
installDependencies();
|
|
85
108
|
}
|
|
86
|
-
if (
|
|
109
|
+
if (fs.existsSync('dist')) {
|
|
87
110
|
options.typeScriptPackage = true;
|
|
88
111
|
}
|
|
89
|
-
const folder =
|
|
112
|
+
const folder = path.resolve('.');
|
|
90
113
|
const packageInfo = getPackageInfo(folder);
|
|
91
114
|
if (packageInfo === undefined) {
|
|
92
115
|
console.error('Package info not found');
|
|
93
116
|
process.exit(1);
|
|
94
117
|
}
|
|
95
118
|
const zipFile = `${options.outputFolder}/${packageInfo.packageName}_${packageInfo.packageVersion}.zip`;
|
|
96
|
-
if (
|
|
119
|
+
if (fs.existsSync(zipFile)) {
|
|
97
120
|
try {
|
|
98
|
-
|
|
121
|
+
fs.unlinkSync(zipFile);
|
|
99
122
|
}
|
|
100
123
|
catch (error) {
|
|
101
124
|
console.error('An error occured: ', error);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
-
import EventEmitter from 'events';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
5
|
import { CamOverlayDrawingOptions, TCairoCreateResponse, TCairoResponse, TUploadImageResponse, TWriteTextParams } from '../types/CamOverlayDrawingAPI';
|
|
6
6
|
export declare class CamOverlayDrawingAPI extends EventEmitter {
|
|
7
7
|
private tls;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.CamOverlayDrawingAPI = void 0;
|
|
7
|
-
const events_1 =
|
|
4
|
+
const events_1 = require("events");
|
|
8
5
|
const WsClient_1 = require("./WsClient");
|
|
9
|
-
class CamOverlayDrawingAPI extends events_1.
|
|
6
|
+
class CamOverlayDrawingAPI extends events_1.EventEmitter {
|
|
10
7
|
tls;
|
|
11
8
|
tlsInsecure;
|
|
12
9
|
ip;
|
|
@@ -40,7 +37,7 @@ class CamOverlayDrawingAPI extends events_1.default {
|
|
|
40
37
|
this.sendMessages = {};
|
|
41
38
|
this.wsConnected = false;
|
|
42
39
|
this.createWsClient();
|
|
43
|
-
events_1.
|
|
40
|
+
events_1.EventEmitter.call(this);
|
|
44
41
|
}
|
|
45
42
|
connect() {
|
|
46
43
|
this.ws.open();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import EventEmitter from 'events';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
3
|
import { Options } from '../internal/types';
|
|
4
4
|
import { TCamScripterEvent, TEventDeclaration, TEventUndeclaration, TCamScripterResponse } from '../types/CamScripterAPICameraEventsGenerator';
|
|
5
5
|
export declare class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.CamScripterAPICameraEventsGenerator = void 0;
|
|
7
|
-
const events_1 =
|
|
4
|
+
const events_1 = require("events");
|
|
8
5
|
const WsClient_1 = require("./WsClient");
|
|
9
|
-
class CamScripterAPICameraEventsGenerator extends events_1.
|
|
6
|
+
class CamScripterAPICameraEventsGenerator extends events_1.EventEmitter {
|
|
10
7
|
tls;
|
|
11
8
|
tlsInsecure;
|
|
12
9
|
ip;
|
|
@@ -30,7 +27,7 @@ class CamScripterAPICameraEventsGenerator extends events_1.default {
|
|
|
30
27
|
this.sendMessages = {};
|
|
31
28
|
this.wsConnected = false;
|
|
32
29
|
this.createWsClient();
|
|
33
|
-
events_1.
|
|
30
|
+
events_1.EventEmitter.call(this);
|
|
34
31
|
}
|
|
35
32
|
connect() {
|
|
36
33
|
this.ws.open();
|
package/cjs/node/Digest.js
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.Digest = void 0;
|
|
7
|
-
const
|
|
27
|
+
const crypto = __importStar(require("crypto"));
|
|
8
28
|
class Digest {
|
|
9
29
|
nonceCount = 1;
|
|
10
30
|
getAuthHeader(user, pass, method, uri, wwwAuthenticateHeader) {
|
|
@@ -16,18 +36,18 @@ class Digest {
|
|
|
16
36
|
const value = arg.substring(pos + 1).trim();
|
|
17
37
|
digestItems[key] = value.replace(/"/g, '');
|
|
18
38
|
}
|
|
19
|
-
const HA1 =
|
|
20
|
-
const HA2 =
|
|
39
|
+
const HA1 = crypto.createHash('md5').update(`${user}:${digestItems['realm']}:${pass}`).digest('hex');
|
|
40
|
+
const HA2 = crypto.createHash('md5').update(`${method}:${uri}`).digest('hex');
|
|
21
41
|
const ncValue = ('00000000' + this.nonceCount.toString(16)).slice(-8);
|
|
22
42
|
let response;
|
|
23
43
|
if (digestItems['qop'] !== undefined) {
|
|
24
|
-
response =
|
|
44
|
+
response = crypto
|
|
25
45
|
.createHash('md5')
|
|
26
46
|
.update(`${HA1}:${digestItems['nonce']}:${ncValue}:162d50aa594e9648:auth:${HA2}`)
|
|
27
47
|
.digest('hex');
|
|
28
48
|
}
|
|
29
49
|
else {
|
|
30
|
-
response =
|
|
50
|
+
response = crypto.createHash('md5').update(`${HA1}:${digestItems['nonce']}:${HA2}`).digest('hex');
|
|
31
51
|
}
|
|
32
52
|
let header = 'Digest ' +
|
|
33
53
|
`username="${user}",` +
|
package/cjs/node/HttpServer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import http from 'http';
|
|
4
|
-
import EventEmitter from 'events';
|
|
3
|
+
import * as http from 'http';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
5
|
export type HttpServerOptions = {
|
|
6
6
|
host?: string;
|
|
7
7
|
port?: number;
|
package/cjs/node/HttpServer.js
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.HttpServer = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const events_1 =
|
|
12
|
-
class HttpServer extends events_1.
|
|
27
|
+
const http = __importStar(require("http"));
|
|
28
|
+
const url = __importStar(require("url"));
|
|
29
|
+
const fs = __importStar(require("fs"));
|
|
30
|
+
const path = __importStar(require("path"));
|
|
31
|
+
const events_1 = require("events");
|
|
32
|
+
class HttpServer extends events_1.EventEmitter {
|
|
13
33
|
host;
|
|
14
34
|
port;
|
|
15
35
|
registeredPaths;
|
|
@@ -20,9 +40,9 @@ class HttpServer extends events_1.default {
|
|
|
20
40
|
this.host = options?.host ?? process.env.HTTP_HOST ?? '0.0.0.0';
|
|
21
41
|
this.port = options?.port ?? parseInt(process.env.HTTP_PORT ?? '80');
|
|
22
42
|
this.registeredPaths = new Map();
|
|
23
|
-
this.server =
|
|
43
|
+
this.server = http.createServer((req, res) => {
|
|
24
44
|
this.emit('access', req.method + ' ' + req.url);
|
|
25
|
-
const parsedUrl =
|
|
45
|
+
const parsedUrl = url.parse(req.url ?? '');
|
|
26
46
|
parsedUrl.pathname ??= '';
|
|
27
47
|
const requestCallback = this.registeredPaths.get(parsedUrl.pathname);
|
|
28
48
|
if (requestCallback) {
|
|
@@ -30,7 +50,7 @@ class HttpServer extends events_1.default {
|
|
|
30
50
|
return;
|
|
31
51
|
}
|
|
32
52
|
let pathname = `./html${parsedUrl.pathname}`;
|
|
33
|
-
const ext =
|
|
53
|
+
const ext = path.parse(pathname).ext;
|
|
34
54
|
const map = {
|
|
35
55
|
'.ico': 'image/x-icon',
|
|
36
56
|
'.html': 'text/html',
|
|
@@ -45,17 +65,17 @@ class HttpServer extends events_1.default {
|
|
|
45
65
|
'.pdf': 'application/pdf',
|
|
46
66
|
'.doc': 'application/msword',
|
|
47
67
|
};
|
|
48
|
-
|
|
68
|
+
fs.access(pathname, fs.constants.R_OK, (err) => {
|
|
49
69
|
if (err) {
|
|
50
70
|
res.statusCode = 404;
|
|
51
71
|
res.end(`File ${pathname} not found!`);
|
|
52
72
|
this.emit('error', `File ${pathname} not found!`);
|
|
53
73
|
return;
|
|
54
74
|
}
|
|
55
|
-
if (
|
|
75
|
+
if (fs.statSync(pathname).isDirectory()) {
|
|
56
76
|
pathname += `/index${ext}`;
|
|
57
77
|
}
|
|
58
|
-
|
|
78
|
+
fs.readFile(pathname, (error, data) => {
|
|
59
79
|
if (error) {
|
|
60
80
|
res.statusCode = 500;
|
|
61
81
|
res.end(`Error getting the file: ${error}`);
|
package/cjs/node/WsClient.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.WsClient = void 0;
|
|
7
|
-
const ws_1 =
|
|
4
|
+
const ws_1 = require("ws");
|
|
8
5
|
const Digest_1 = require("./Digest");
|
|
9
6
|
class WsClient {
|
|
10
7
|
user;
|
|
@@ -43,15 +40,15 @@ class WsClient {
|
|
|
43
40
|
}
|
|
44
41
|
this.isClosed = false;
|
|
45
42
|
if (this.protocol === undefined) {
|
|
46
|
-
this.ws = new ws_1.
|
|
43
|
+
this.ws = new ws_1.WebSocket(this.address, this.wsOptions);
|
|
47
44
|
}
|
|
48
45
|
else {
|
|
49
|
-
this.ws = new ws_1.
|
|
46
|
+
this.ws = new ws_1.WebSocket(this.address, this.protocol, this.wsOptions);
|
|
50
47
|
}
|
|
51
48
|
this.ws.binaryType = 'arraybuffer';
|
|
52
49
|
this.isAlive = true;
|
|
53
50
|
this.pingTimer = setInterval(() => {
|
|
54
|
-
if ((this.ws && this.ws.readyState !== ws_1.
|
|
51
|
+
if ((this.ws && this.ws.readyState !== ws_1.WebSocket.OPEN) || this.isAlive === false) {
|
|
55
52
|
this.onError(new Error('Connection timeout'));
|
|
56
53
|
this.closeWsConnection();
|
|
57
54
|
}
|
|
@@ -132,11 +129,11 @@ class WsClient {
|
|
|
132
129
|
}
|
|
133
130
|
wsCopy.removeAllListeners();
|
|
134
131
|
wsCopy.on('error', () => { });
|
|
135
|
-
if (wsCopy.readyState !== ws_1.
|
|
132
|
+
if (wsCopy.readyState !== ws_1.WebSocket.CLOSING && wsCopy.readyState !== ws_1.WebSocket.CLOSED) {
|
|
136
133
|
wsCopy.close();
|
|
137
134
|
}
|
|
138
135
|
setTimeout(() => {
|
|
139
|
-
if (wsCopy.readyState !== ws_1.
|
|
136
|
+
if (wsCopy.readyState !== ws_1.WebSocket.CLOSED) {
|
|
140
137
|
wsCopy.terminate();
|
|
141
138
|
}
|
|
142
139
|
}, 5000);
|
package/esm/bin/CreatePackage.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import AdmZip from 'adm-zip';
|
|
2
|
-
import
|
|
3
|
-
import fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
4
|
import { execSync } from 'child_process';
|
|
5
5
|
const productionModulesFolder = 'production_modules';
|
|
6
|
-
function isDirectory(
|
|
7
|
-
const stat = fs.statSync(
|
|
6
|
+
function isDirectory(filePath) {
|
|
7
|
+
const stat = fs.statSync(filePath);
|
|
8
8
|
return stat.isDirectory();
|
|
9
9
|
}
|
|
10
10
|
function getPackageInfo(folder) {
|
|
11
11
|
try {
|
|
12
|
-
const manifest = fs.readFileSync(
|
|
12
|
+
const manifest = fs.readFileSync(path.join(folder, 'manifest.json'));
|
|
13
13
|
const manifestParsed = JSON.parse(manifest.toString());
|
|
14
14
|
return {
|
|
15
15
|
packageName: manifestParsed.package_name,
|
|
@@ -21,11 +21,11 @@ function getPackageInfo(folder) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
function createZipArchive(zip, folder, options) {
|
|
24
|
-
const zipFileRegex = new RegExp(`${
|
|
24
|
+
const zipFileRegex = new RegExp(`${path.basename(folder)}(_[0-9]){3}\\.zip`);
|
|
25
25
|
const files = fs.readdirSync(folder);
|
|
26
26
|
for (const file of files) {
|
|
27
|
-
const
|
|
28
|
-
const isDir = isDirectory(
|
|
27
|
+
const filePath = path.join(folder, file);
|
|
28
|
+
const isDir = isDirectory(filePath);
|
|
29
29
|
if (file[0] === '.' ||
|
|
30
30
|
zipFileRegex.test(file) ||
|
|
31
31
|
file === 'node_modules' ||
|
|
@@ -34,16 +34,16 @@ function createZipArchive(zip, folder, options) {
|
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
else if (file === 'dist' && options.typeScriptPackage) {
|
|
37
|
-
zip.addLocalFolder(
|
|
37
|
+
zip.addLocalFolder(filePath);
|
|
38
38
|
}
|
|
39
39
|
else if (file === productionModulesFolder && options.includeNodeModules) {
|
|
40
|
-
zip.addLocalFolder(
|
|
40
|
+
zip.addLocalFolder(path.join(productionModulesFolder, 'node_modules'), 'node_modules');
|
|
41
41
|
}
|
|
42
42
|
else if (isDir) {
|
|
43
|
-
zip.addLocalFolder(
|
|
43
|
+
zip.addLocalFolder(filePath, file);
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
zip.addLocalFile(
|
|
46
|
+
zip.addLocalFile(filePath);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -51,10 +51,10 @@ function installDependencies() {
|
|
|
51
51
|
if (!fs.existsSync(productionModulesFolder)) {
|
|
52
52
|
fs.mkdirSync(productionModulesFolder, {});
|
|
53
53
|
}
|
|
54
|
-
fs.cpSync('package.json',
|
|
55
|
-
fs.cpSync('package-lock.json',
|
|
54
|
+
fs.cpSync('package.json', path.join(productionModulesFolder, 'package.json'));
|
|
55
|
+
fs.cpSync('package-lock.json', path.join(productionModulesFolder, 'package-lock.json'));
|
|
56
56
|
execSync(`npm ci --omit=dev`, {
|
|
57
|
-
cwd:
|
|
57
|
+
cwd: path.join(process.cwd(), productionModulesFolder),
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
function main(args) {
|
|
@@ -81,7 +81,7 @@ function main(args) {
|
|
|
81
81
|
if (fs.existsSync('dist')) {
|
|
82
82
|
options.typeScriptPackage = true;
|
|
83
83
|
}
|
|
84
|
-
const folder =
|
|
84
|
+
const folder = path.resolve('.');
|
|
85
85
|
const packageInfo = getPackageInfo(folder);
|
|
86
86
|
if (packageInfo === undefined) {
|
|
87
87
|
console.error('Package info not found');
|
package/esm/node/Digest.js
CHANGED
package/esm/node/HttpServer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import http from 'http';
|
|
2
|
-
import url from 'url';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import EventEmitter from 'events';
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import * as url from 'url';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
6
|
export class HttpServer extends EventEmitter {
|
|
7
7
|
host;
|
|
8
8
|
port;
|
package/esm/node/WsClient.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
-
import EventEmitter from 'events';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
5
|
import { CamOverlayDrawingOptions, TCairoCreateResponse, TCairoResponse, TUploadImageResponse, TWriteTextParams } from '../types/CamOverlayDrawingAPI';
|
|
6
6
|
export declare class CamOverlayDrawingAPI extends EventEmitter {
|
|
7
7
|
private tls;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import EventEmitter from 'events';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
3
|
import { Options } from '../internal/types';
|
|
4
4
|
import { TCamScripterEvent, TEventDeclaration, TEventUndeclaration, TCamScripterResponse } from '../types/CamScripterAPICameraEventsGenerator';
|
|
5
5
|
export declare class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import http from 'http';
|
|
4
|
-
import EventEmitter from 'events';
|
|
3
|
+
import * as http from 'http';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
5
|
export type HttpServerOptions = {
|
|
6
6
|
host?: string;
|
|
7
7
|
port?: number;
|