camstreamerlib 4.0.0-beta.6 → 4.0.0-beta.61
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/README.md +142 -38
- package/cjs/CamOverlayAPI.js +135 -92
- package/cjs/CamScripterAPI.js +52 -42
- package/cjs/CamStreamerAPI.js +83 -39
- package/cjs/CamSwitcherAPI.js +142 -124
- package/cjs/PlaneTrackerAPI.js +247 -0
- package/cjs/VapixAPI.js +323 -233
- package/cjs/{CreatePackage.js → bin/CreatePackage.js} +22 -19
- package/cjs/errors/errors.js +113 -1
- package/cjs/index.js +28 -5
- package/cjs/internal/ProxyClient.js +28 -32
- package/cjs/{CamSwitcherEvents.js → internal/WsEvents.js} +28 -22
- package/cjs/internal/types.js +2 -0
- package/cjs/internal/utils.js +22 -3
- package/cjs/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +17 -14
- package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
- package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +5 -17
- package/cjs/node/CamOverlayPainter/ResourceManager.js +72 -0
- package/cjs/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +16 -13
- package/cjs/node/DefaultClient.js +10 -12
- package/cjs/{internal → node}/Digest.js +8 -5
- package/cjs/node/Digest.test.js +13 -0
- package/cjs/node/HttpRequestSender.js +14 -4
- package/cjs/node/HttpServer.js +15 -12
- package/cjs/{VapixEvents.js → node/VapixEvents.js} +10 -10
- package/cjs/node/WsClient.js +30 -20
- package/cjs/node/events/AxisCameraStationEvents.js +53 -0
- package/cjs/node/events/GenetecAgent.js +123 -0
- package/cjs/node/index.js +38 -5
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +92 -0
- package/cjs/types/CamOverlayAPI/accuweatherSchema.js +47 -0
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.js +72 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.js +9 -0
- package/cjs/types/CamOverlayAPI/index.js +27 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.js +26 -0
- package/cjs/types/CamOverlayAPI/pipSchema.js +39 -0
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.js +26 -0
- package/cjs/types/CamOverlayAPI/ptzSchema.js +12 -0
- package/cjs/types/CamOverlayAPI/scoreBoardSchema.js +132 -0
- package/cjs/types/CamOverlayAPI/screenSharingSchema.js +8 -0
- package/cjs/types/CamOverlayAPI/serviceCommonTypes.js +91 -0
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +8 -0
- package/cjs/types/CamOverlayDrawingAPI.js +2 -0
- package/cjs/types/CamOverlayPainter.js +14 -0
- package/cjs/types/CamScripterAPI.js +24 -8
- package/cjs/types/CamScripterAPICameraEventsGenerator.js +2 -0
- package/cjs/types/CamStreamerAPI.js +34 -3
- package/cjs/types/CamSwitcherAPI.js +38 -1
- package/cjs/types/GenetecAgent.js +31 -0
- package/cjs/types/PlaneTrackerAPI.js +310 -0
- package/cjs/types/VapixAPI.js +71 -13
- package/cjs/types/VapixEvents.js +2 -0
- package/cjs/types/common.js +4 -2
- package/cjs/types/ws/CamOverlayEvents.js +19 -0
- package/cjs/types/ws/CamStreamerEvents.js +32 -0
- package/cjs/types/{CamSwitcherEvents.js → ws/CamSwitcherEvents.js} +8 -0
- package/cjs/types/ws/PlaneTrackerEvents.js +194 -0
- package/cjs/web/DefaultClient.js +26 -10
- package/cjs/web/WsClient.js +16 -18
- package/cjs/ws/CamOverlayEvents.js +24 -0
- package/cjs/ws/CamStreamerEvents.js +24 -0
- package/cjs/ws/CamSwitcherEvents.js +24 -0
- package/cjs/ws/PlaneTrackerEvents.js +30 -0
- package/esm/CamOverlayAPI.js +131 -88
- package/esm/CamScripterAPI.js +48 -38
- package/esm/CamStreamerAPI.js +81 -38
- package/esm/CamSwitcherAPI.js +138 -120
- package/esm/PlaneTrackerAPI.js +243 -0
- package/esm/VapixAPI.js +315 -225
- package/esm/{CreatePackage.js → bin/CreatePackage.js} +3 -3
- package/esm/errors/errors.js +96 -0
- package/esm/index.js +20 -4
- package/esm/internal/ProxyClient.js +28 -32
- package/esm/{CamSwitcherEvents.js → internal/WsEvents.js} +26 -20
- package/esm/internal/utils.js +17 -1
- package/esm/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +12 -12
- package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
- package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +2 -13
- package/esm/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +7 -5
- package/esm/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +11 -11
- package/esm/node/DefaultClient.js +10 -12
- package/esm/{internal → node}/Digest.js +1 -1
- package/esm/node/Digest.test.js +11 -0
- package/esm/node/HttpRequestSender.js +14 -4
- package/esm/node/HttpServer.js +5 -5
- package/esm/{VapixEvents.js → node/VapixEvents.js} +10 -10
- package/esm/node/WsClient.js +22 -15
- package/esm/{events → node/events}/AxisCameraStationEvents.js +18 -13
- package/esm/node/events/GenetecAgent.js +119 -0
- package/esm/node/index.js +17 -2
- package/esm/types/CamOverlayAPI/CamOverlayAPI.js +76 -0
- package/esm/types/CamOverlayAPI/accuweatherSchema.js +44 -0
- package/esm/types/CamOverlayAPI/customGraphicsSchema.js +69 -0
- package/esm/types/CamOverlayAPI/imagesSchema.js +6 -0
- package/esm/types/CamOverlayAPI/index.js +11 -0
- package/esm/types/CamOverlayAPI/infotickerSchema.js +23 -0
- package/esm/types/CamOverlayAPI/pipSchema.js +36 -0
- package/esm/types/CamOverlayAPI/ptzCompassSchema.js +23 -0
- package/esm/types/CamOverlayAPI/ptzSchema.js +9 -0
- package/esm/types/CamOverlayAPI/scoreBoardSchema.js +129 -0
- package/esm/types/CamOverlayAPI/screenSharingSchema.js +5 -0
- package/esm/types/CamOverlayAPI/serviceCommonTypes.js +88 -0
- package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +5 -0
- package/esm/types/CamOverlayPainter.js +11 -0
- package/esm/types/CamScripterAPI.js +23 -7
- package/esm/types/CamScripterAPICameraEventsGenerator.js +1 -0
- package/esm/types/CamStreamerAPI.js +33 -2
- package/esm/types/CamSwitcherAPI.js +38 -1
- package/esm/types/GenetecAgent.js +28 -0
- package/esm/types/PlaneTrackerAPI.js +307 -0
- package/esm/types/VapixAPI.js +70 -12
- package/esm/types/VapixEvents.js +1 -0
- package/esm/types/common.js +3 -1
- package/esm/types/ws/CamOverlayEvents.js +16 -0
- package/esm/types/ws/CamStreamerEvents.js +29 -0
- package/esm/types/{CamSwitcherEvents.js → ws/CamSwitcherEvents.js} +8 -0
- package/esm/types/ws/PlaneTrackerEvents.js +191 -0
- package/esm/web/DefaultClient.js +26 -10
- package/esm/web/WsClient.js +16 -18
- package/esm/ws/CamOverlayEvents.js +20 -0
- package/esm/ws/CamStreamerEvents.js +20 -0
- package/esm/ws/CamSwitcherEvents.js +20 -0
- package/esm/ws/PlaneTrackerEvents.js +26 -0
- package/package.json +29 -11
- package/types/CamOverlayAPI.d.ts +867 -0
- package/types/CamScripterAPI.d.ts +46 -0
- package/types/CamStreamerAPI.d.ts +64 -0
- package/types/CamSwitcherAPI.d.ts +167 -0
- package/types/PlaneTrackerAPI.d.ts +229 -0
- package/types/VapixAPI.d.ts +118 -0
- package/types/bin/CreatePackage.d.ts +1 -0
- package/types/errors/errors.d.ts +83 -0
- package/types/index.d.ts +27 -0
- package/types/internal/ProxyClient.d.ts +10 -0
- package/types/internal/WsEvents.d.ts +37 -0
- package/types/internal/types.d.ts +47 -0
- package/{cjs → types}/internal/utils.d.ts +4 -1
- package/{cjs → types}/internal/versionCompare.d.ts +2 -2
- package/types/node/CamOverlayDrawingAPI.d.ts +41 -0
- package/{esm → types/node}/CamOverlayPainter/Frame.d.ts +8 -37
- package/{cjs → types/node}/CamOverlayPainter/Painter.d.ts +5 -21
- package/types/node/CamOverlayPainter/ResourceManager.d.ts +15 -0
- package/types/node/CamScripterAPICameraEventsGenerator.d.ts +31 -0
- package/types/node/DefaultClient.d.ts +16 -0
- package/types/node/Digest.test.d.ts +1 -0
- package/{esm → types}/node/HttpRequestSender.d.ts +1 -0
- package/{cjs → types}/node/HttpServer.d.ts +2 -2
- package/types/node/VapixEvents.d.ts +16 -0
- package/types/node/WsClient.d.ts +30 -0
- package/types/node/events/AxisCameraStationEvents.d.ts +12 -0
- package/types/node/events/GenetecAgent.d.ts +16 -0
- package/types/node/index.d.ts +17 -0
- package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +4330 -0
- package/types/types/CamOverlayAPI/accuweatherSchema.d.ts +84 -0
- package/types/types/CamOverlayAPI/customGraphicsSchema.d.ts +700 -0
- package/types/types/CamOverlayAPI/imagesSchema.d.ts +95 -0
- package/types/types/CamOverlayAPI/index.d.ts +11 -0
- package/types/types/CamOverlayAPI/infotickerSchema.d.ts +96 -0
- package/types/types/CamOverlayAPI/pipSchema.d.ts +125 -0
- package/types/types/CamOverlayAPI/ptzCompassSchema.d.ts +96 -0
- package/types/types/CamOverlayAPI/ptzSchema.d.ts +118 -0
- package/types/types/CamOverlayAPI/scoreBoardSchema.d.ts +357 -0
- package/types/types/CamOverlayAPI/screenSharingSchema.d.ts +58 -0
- package/types/types/CamOverlayAPI/serviceCommonTypes.d.ts +145 -0
- package/types/types/CamOverlayAPI/webCameraSharingSchema.d.ts +58 -0
- package/types/types/CamOverlayDrawingAPI.d.ts +48 -0
- package/types/types/CamOverlayPainter.d.ts +76 -0
- package/types/types/CamScripterAPI.d.ts +130 -0
- package/types/types/CamScripterAPICameraEventsGenerator.d.ts +45 -0
- package/types/types/CamStreamerAPI.d.ts +272 -0
- package/{esm → types}/types/CamSwitcherAPI.d.ts +145 -66
- package/{esm/events → types/types}/GenetecAgent.d.ts +47 -47
- package/types/types/PlaneTrackerAPI.d.ts +918 -0
- package/{cjs → types}/types/VapixAPI.d.ts +647 -465
- package/types/types/VapixEvents.d.ts +15 -0
- package/{cjs → types}/types/common.d.ts +17 -5
- package/types/types/ws/CamOverlayEvents.d.ts +88 -0
- package/types/types/ws/CamStreamerEvents.d.ts +249 -0
- package/{cjs/types → types/types/ws}/CamSwitcherEvents.d.ts +77 -0
- package/types/types/ws/PlaneTrackerEvents.d.ts +1597 -0
- package/types/web/DefaultClient.d.ts +8 -0
- package/types/web/WsClient.d.ts +17 -0
- package/types/ws/CamOverlayEvents.d.ts +8 -0
- package/types/ws/CamStreamerEvents.d.ts +8 -0
- package/types/ws/CamSwitcherEvents.d.ts +8 -0
- package/types/ws/PlaneTrackerEvents.d.ts +9 -0
- package/cjs/CamOverlayAPI.d.ts +0 -31
- package/cjs/CamOverlayDrawingAPI.d.ts +0 -86
- package/cjs/CamOverlayPainter/Frame.d.ts +0 -96
- package/cjs/CamOverlayPainter/ResourceManager.d.ts +0 -14
- package/cjs/CamOverlayPainter/ResourceManager.js +0 -46
- package/cjs/CamScripterAPI.d.ts +0 -19
- package/cjs/CamScripterAPICameraEventsGenerator.d.ts +0 -74
- package/cjs/CamStreamerAPI.d.ts +0 -16
- package/cjs/CamSwitcherAPI.d.ts +0 -48
- package/cjs/CamSwitcherEvents.d.ts +0 -18
- package/cjs/VapixAPI.d.ts +0 -66
- package/cjs/VapixEvents.d.ts +0 -43
- package/cjs/errors/errors.d.ts +0 -34
- package/cjs/events/AxisCameraStationEvents.d.ts +0 -9
- package/cjs/events/AxisCameraStationEvents.js +0 -48
- package/cjs/events/GenetecAgent.d.ts +0 -174
- package/cjs/events/GenetecAgent.js +0 -123
- package/cjs/index.d.ts +0 -11
- package/cjs/internal/ProxyClient.d.ts +0 -11
- package/cjs/internal/common.d.ts +0 -39
- package/cjs/internal/common.js +0 -27
- package/cjs/node/DefaultClient.d.ts +0 -15
- package/cjs/node/HttpRequestSender.d.ts +0 -28
- package/cjs/node/WsClient.d.ts +0 -39
- package/cjs/node/WsEventClient.d.ts +0 -13
- package/cjs/node/WsEventClient.js +0 -22
- package/cjs/types/CamOverlayAPI.d.ts +0 -188
- package/cjs/types/CamOverlayAPI.js +0 -47
- package/cjs/types/CamScripterAPI.d.ts +0 -67
- package/cjs/types/CamStreamerAPI.d.ts +0 -139
- package/cjs/types/CamSwitcherAPI.d.ts +0 -814
- package/cjs/web/DefaultClient.d.ts +0 -6
- package/cjs/web/WsClient.d.ts +0 -13
- package/cjs/web/index.d.ts +0 -2
- package/esm/CamOverlayAPI.d.ts +0 -31
- package/esm/CamOverlayDrawingAPI.d.ts +0 -86
- package/esm/CamOverlayPainter/Painter.d.ts +0 -48
- package/esm/CamOverlayPainter/ResourceManager.d.ts +0 -14
- package/esm/CamScripterAPI.d.ts +0 -19
- package/esm/CamScripterAPICameraEventsGenerator.d.ts +0 -74
- package/esm/CamStreamerAPI.d.ts +0 -16
- package/esm/CamSwitcherAPI.d.ts +0 -48
- package/esm/CamSwitcherEvents.d.ts +0 -18
- package/esm/VapixAPI.d.ts +0 -66
- package/esm/VapixEvents.d.ts +0 -43
- package/esm/errors/errors.d.ts +0 -34
- package/esm/events/AxisCameraStationEvents.d.ts +0 -9
- package/esm/events/GenetecAgent.js +0 -119
- package/esm/index.d.ts +0 -11
- package/esm/internal/Digest.d.ts +0 -4
- package/esm/internal/ProxyClient.d.ts +0 -11
- package/esm/internal/common.d.ts +0 -39
- package/esm/internal/common.js +0 -20
- package/esm/internal/constants.d.ts +0 -1
- package/esm/internal/transformers.d.ts +0 -5
- package/esm/internal/utils.d.ts +0 -11
- package/esm/internal/versionCompare.d.ts +0 -6
- package/esm/node/DefaultClient.d.ts +0 -15
- package/esm/node/HttpServer.d.ts +0 -21
- package/esm/node/WsClient.d.ts +0 -39
- package/esm/node/WsEventClient.d.ts +0 -13
- package/esm/node/WsEventClient.js +0 -18
- package/esm/node/index.d.ts +0 -2
- package/esm/types/CamOverlayAPI.d.ts +0 -188
- package/esm/types/CamOverlayAPI.js +0 -44
- package/esm/types/CamScripterAPI.d.ts +0 -67
- package/esm/types/CamStreamerAPI.d.ts +0 -139
- package/esm/types/CamSwitcherEvents.d.ts +0 -491
- package/esm/types/VapixAPI.d.ts +0 -1683
- package/esm/types/common.d.ts +0 -37
- package/esm/web/DefaultClient.d.ts +0 -6
- package/esm/web/WsClient.d.ts +0 -13
- package/esm/web/index.d.ts +0 -2
- /package/{cjs/CreatePackage.d.ts → esm/internal/types.js} +0 -0
- /package/esm/{CreatePackage.d.ts → types/CamOverlayDrawingAPI.js} +0 -0
- /package/{cjs → types}/internal/constants.d.ts +0 -0
- /package/{cjs → types}/internal/transformers.d.ts +0 -0
- /package/{cjs/internal → types/node}/Digest.d.ts +0 -0
- /package/{cjs/node → types/web}/index.d.ts +0 -0
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
+
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
6
9
|
const child_process_1 = require("child_process");
|
|
7
10
|
const productionModulesFolder = 'production_modules';
|
|
8
11
|
function isDirectory(path) {
|
|
9
|
-
const stat =
|
|
12
|
+
const stat = fs_1.default.statSync(path);
|
|
10
13
|
return stat.isDirectory();
|
|
11
14
|
}
|
|
12
15
|
function getPackageInfo(folder) {
|
|
13
16
|
try {
|
|
14
|
-
const manifest =
|
|
17
|
+
const manifest = fs_1.default.readFileSync(path_1.default.join(folder, 'manifest.json'));
|
|
15
18
|
const manifestParsed = JSON.parse(manifest.toString());
|
|
16
19
|
return {
|
|
17
20
|
packageName: manifestParsed.package_name,
|
|
@@ -23,10 +26,10 @@ function getPackageInfo(folder) {
|
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
function createZipArchive(zip, folder, options) {
|
|
26
|
-
const zipFileRegex = new RegExp(`${
|
|
27
|
-
const files =
|
|
29
|
+
const zipFileRegex = new RegExp(`${path_1.default.basename(folder)}(_[0-9]){3}\\.zip`);
|
|
30
|
+
const files = fs_1.default.readdirSync(folder);
|
|
28
31
|
for (const file of files) {
|
|
29
|
-
const path =
|
|
32
|
+
const path = path_1.default.join(folder, file);
|
|
30
33
|
const isDir = isDirectory(path);
|
|
31
34
|
if (file[0] === '.' ||
|
|
32
35
|
zipFileRegex.test(file) ||
|
|
@@ -39,7 +42,7 @@ function createZipArchive(zip, folder, options) {
|
|
|
39
42
|
zip.addLocalFolder(path);
|
|
40
43
|
}
|
|
41
44
|
else if (file === productionModulesFolder && options.includeNodeModules) {
|
|
42
|
-
zip.addLocalFolder(
|
|
45
|
+
zip.addLocalFolder(path_1.default.join(productionModulesFolder, 'node_modules'), 'node_modules');
|
|
43
46
|
}
|
|
44
47
|
else if (isDir) {
|
|
45
48
|
zip.addLocalFolder(path, file);
|
|
@@ -50,13 +53,13 @@ function createZipArchive(zip, folder, options) {
|
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
function installDependencies() {
|
|
53
|
-
if (!
|
|
54
|
-
|
|
56
|
+
if (!fs_1.default.existsSync(productionModulesFolder)) {
|
|
57
|
+
fs_1.default.mkdirSync(productionModulesFolder, {});
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
fs_1.default.cpSync('package.json', path_1.default.join(productionModulesFolder, 'package.json'));
|
|
60
|
+
fs_1.default.cpSync('package-lock.json', path_1.default.join(productionModulesFolder, 'package-lock.json'));
|
|
58
61
|
(0, child_process_1.execSync)(`npm ci --omit=dev`, {
|
|
59
|
-
cwd:
|
|
62
|
+
cwd: path_1.default.join(process.cwd(), productionModulesFolder),
|
|
60
63
|
});
|
|
61
64
|
}
|
|
62
65
|
function main(args) {
|
|
@@ -80,26 +83,26 @@ function main(args) {
|
|
|
80
83
|
if (options.includeNodeModules) {
|
|
81
84
|
installDependencies();
|
|
82
85
|
}
|
|
83
|
-
if (
|
|
86
|
+
if (fs_1.default.existsSync('dist')) {
|
|
84
87
|
options.typeScriptPackage = true;
|
|
85
88
|
}
|
|
86
|
-
const folder =
|
|
89
|
+
const folder = path_1.default.resolve('.');
|
|
87
90
|
const packageInfo = getPackageInfo(folder);
|
|
88
91
|
if (packageInfo === undefined) {
|
|
89
92
|
console.error('Package info not found');
|
|
90
93
|
process.exit(1);
|
|
91
94
|
}
|
|
92
95
|
const zipFile = `${options.outputFolder}/${packageInfo.packageName}_${packageInfo.packageVersion}.zip`;
|
|
93
|
-
if (
|
|
96
|
+
if (fs_1.default.existsSync(zipFile)) {
|
|
94
97
|
try {
|
|
95
|
-
|
|
98
|
+
fs_1.default.unlinkSync(zipFile);
|
|
96
99
|
}
|
|
97
100
|
catch (error) {
|
|
98
101
|
console.error('An error occured: ', error);
|
|
99
102
|
process.exit(1);
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
|
-
const zip = new
|
|
105
|
+
const zip = new adm_zip_1.default();
|
|
103
106
|
createZipArchive(zip, folder, options);
|
|
104
107
|
zip.writeZip(zipFile);
|
|
105
108
|
}
|
package/cjs/errors/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = void 0;
|
|
3
|
+
exports.BadRequestError = exports.ServerError = exports.InvalidAltitudeError = exports.InvalidLatLngError = exports.CannotSetCoordsInAutoModeError = exports.ImportSettingsError = exports.ResetCalibrationError = exports.TimezoneFetchError = exports.TimezoneNotSetupError = exports.UtcTimeFetchError = exports.WsAuthorizationError = exports.StorageDataFetchError = exports.PtzNotSupportedError = exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.SettingParameterError = exports.ParameterNotFoundError = exports.JsonParseError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = void 0;
|
|
4
4
|
class ServiceUnavailableError extends Error {
|
|
5
5
|
constructor() {
|
|
6
6
|
super('Service is unavailable.');
|
|
@@ -22,6 +22,27 @@ class ParsingBlobError extends Error {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
exports.ParsingBlobError = ParsingBlobError;
|
|
25
|
+
class JsonParseError extends Error {
|
|
26
|
+
constructor(paramName, data) {
|
|
27
|
+
super(`Error: in JSON parsing of ${paramName}. Cannot parse: ${data}`);
|
|
28
|
+
this.name = 'JsonParseError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.JsonParseError = JsonParseError;
|
|
32
|
+
class ParameterNotFoundError extends Error {
|
|
33
|
+
constructor(paramName) {
|
|
34
|
+
super(`Error: no parameter '${paramName}' was found`);
|
|
35
|
+
this.name = 'ParameterNotFoundError';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ParameterNotFoundError = ParameterNotFoundError;
|
|
39
|
+
class SettingParameterError extends Error {
|
|
40
|
+
constructor(message) {
|
|
41
|
+
super(`Error setting parameter to camera: ${message}`);
|
|
42
|
+
this.name = 'SettingParameterError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.SettingParameterError = SettingParameterError;
|
|
25
46
|
class ApplicationAPIError extends Error {
|
|
26
47
|
constructor(action, res) {
|
|
27
48
|
super(`[APP ${action}] Error: ` + res);
|
|
@@ -77,3 +98,94 @@ class AddNewClipError extends Error {
|
|
|
77
98
|
}
|
|
78
99
|
}
|
|
79
100
|
exports.AddNewClipError = AddNewClipError;
|
|
101
|
+
class PtzNotSupportedError extends Error {
|
|
102
|
+
constructor() {
|
|
103
|
+
super('Ptz not supported.');
|
|
104
|
+
this.name = 'PtzNotSupportedError';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.PtzNotSupportedError = PtzNotSupportedError;
|
|
108
|
+
class StorageDataFetchError extends Error {
|
|
109
|
+
constructor(err) {
|
|
110
|
+
super('Error fetching storage data: ' + err);
|
|
111
|
+
this.name = 'StorageDataFetchError';
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.StorageDataFetchError = StorageDataFetchError;
|
|
115
|
+
class WsAuthorizationError extends Error {
|
|
116
|
+
constructor(message) {
|
|
117
|
+
super('Server error on ws authorization: ' + message);
|
|
118
|
+
this.name = 'WsAuthorizationError';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.WsAuthorizationError = WsAuthorizationError;
|
|
122
|
+
class UtcTimeFetchError extends Error {
|
|
123
|
+
constructor(message) {
|
|
124
|
+
super('Server error on get UTC time: ' + message);
|
|
125
|
+
this.name = 'UtcTimeFetchError';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.UtcTimeFetchError = UtcTimeFetchError;
|
|
129
|
+
class TimezoneNotSetupError extends Error {
|
|
130
|
+
constructor() {
|
|
131
|
+
super('Time zone not setup on the device');
|
|
132
|
+
this.name = 'TimezoneNotSetupError';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.TimezoneNotSetupError = TimezoneNotSetupError;
|
|
136
|
+
class TimezoneFetchError extends Error {
|
|
137
|
+
constructor(err) {
|
|
138
|
+
super('Error fetching time zone information: ' + err);
|
|
139
|
+
this.name = 'TimezoneFetchError';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.TimezoneFetchError = TimezoneFetchError;
|
|
143
|
+
class ResetCalibrationError extends Error {
|
|
144
|
+
constructor(type, err) {
|
|
145
|
+
super('Error resetting ' + type.toLowerCase() + ' calibration: ' + err);
|
|
146
|
+
this.name = 'ResetCalibrationError';
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.ResetCalibrationError = ResetCalibrationError;
|
|
150
|
+
class ImportSettingsError extends Error {
|
|
151
|
+
constructor(err) {
|
|
152
|
+
super('Error importing settings: ' + err);
|
|
153
|
+
this.name = 'ImportSettingsError';
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.ImportSettingsError = ImportSettingsError;
|
|
157
|
+
class CannotSetCoordsInAutoModeError extends Error {
|
|
158
|
+
constructor() {
|
|
159
|
+
super("The automatic mode doesn't allow control of the camera.");
|
|
160
|
+
this.name = 'CannotSetCoordsInAutoModeError';
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.CannotSetCoordsInAutoModeError = CannotSetCoordsInAutoModeError;
|
|
164
|
+
class InvalidLatLngError extends Error {
|
|
165
|
+
constructor() {
|
|
166
|
+
super('The provided latitude or longitude parameters are invalid.');
|
|
167
|
+
this.name = 'InvalidLatLngError';
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.InvalidLatLngError = InvalidLatLngError;
|
|
171
|
+
class InvalidAltitudeError extends Error {
|
|
172
|
+
constructor() {
|
|
173
|
+
super('The provided altitude parameter is invalid.');
|
|
174
|
+
this.name = 'InvalidAltitudeError';
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.InvalidAltitudeError = InvalidAltitudeError;
|
|
178
|
+
class ServerError extends Error {
|
|
179
|
+
constructor() {
|
|
180
|
+
super('An internal server error occurred.');
|
|
181
|
+
this.name = 'ServerError';
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.ServerError = ServerError;
|
|
185
|
+
class BadRequestError extends Error {
|
|
186
|
+
constructor(err) {
|
|
187
|
+
super('An unknown error occurred: ' + err);
|
|
188
|
+
this.name = 'UnknownError';
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.BadRequestError = BadRequestError;
|
package/cjs/index.js
CHANGED
|
@@ -14,18 +14,41 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.VapixAPI = exports.CamSwitcherEvents = exports.CamSwitcherAPI = void 0;
|
|
18
|
-
__exportStar(require("./
|
|
17
|
+
exports.VapixAPI = exports.CamScripterAPI = exports.PlaneTrackerEvents = exports.PlaneTrackerAPI = exports.CamSwitcherEvents = exports.CamSwitcherAPI = exports.CamOverlayEvents = exports.CamOverlayAPI = exports.CamStreamerEvents = exports.CamStreamerAPI = void 0;
|
|
18
|
+
__exportStar(require("./errors/errors"), exports);
|
|
19
|
+
__exportStar(require("./internal/types"), exports);
|
|
19
20
|
__exportStar(require("./internal/constants"), exports);
|
|
20
21
|
__exportStar(require("./internal/utils"), exports);
|
|
21
22
|
__exportStar(require("./internal/versionCompare"), exports);
|
|
23
|
+
__exportStar(require("./internal/ProxyClient"), exports);
|
|
22
24
|
__exportStar(require("./types/common"), exports);
|
|
25
|
+
var CamStreamerAPI_1 = require("./CamStreamerAPI");
|
|
26
|
+
Object.defineProperty(exports, "CamStreamerAPI", { enumerable: true, get: function () { return CamStreamerAPI_1.CamStreamerAPI; } });
|
|
27
|
+
__exportStar(require("./types/CamStreamerAPI"), exports);
|
|
28
|
+
var CamStreamerEvents_1 = require("./ws/CamStreamerEvents");
|
|
29
|
+
Object.defineProperty(exports, "CamStreamerEvents", { enumerable: true, get: function () { return CamStreamerEvents_1.CamStreamerEvents; } });
|
|
30
|
+
__exportStar(require("./types/ws/CamStreamerEvents"), exports);
|
|
31
|
+
var CamOverlayAPI_1 = require("./CamOverlayAPI");
|
|
32
|
+
Object.defineProperty(exports, "CamOverlayAPI", { enumerable: true, get: function () { return CamOverlayAPI_1.CamOverlayAPI; } });
|
|
33
|
+
__exportStar(require("./types/CamOverlayAPI"), exports);
|
|
34
|
+
var CamOverlayEvents_1 = require("./ws/CamOverlayEvents");
|
|
35
|
+
Object.defineProperty(exports, "CamOverlayEvents", { enumerable: true, get: function () { return CamOverlayEvents_1.CamOverlayEvents; } });
|
|
36
|
+
__exportStar(require("./types/ws/CamOverlayEvents"), exports);
|
|
23
37
|
var CamSwitcherAPI_1 = require("./CamSwitcherAPI");
|
|
24
38
|
Object.defineProperty(exports, "CamSwitcherAPI", { enumerable: true, get: function () { return CamSwitcherAPI_1.CamSwitcherAPI; } });
|
|
25
|
-
|
|
39
|
+
__exportStar(require("./types/CamSwitcherAPI"), exports);
|
|
40
|
+
var CamSwitcherEvents_1 = require("./ws/CamSwitcherEvents");
|
|
26
41
|
Object.defineProperty(exports, "CamSwitcherEvents", { enumerable: true, get: function () { return CamSwitcherEvents_1.CamSwitcherEvents; } });
|
|
42
|
+
__exportStar(require("./types/ws/CamSwitcherEvents"), exports);
|
|
43
|
+
var PlaneTrackerAPI_1 = require("./PlaneTrackerAPI");
|
|
44
|
+
Object.defineProperty(exports, "PlaneTrackerAPI", { enumerable: true, get: function () { return PlaneTrackerAPI_1.PlaneTrackerAPI; } });
|
|
45
|
+
__exportStar(require("./types/PlaneTrackerAPI"), exports);
|
|
46
|
+
var PlaneTrackerEvents_1 = require("./ws/PlaneTrackerEvents");
|
|
47
|
+
Object.defineProperty(exports, "PlaneTrackerEvents", { enumerable: true, get: function () { return PlaneTrackerEvents_1.PlaneTrackerEvents; } });
|
|
48
|
+
__exportStar(require("./types/ws/PlaneTrackerEvents"), exports);
|
|
49
|
+
var CamScripterAPI_1 = require("./CamScripterAPI");
|
|
50
|
+
Object.defineProperty(exports, "CamScripterAPI", { enumerable: true, get: function () { return CamScripterAPI_1.CamScripterAPI; } });
|
|
51
|
+
__exportStar(require("./types/CamScripterAPI"), exports);
|
|
27
52
|
var VapixAPI_1 = require("./VapixAPI");
|
|
28
53
|
Object.defineProperty(exports, "VapixAPI", { enumerable: true, get: function () { return VapixAPI_1.VapixAPI; } });
|
|
29
|
-
__exportStar(require("./types/CamSwitcherEvents"), exports);
|
|
30
|
-
__exportStar(require("./types/CamSwitcherAPI"), exports);
|
|
31
54
|
__exportStar(require("./types/VapixAPI"), exports);
|
|
@@ -4,41 +4,37 @@ exports.ProxyClient = void 0;
|
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
class ProxyClient {
|
|
6
6
|
client;
|
|
7
|
-
|
|
8
|
-
constructor(client,
|
|
7
|
+
proxyParams;
|
|
8
|
+
constructor(client, proxyParams) {
|
|
9
9
|
this.client = client;
|
|
10
|
-
this.
|
|
10
|
+
this.proxyParams = proxyParams;
|
|
11
11
|
}
|
|
12
|
-
get
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
realUrl: this.getProxyUrl(),
|
|
26
|
-
realHeaders: {
|
|
27
|
-
...(headers ?? {}),
|
|
28
|
-
'x-target-camera-protocol': proxy.port === 443 ? 'https' : 'http',
|
|
29
|
-
'x-target-camera-path': url,
|
|
30
|
-
'x-target-camera-ip': proxy.ip,
|
|
31
|
-
'x-target-camera-mdns': proxy.mdnsName,
|
|
32
|
-
'x-target-camera-port': String(proxy.port),
|
|
33
|
-
'x-target-camera-pass': encodeURIComponent(proxy.pass),
|
|
34
|
-
'x-target-camera-user': encodeURIComponent(proxy.user),
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
}
|
|
12
|
+
get(params) {
|
|
13
|
+
const { path, parameters, headers, timeout } = params;
|
|
14
|
+
const targetPath = (0, utils_1.addParametersToPath)(path, parameters);
|
|
15
|
+
const { realPath, realHeaders } = this.getReal(targetPath, headers);
|
|
16
|
+
return this.client.get({ path: realPath, headers: realHeaders, timeout });
|
|
17
|
+
}
|
|
18
|
+
post(params) {
|
|
19
|
+
const { path, data, parameters, headers, timeout } = params;
|
|
20
|
+
const targetPath = (0, utils_1.addParametersToPath)(path, parameters);
|
|
21
|
+
const { realPath, realHeaders } = this.getReal(targetPath, headers);
|
|
22
|
+
return this.client.post({ path: realPath, data, headers: realHeaders, timeout });
|
|
23
|
+
}
|
|
24
|
+
getReal(targetPath, headers) {
|
|
38
25
|
return {
|
|
39
|
-
|
|
40
|
-
realHeaders:
|
|
26
|
+
realPath: this.proxyParams.path,
|
|
27
|
+
realHeaders: {
|
|
28
|
+
...(headers ?? {}),
|
|
29
|
+
'x-target-camera-protocol': this.proxyParams.target.port === 443 ? 'https' : 'http',
|
|
30
|
+
'x-target-camera-path': targetPath,
|
|
31
|
+
'x-target-camera-ip': this.proxyParams.target.ip,
|
|
32
|
+
'x-target-camera-mdns': this.proxyParams.target.mdnsName,
|
|
33
|
+
'x-target-camera-port': String(this.proxyParams.target.port),
|
|
34
|
+
'x-target-camera-pass': this.proxyParams.target.pass,
|
|
35
|
+
'x-target-camera-user': this.proxyParams.target.user,
|
|
36
|
+
},
|
|
41
37
|
};
|
|
42
|
-
}
|
|
38
|
+
}
|
|
43
39
|
}
|
|
44
40
|
exports.ProxyClient = ProxyClient;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.WsEvents = void 0;
|
|
4
|
+
class WsEvents {
|
|
5
|
+
validate;
|
|
6
|
+
ws;
|
|
7
|
+
_isDestroyed = false;
|
|
8
8
|
listeners = {};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.ws.destroy();
|
|
12
|
-
}
|
|
9
|
+
constructor(validate, ws) {
|
|
10
|
+
this.validate = validate;
|
|
13
11
|
this.ws = ws;
|
|
14
|
-
this.ws.
|
|
12
|
+
this.ws.onMessage = (e) => this.onMessage(e);
|
|
13
|
+
}
|
|
14
|
+
get isDestroyed() {
|
|
15
|
+
return this._isDestroyed;
|
|
15
16
|
}
|
|
16
17
|
resendInitData() {
|
|
17
18
|
const request = {
|
|
18
19
|
command: 'sendInitData',
|
|
19
20
|
};
|
|
20
|
-
this.ws
|
|
21
|
+
this.ws.send(JSON.stringify(request));
|
|
21
22
|
}
|
|
22
23
|
addListener(type, listener, id) {
|
|
23
24
|
const typeList = this.listeners[type];
|
|
@@ -31,23 +32,26 @@ class CamSwitcherEvents {
|
|
|
31
32
|
const typeList = this.listeners[type];
|
|
32
33
|
if (typeList) {
|
|
33
34
|
delete typeList[id];
|
|
35
|
+
if (Object.keys(typeList).length === 0) {
|
|
36
|
+
delete this.listeners[type];
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
|
-
onMessage(
|
|
40
|
+
onMessage(incomeData) {
|
|
37
41
|
if (this.isDestroyed) {
|
|
38
42
|
return;
|
|
39
43
|
}
|
|
40
44
|
try {
|
|
41
|
-
const eventData = JSON.parse(
|
|
42
|
-
const data =
|
|
43
|
-
if (data
|
|
45
|
+
const eventData = JSON.parse(incomeData.toString());
|
|
46
|
+
const data = this.validate(eventData);
|
|
47
|
+
if (isInitEvent(data)) {
|
|
44
48
|
this.processMessage(data.data, true);
|
|
45
49
|
return;
|
|
46
50
|
}
|
|
47
51
|
this.processMessage(data, false);
|
|
48
52
|
}
|
|
49
53
|
catch (error) {
|
|
50
|
-
console.error('Error parsing event data:',
|
|
54
|
+
console.error('Error parsing event data:', incomeData.toString(), error);
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
processMessage(event, isInit) {
|
|
@@ -56,12 +60,14 @@ class CamSwitcherEvents {
|
|
|
56
60
|
list.forEach((listener) => listener(event, isInit));
|
|
57
61
|
}
|
|
58
62
|
destroy() {
|
|
59
|
-
this.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
63
|
+
this._isDestroyed = true;
|
|
64
|
+
this.ws.onMessage = () => { };
|
|
65
|
+
this.ws.onOpen = () => Promise.reject(new Error('Websocket is destroyed'));
|
|
66
|
+
this.ws.destroy();
|
|
64
67
|
this.listeners = {};
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
|
-
exports.
|
|
70
|
+
exports.WsEvents = WsEvents;
|
|
71
|
+
const isInitEvent = (event) => {
|
|
72
|
+
return event.type === 'init';
|
|
73
|
+
};
|
package/cjs/internal/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLoopPlayType = exports.isPlaylist = exports.isTracker = exports.isClip = exports.isStream = exports.isCamera = exports.arrayToUrl = exports.paramToUrl = exports.addParametersToPath = void 0;
|
|
4
|
-
const common_1 = require("./common");
|
|
3
|
+
exports.isNullish = exports.pad = exports.responseStringify = exports.isLoopPlayType = exports.isPlaylist = exports.isTracker = exports.isClip = exports.isStream = exports.isCamera = exports.arrayToUrl = exports.paramToUrl = exports.addParametersToPath = void 0;
|
|
5
4
|
const addParametersToPath = (path, params) => {
|
|
6
5
|
if (params === undefined || Object.keys(params).length === 0) {
|
|
7
6
|
return path;
|
|
@@ -17,7 +16,7 @@ const paramToUrl = (params) => {
|
|
|
17
16
|
let output = '';
|
|
18
17
|
for (const key in params) {
|
|
19
18
|
const value = params[key];
|
|
20
|
-
if (
|
|
19
|
+
if (isNullish(value)) {
|
|
21
20
|
continue;
|
|
22
21
|
}
|
|
23
22
|
output += `${encodeURIComponent(key)}=${encodeURIComponent(value)}&`;
|
|
@@ -44,3 +43,23 @@ const isPlaylist = (id) => id?.charAt(0) === 'p';
|
|
|
44
43
|
exports.isPlaylist = isPlaylist;
|
|
45
44
|
const isLoopPlayType = (playType) => playType.includes('LOOP');
|
|
46
45
|
exports.isLoopPlayType = isLoopPlayType;
|
|
46
|
+
async function responseStringify(res) {
|
|
47
|
+
return JSON.stringify({
|
|
48
|
+
status: res.status,
|
|
49
|
+
body: await res.text(),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.responseStringify = responseStringify;
|
|
53
|
+
function pad(num, size) {
|
|
54
|
+
const sign = Math.sign(num) === -1 ? '-' : '';
|
|
55
|
+
return (sign +
|
|
56
|
+
new Array(size)
|
|
57
|
+
.concat([Math.abs(num)])
|
|
58
|
+
.join('0')
|
|
59
|
+
.slice(-size));
|
|
60
|
+
}
|
|
61
|
+
exports.pad = pad;
|
|
62
|
+
function isNullish(value) {
|
|
63
|
+
return value === null || value === undefined;
|
|
64
|
+
}
|
|
65
|
+
exports.isNullish = isNullish;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.CamOverlayDrawingAPI = void 0;
|
|
4
|
-
const
|
|
5
|
-
const WsClient_1 = require("./
|
|
6
|
-
class CamOverlayDrawingAPI extends
|
|
7
|
+
const events_1 = __importDefault(require("events"));
|
|
8
|
+
const WsClient_1 = require("./WsClient");
|
|
9
|
+
class CamOverlayDrawingAPI extends events_1.default {
|
|
7
10
|
tls;
|
|
8
11
|
tlsInsecure;
|
|
9
12
|
ip;
|
|
@@ -37,14 +40,14 @@ class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
37
40
|
this.sendMessages = {};
|
|
38
41
|
this.wsConnected = false;
|
|
39
42
|
this.createWsClient();
|
|
40
|
-
|
|
43
|
+
events_1.default.call(this);
|
|
41
44
|
}
|
|
42
45
|
connect() {
|
|
43
46
|
this.ws.open();
|
|
44
47
|
this.startMsgsTimeoutCheck();
|
|
45
48
|
}
|
|
46
49
|
disconnect() {
|
|
47
|
-
this.ws.
|
|
50
|
+
this.ws.destroy();
|
|
48
51
|
this.stopMsgsTimeoutCheck();
|
|
49
52
|
}
|
|
50
53
|
isConnected() {
|
|
@@ -101,23 +104,23 @@ class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
101
104
|
tlsInsecure: this.tlsInsecure,
|
|
102
105
|
};
|
|
103
106
|
this.ws = new WsClient_1.WsClient(options);
|
|
104
|
-
this.ws.
|
|
107
|
+
this.ws.onOpen = () => {
|
|
105
108
|
console.log('CamOverlay connection opened');
|
|
106
109
|
this.wsConnected = true;
|
|
107
110
|
this.emit('open');
|
|
108
|
-
}
|
|
109
|
-
this.ws.
|
|
110
|
-
this.ws.
|
|
111
|
+
};
|
|
112
|
+
this.ws.onMessage = (data) => this.incomingWsMessageHandler(data.toString());
|
|
113
|
+
this.ws.onError = (error) => {
|
|
111
114
|
this.reportError(error);
|
|
112
|
-
}
|
|
113
|
-
this.ws.
|
|
115
|
+
};
|
|
116
|
+
this.ws.onClose = () => {
|
|
114
117
|
console.log('CamOverlay connection closed');
|
|
115
118
|
this.wsConnected = false;
|
|
116
119
|
this.reportClose();
|
|
117
|
-
}
|
|
120
|
+
};
|
|
118
121
|
}
|
|
119
122
|
incomingWsMessageHandler(msgData) {
|
|
120
|
-
const dataJSON = JSON.parse(msgData
|
|
123
|
+
const dataJSON = JSON.parse(msgData);
|
|
121
124
|
let errorResponse;
|
|
122
125
|
if ('error' in dataJSON) {
|
|
123
126
|
errorResponse = dataJSON;
|
|
@@ -174,7 +177,7 @@ class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
174
177
|
headerView.setInt8(0, 1);
|
|
175
178
|
headerView.setInt32(1, jsonBuffer.byteLength);
|
|
176
179
|
const msgBuffer = Buffer.concat([Buffer.from(header), jsonBuffer, data]);
|
|
177
|
-
this.ws.send(msgBuffer);
|
|
180
|
+
this.ws.send(msgBuffer.buffer);
|
|
178
181
|
this.sendMessages[this.callId] = { resolve, reject, sentTimestamp: Date.now() };
|
|
179
182
|
}
|
|
180
183
|
catch (err) {
|
|
@@ -57,6 +57,14 @@ class Frame extends events_1.EventEmitter {
|
|
|
57
57
|
this.width = width;
|
|
58
58
|
this.height = height;
|
|
59
59
|
}
|
|
60
|
+
getFrameInfo() {
|
|
61
|
+
return {
|
|
62
|
+
x: this.posX,
|
|
63
|
+
y: this.posY,
|
|
64
|
+
width: this.width,
|
|
65
|
+
height: this.height,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
60
68
|
setText(text, align, textType = 'TFM_OVERFLOW', fontColor) {
|
|
61
69
|
this.text = text;
|
|
62
70
|
this.align = align;
|
|
@@ -76,6 +84,16 @@ class Frame extends events_1.EventEmitter {
|
|
|
76
84
|
this.fontName = undefined;
|
|
77
85
|
this.font = fontData;
|
|
78
86
|
}
|
|
87
|
+
getTextInfo() {
|
|
88
|
+
return {
|
|
89
|
+
text: this.text,
|
|
90
|
+
textAlign: this.align,
|
|
91
|
+
textType: this.textType,
|
|
92
|
+
fontColor: this.fontColor,
|
|
93
|
+
font: this.font,
|
|
94
|
+
fontName: this.fontName,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
79
97
|
setBgColor(color) {
|
|
80
98
|
this.bgColor = color;
|
|
81
99
|
}
|
|
@@ -92,6 +110,14 @@ class Frame extends events_1.EventEmitter {
|
|
|
92
110
|
setBgType(type) {
|
|
93
111
|
this.bgType = type;
|
|
94
112
|
}
|
|
113
|
+
getBgInfo() {
|
|
114
|
+
return {
|
|
115
|
+
bgColor: this.bgColor,
|
|
116
|
+
bgImage: this.bgImage,
|
|
117
|
+
bgImageName: this.bgImageName,
|
|
118
|
+
bgType: this.bgType,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
95
121
|
setBorderRadius(radius) {
|
|
96
122
|
this.borderRadius = radius;
|
|
97
123
|
}
|
|
@@ -101,6 +127,13 @@ class Frame extends events_1.EventEmitter {
|
|
|
101
127
|
setBorderColor(color) {
|
|
102
128
|
this.borderColor = color;
|
|
103
129
|
}
|
|
130
|
+
getBorderInfo() {
|
|
131
|
+
return {
|
|
132
|
+
borderRadius: this.borderRadius,
|
|
133
|
+
borderWidth: this.borderWidth,
|
|
134
|
+
borderColor: this.borderColor,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
104
137
|
setCustomDraw(customDraw) {
|
|
105
138
|
this.customDraw = customDraw;
|
|
106
139
|
}
|
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Painter = void 0;
|
|
4
4
|
const CamOverlayDrawingAPI_1 = require("../CamOverlayDrawingAPI");
|
|
5
5
|
const ResourceManager_1 = require("./ResourceManager");
|
|
6
|
-
exports.ResourceManager = ResourceManager_1.default;
|
|
7
6
|
const Frame_1 = require("./Frame");
|
|
8
|
-
|
|
9
|
-
exports.COORD = {
|
|
10
|
-
top_left: [-1, -1],
|
|
11
|
-
center_left: [-1, 0],
|
|
12
|
-
bottom_left: [-1, 1],
|
|
13
|
-
top_center: [0, -1],
|
|
14
|
-
center: [0, 0],
|
|
15
|
-
bottom_center: [0, 1],
|
|
16
|
-
top_right: [1, -1],
|
|
17
|
-
center_right: [1, 0],
|
|
18
|
-
bottom_right: [1, 1],
|
|
19
|
-
};
|
|
7
|
+
const CamOverlayPainter_1 = require("../../types/CamOverlayPainter");
|
|
20
8
|
class Painter extends Frame_1.Frame {
|
|
21
9
|
screenWidth;
|
|
22
10
|
screenHeight;
|
|
@@ -27,11 +15,11 @@ class Painter extends Frame_1.Frame {
|
|
|
27
15
|
layers = [];
|
|
28
16
|
constructor(opt, coopt) {
|
|
29
17
|
super(opt);
|
|
30
|
-
this.coAlignment =
|
|
18
|
+
this.coAlignment = CamOverlayPainter_1.COORD[opt.coAlignment];
|
|
31
19
|
this.screenWidth = opt.screenWidth;
|
|
32
20
|
this.screenHeight = opt.screenHeight;
|
|
33
21
|
this.cod = new CamOverlayDrawingAPI_1.CamOverlayDrawingAPI(coopt);
|
|
34
|
-
this.rm = new ResourceManager_1.
|
|
22
|
+
this.rm = new ResourceManager_1.ResourceManager(this.cod);
|
|
35
23
|
}
|
|
36
24
|
get camOverlayDrawingAPI() {
|
|
37
25
|
return this.cod;
|
|
@@ -71,7 +59,7 @@ class Painter extends Frame_1.Frame {
|
|
|
71
59
|
this.screenHeight = sh;
|
|
72
60
|
}
|
|
73
61
|
setCoAlignment(coAlignment) {
|
|
74
|
-
this.coAlignment =
|
|
62
|
+
this.coAlignment = CamOverlayPainter_1.COORD[coAlignment];
|
|
75
63
|
}
|
|
76
64
|
layoutChanged() {
|
|
77
65
|
this.refreshLayers = true;
|