camstreamerlib 4.0.0-beta.4 → 4.0.0-beta.41
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 +112 -0
- package/cjs/CamOverlayAPI.js +135 -92
- package/cjs/CamScripterAPI.js +52 -42
- package/cjs/CamStreamerAPI.js +83 -39
- package/cjs/CamSwitcherAPI.js +141 -123
- package/cjs/CamSwitcherEvents.js +4 -60
- package/cjs/PlaneTrackerAPI.js +210 -0
- package/cjs/VapixAPI.js +323 -233
- package/cjs/{CreatePackage.js → bin/CreatePackage.js} +22 -19
- package/cjs/errors/errors.js +78 -1
- package/cjs/index.js +17 -4
- package/cjs/internal/ProxyClient.js +28 -32
- package/cjs/internal/WsEvents.js +72 -0
- package/cjs/internal/types.js +2 -0
- package/cjs/internal/utils.js +22 -3
- package/cjs/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +7 -4
- 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} +7 -4
- package/cjs/node/DefaultClient.js +10 -12
- package/cjs/{internal → node}/Digest.js +8 -5
- package/cjs/node/HttpRequestSender.js +14 -4
- package/cjs/node/HttpServer.js +15 -12
- package/cjs/{VapixEvents.js → node/VapixEvents.js} +1 -1
- package/cjs/node/WsClient.js +12 -9
- 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 +25 -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 +22 -7
- package/cjs/types/CamScripterAPICameraEventsGenerator.js +2 -0
- package/cjs/types/CamStreamerAPI.js +34 -3
- package/cjs/types/CamSwitcherAPI.js +38 -1
- package/cjs/types/CamSwitcherEvents.js +8 -0
- package/cjs/types/GenetecAgent.js +31 -0
- package/cjs/types/PlaneTrackerAPI.js +286 -0
- package/cjs/types/VapixAPI.js +71 -13
- package/cjs/types/VapixEvents.js +2 -0
- package/cjs/web/DefaultClient.js +22 -10
- package/cjs/web/WsClient.js +3 -3
- package/esm/CamOverlayAPI.js +131 -88
- package/esm/CamScripterAPI.js +48 -38
- package/esm/CamStreamerAPI.js +81 -38
- package/esm/CamSwitcherAPI.js +137 -119
- package/esm/CamSwitcherEvents.js +5 -61
- package/esm/PlaneTrackerAPI.js +206 -0
- package/esm/VapixAPI.js +315 -225
- package/esm/{CreatePackage.js → bin/CreatePackage.js} +3 -3
- package/esm/errors/errors.js +66 -0
- package/esm/index.js +12 -3
- package/esm/internal/ProxyClient.js +28 -32
- package/esm/internal/WsEvents.js +68 -0
- package/esm/internal/utils.js +17 -1
- package/esm/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +2 -2
- 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} +2 -2
- package/esm/node/DefaultClient.js +10 -12
- package/esm/{internal → node}/Digest.js +1 -1
- package/esm/node/HttpRequestSender.js +14 -4
- package/esm/node/HttpServer.js +5 -5
- package/esm/{VapixEvents.js → node/VapixEvents.js} +1 -1
- package/esm/node/WsClient.js +3 -3
- 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 +22 -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 +21 -6
- package/esm/types/CamScripterAPICameraEventsGenerator.js +1 -0
- package/esm/types/CamStreamerAPI.js +33 -2
- package/esm/types/CamSwitcherAPI.js +38 -1
- package/esm/types/CamSwitcherEvents.js +8 -0
- package/esm/types/GenetecAgent.js +28 -0
- package/esm/types/PlaneTrackerAPI.js +283 -0
- package/esm/types/VapixAPI.js +70 -12
- package/esm/types/VapixEvents.js +1 -0
- package/esm/web/DefaultClient.js +22 -10
- package/esm/web/WsClient.js +3 -3
- package/package.json +30 -12
- package/types/CamOverlayAPI.d.ts +865 -0
- package/types/CamScripterAPI.d.ts +47 -0
- package/types/CamStreamerAPI.d.ts +64 -0
- package/types/CamSwitcherAPI.d.ts +167 -0
- package/types/CamSwitcherEvents.d.ts +8 -0
- package/types/PlaneTrackerAPI.d.ts +230 -0
- package/types/VapixAPI.d.ts +118 -0
- package/types/bin/CreatePackage.d.ts +1 -0
- package/types/errors/errors.d.ts +68 -0
- package/types/index.d.ts +20 -0
- package/types/internal/ProxyClient.d.ts +10 -0
- package/types/internal/WsEvents.d.ts +41 -0
- package/types/internal/types.d.ts +45 -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/{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/{cjs → types}/node/WsClient.d.ts +3 -2
- 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 +4321 -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 +93 -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 +115 -36
- package/{cjs → types}/types/CamSwitcherEvents.d.ts +77 -0
- package/{esm/events → types/types}/GenetecAgent.d.ts +47 -47
- package/types/types/PlaneTrackerAPI.d.ts +890 -0
- package/{cjs → types}/types/VapixAPI.d.ts +647 -465
- package/types/types/VapixEvents.d.ts +15 -0
- package/{esm → types}/types/common.d.ts +15 -5
- package/types/web/DefaultClient.d.ts +6 -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/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/types/common.d.ts +0 -37
- package/cjs/web/DefaultClient.d.ts +0 -6
- 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/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 → types}/web/WsClient.d.ts +0 -0
- /package/{cjs/node → types/web}/index.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import AdmZip from 'adm-zip';
|
|
2
|
+
import Path from 'path';
|
|
3
|
+
import fs from 'fs';
|
|
4
4
|
import { execSync } from 'child_process';
|
|
5
5
|
const productionModulesFolder = 'production_modules';
|
|
6
6
|
function isDirectory(path) {
|
package/esm/errors/errors.js
CHANGED
|
@@ -16,6 +16,24 @@ export class ParsingBlobError extends Error {
|
|
|
16
16
|
this.name = 'ParsingBlobError';
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
export class JsonParseError extends Error {
|
|
20
|
+
constructor(paramName, data) {
|
|
21
|
+
super(`Error: in JSON parsing of ${paramName}. Cannot parse: ${data}`);
|
|
22
|
+
this.name = 'JsonParseError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class ParameterNotFoundError extends Error {
|
|
26
|
+
constructor(paramName) {
|
|
27
|
+
super(`Error: no parameter '${paramName}' was found`);
|
|
28
|
+
this.name = 'ParameterNotFoundError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class SettingParameterError extends Error {
|
|
32
|
+
constructor(message) {
|
|
33
|
+
super(`Error setting parameter to camera: ${message}`);
|
|
34
|
+
this.name = 'SettingParameterError';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
19
37
|
export class ApplicationAPIError extends Error {
|
|
20
38
|
constructor(action, res) {
|
|
21
39
|
super(`[APP ${action}] Error: ` + res);
|
|
@@ -64,3 +82,51 @@ export class AddNewClipError extends Error {
|
|
|
64
82
|
this.name = 'AddNewClipError';
|
|
65
83
|
}
|
|
66
84
|
}
|
|
85
|
+
export class PtzNotSupportedError extends Error {
|
|
86
|
+
constructor() {
|
|
87
|
+
super('Ptz not supported.');
|
|
88
|
+
this.name = 'PtzNotSupportedError';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export class StorageDataFetchError extends Error {
|
|
92
|
+
constructor(err) {
|
|
93
|
+
super('Error fetching storage data: ' + err);
|
|
94
|
+
this.name = 'StorageDataFetchError';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export class WsAuthorizationError extends Error {
|
|
98
|
+
constructor(message) {
|
|
99
|
+
super('Server error on ws authorization: ' + message);
|
|
100
|
+
this.name = 'WsAuthorizationError';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export class UtcTimeFetchError extends Error {
|
|
104
|
+
constructor(message) {
|
|
105
|
+
super('Server error on get UTC time: ' + message);
|
|
106
|
+
this.name = 'UtcTimeFetchError';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export class TimezoneNotSetupError extends Error {
|
|
110
|
+
constructor() {
|
|
111
|
+
super('Time zone not setup on the device');
|
|
112
|
+
this.name = 'TimezoneNotSetupError';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export class TimezoneFetchError extends Error {
|
|
116
|
+
constructor(err) {
|
|
117
|
+
super('Error fetching time zone information: ' + err);
|
|
118
|
+
this.name = 'TimezoneFetchError';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export class ResetCalibrationError extends Error {
|
|
122
|
+
constructor(type, err) {
|
|
123
|
+
super('Error resetting ' + type.toLowerCase() + ' calibration: ' + err);
|
|
124
|
+
this.name = 'ResetCalibrationError';
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export class ImportSettingsError extends Error {
|
|
128
|
+
constructor(err) {
|
|
129
|
+
super('Error importing settings: ' + err);
|
|
130
|
+
this.name = 'ImportSettingsError';
|
|
131
|
+
}
|
|
132
|
+
}
|
package/esm/index.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
export * from './internal/
|
|
1
|
+
export * from './internal/types';
|
|
2
2
|
export * from './internal/constants';
|
|
3
3
|
export * from './internal/utils';
|
|
4
4
|
export * from './internal/versionCompare';
|
|
5
|
+
export * from './internal/ProxyClient';
|
|
5
6
|
export * from './types/common';
|
|
7
|
+
export { CamOverlayAPI } from './CamOverlayAPI';
|
|
8
|
+
export * from './types/CamOverlayAPI';
|
|
9
|
+
export { CamScripterAPI } from './CamScripterAPI';
|
|
10
|
+
export * from './types/CamScripterAPI';
|
|
11
|
+
export { CamStreamerAPI } from './CamStreamerAPI';
|
|
12
|
+
export * from './types/CamStreamerAPI';
|
|
6
13
|
export { CamSwitcherAPI } from './CamSwitcherAPI';
|
|
14
|
+
export * from './types/CamSwitcherAPI';
|
|
7
15
|
export { CamSwitcherEvents } from './CamSwitcherEvents';
|
|
8
|
-
export { VapixAPI } from './VapixAPI';
|
|
9
16
|
export * from './types/CamSwitcherEvents';
|
|
10
|
-
export
|
|
17
|
+
export { PlaneTrackerAPI } from './PlaneTrackerAPI';
|
|
18
|
+
export * from './types/PlaneTrackerAPI';
|
|
19
|
+
export { VapixAPI } from './VapixAPI';
|
|
11
20
|
export * from './types/VapixAPI';
|
|
@@ -1,40 +1,36 @@
|
|
|
1
1
|
import { addParametersToPath } from './utils';
|
|
2
2
|
export class ProxyClient {
|
|
3
3
|
client;
|
|
4
|
-
|
|
5
|
-
constructor(client,
|
|
4
|
+
proxyParams;
|
|
5
|
+
constructor(client, proxyParams) {
|
|
6
6
|
this.client = client;
|
|
7
|
-
this.
|
|
7
|
+
this.proxyParams = proxyParams;
|
|
8
8
|
}
|
|
9
|
-
get
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
realUrl: this.getProxyUrl(),
|
|
23
|
-
realHeaders: {
|
|
24
|
-
...(headers ?? {}),
|
|
25
|
-
'x-target-camera-protocol': proxy.port === 443 ? 'https' : 'http',
|
|
26
|
-
'x-target-camera-path': url,
|
|
27
|
-
'x-target-camera-ip': proxy.ip,
|
|
28
|
-
'x-target-camera-mdns': proxy.mdnsName,
|
|
29
|
-
'x-target-camera-port': String(proxy.port),
|
|
30
|
-
'x-target-camera-pass': encodeURIComponent(proxy.pass),
|
|
31
|
-
'x-target-camera-user': encodeURIComponent(proxy.user),
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
9
|
+
get(params) {
|
|
10
|
+
const { path, parameters, headers, timeout } = params;
|
|
11
|
+
const targetPath = addParametersToPath(path, parameters);
|
|
12
|
+
const { realPath, realHeaders } = this.getReal(targetPath, headers);
|
|
13
|
+
return this.client.get({ path: realPath, headers: realHeaders, timeout });
|
|
14
|
+
}
|
|
15
|
+
post(params) {
|
|
16
|
+
const { path, data, parameters, headers, timeout } = params;
|
|
17
|
+
const targetPath = addParametersToPath(path, parameters);
|
|
18
|
+
const { realPath, realHeaders } = this.getReal(targetPath, headers);
|
|
19
|
+
return this.client.post({ path: realPath, data, headers: realHeaders, timeout });
|
|
20
|
+
}
|
|
21
|
+
getReal(targetPath, headers) {
|
|
35
22
|
return {
|
|
36
|
-
|
|
37
|
-
realHeaders:
|
|
23
|
+
realPath: this.proxyParams.path,
|
|
24
|
+
realHeaders: {
|
|
25
|
+
...(headers ?? {}),
|
|
26
|
+
'x-target-camera-protocol': this.proxyParams.target.port === 443 ? 'https' : 'http',
|
|
27
|
+
'x-target-camera-path': targetPath,
|
|
28
|
+
'x-target-camera-ip': this.proxyParams.target.ip,
|
|
29
|
+
'x-target-camera-mdns': this.proxyParams.target.mdnsName,
|
|
30
|
+
'x-target-camera-port': String(this.proxyParams.target.port),
|
|
31
|
+
'x-target-camera-pass': this.proxyParams.target.pass,
|
|
32
|
+
'x-target-camera-user': this.proxyParams.target.user,
|
|
33
|
+
},
|
|
38
34
|
};
|
|
39
|
-
}
|
|
35
|
+
}
|
|
40
36
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export class WsEvents {
|
|
2
|
+
zodSchema;
|
|
3
|
+
ws;
|
|
4
|
+
_isDestroyed = false;
|
|
5
|
+
listeners = {};
|
|
6
|
+
constructor(zodSchema, ws) {
|
|
7
|
+
this.zodSchema = zodSchema;
|
|
8
|
+
this.ws = ws;
|
|
9
|
+
this.ws.onmessage = (e) => this.onMessage(e);
|
|
10
|
+
}
|
|
11
|
+
get isDestroyed() {
|
|
12
|
+
return this._isDestroyed;
|
|
13
|
+
}
|
|
14
|
+
resendInitData() {
|
|
15
|
+
const request = {
|
|
16
|
+
command: 'sendInitData',
|
|
17
|
+
};
|
|
18
|
+
this.ws.send(JSON.stringify(request));
|
|
19
|
+
}
|
|
20
|
+
addListener(type, listener, id) {
|
|
21
|
+
const typeList = this.listeners[type];
|
|
22
|
+
if (typeList === undefined) {
|
|
23
|
+
this.listeners[type] = { [id]: listener };
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
typeList[id] = listener;
|
|
27
|
+
}
|
|
28
|
+
removeListener(type, id) {
|
|
29
|
+
const typeList = this.listeners[type];
|
|
30
|
+
if (typeList) {
|
|
31
|
+
delete typeList[id];
|
|
32
|
+
if (Object.keys(typeList).length === 0) {
|
|
33
|
+
delete this.listeners[type];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
onMessage(evt) {
|
|
38
|
+
if (this.isDestroyed) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const eventData = JSON.parse(evt.data);
|
|
43
|
+
const data = this.zodSchema.parse(eventData);
|
|
44
|
+
if (isInitEvent(data)) {
|
|
45
|
+
this.processMessage(data.data, true);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.processMessage(data, false);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error('Error parsing event data:', evt.data, error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
processMessage(event, isInit) {
|
|
55
|
+
const listeners = this.listeners[event.type];
|
|
56
|
+
const list = Object.values(listeners ?? {});
|
|
57
|
+
list.forEach((listener) => listener(event, isInit));
|
|
58
|
+
}
|
|
59
|
+
destroy() {
|
|
60
|
+
this._isDestroyed = true;
|
|
61
|
+
this.ws.onmessage = () => { };
|
|
62
|
+
this.ws.destroy();
|
|
63
|
+
this.listeners = {};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const isInitEvent = (event) => {
|
|
67
|
+
return event.type === 'init';
|
|
68
|
+
};
|
package/esm/internal/utils.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isNullish } from './common';
|
|
2
1
|
export const addParametersToPath = (path, params) => {
|
|
3
2
|
if (params === undefined || Object.keys(params).length === 0) {
|
|
4
3
|
return path;
|
|
@@ -32,3 +31,20 @@ export const isClip = (id) => id?.charAt(0) === 's';
|
|
|
32
31
|
export const isTracker = (id) => id?.charAt(0) === 't';
|
|
33
32
|
export const isPlaylist = (id) => id?.charAt(0) === 'p';
|
|
34
33
|
export const isLoopPlayType = (playType) => playType.includes('LOOP');
|
|
34
|
+
export async function responseStringify(res) {
|
|
35
|
+
return JSON.stringify({
|
|
36
|
+
status: res.status,
|
|
37
|
+
body: await res.text(),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function pad(num, size) {
|
|
41
|
+
const sign = Math.sign(num) === -1 ? '-' : '';
|
|
42
|
+
return (sign +
|
|
43
|
+
new Array(size)
|
|
44
|
+
.concat([Math.abs(num)])
|
|
45
|
+
.join('0')
|
|
46
|
+
.slice(-size));
|
|
47
|
+
}
|
|
48
|
+
export function isNullish(value) {
|
|
49
|
+
return value === null || value === undefined;
|
|
50
|
+
}
|
|
@@ -54,6 +54,14 @@ export class Frame extends EventEmitter {
|
|
|
54
54
|
this.width = width;
|
|
55
55
|
this.height = height;
|
|
56
56
|
}
|
|
57
|
+
getFrameInfo() {
|
|
58
|
+
return {
|
|
59
|
+
x: this.posX,
|
|
60
|
+
y: this.posY,
|
|
61
|
+
width: this.width,
|
|
62
|
+
height: this.height,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
57
65
|
setText(text, align, textType = 'TFM_OVERFLOW', fontColor) {
|
|
58
66
|
this.text = text;
|
|
59
67
|
this.align = align;
|
|
@@ -73,6 +81,16 @@ export class Frame extends EventEmitter {
|
|
|
73
81
|
this.fontName = undefined;
|
|
74
82
|
this.font = fontData;
|
|
75
83
|
}
|
|
84
|
+
getTextInfo() {
|
|
85
|
+
return {
|
|
86
|
+
text: this.text,
|
|
87
|
+
textAlign: this.align,
|
|
88
|
+
textType: this.textType,
|
|
89
|
+
fontColor: this.fontColor,
|
|
90
|
+
font: this.font,
|
|
91
|
+
fontName: this.fontName,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
76
94
|
setBgColor(color) {
|
|
77
95
|
this.bgColor = color;
|
|
78
96
|
}
|
|
@@ -89,6 +107,14 @@ export class Frame extends EventEmitter {
|
|
|
89
107
|
setBgType(type) {
|
|
90
108
|
this.bgType = type;
|
|
91
109
|
}
|
|
110
|
+
getBgInfo() {
|
|
111
|
+
return {
|
|
112
|
+
bgColor: this.bgColor,
|
|
113
|
+
bgImage: this.bgImage,
|
|
114
|
+
bgImageName: this.bgImageName,
|
|
115
|
+
bgType: this.bgType,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
92
118
|
setBorderRadius(radius) {
|
|
93
119
|
this.borderRadius = radius;
|
|
94
120
|
}
|
|
@@ -98,6 +124,13 @@ export class Frame extends EventEmitter {
|
|
|
98
124
|
setBorderColor(color) {
|
|
99
125
|
this.borderColor = color;
|
|
100
126
|
}
|
|
127
|
+
getBorderInfo() {
|
|
128
|
+
return {
|
|
129
|
+
borderRadius: this.borderRadius,
|
|
130
|
+
borderWidth: this.borderWidth,
|
|
131
|
+
borderColor: this.borderColor,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
101
134
|
setCustomDraw(customDraw) {
|
|
102
135
|
this.customDraw = customDraw;
|
|
103
136
|
}
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { CamOverlayDrawingAPI } from '../CamOverlayDrawingAPI';
|
|
2
|
-
import ResourceManager from './ResourceManager';
|
|
2
|
+
import { ResourceManager } from './ResourceManager';
|
|
3
3
|
import { Frame } from './Frame';
|
|
4
|
-
|
|
5
|
-
top_left: [-1, -1],
|
|
6
|
-
center_left: [-1, 0],
|
|
7
|
-
bottom_left: [-1, 1],
|
|
8
|
-
top_center: [0, -1],
|
|
9
|
-
center: [0, 0],
|
|
10
|
-
bottom_center: [0, 1],
|
|
11
|
-
top_right: [1, -1],
|
|
12
|
-
center_right: [1, 0],
|
|
13
|
-
bottom_right: [1, 1],
|
|
14
|
-
};
|
|
4
|
+
import { COORD } from '../../types/CamOverlayPainter';
|
|
15
5
|
export class Painter extends Frame {
|
|
16
6
|
screenWidth;
|
|
17
7
|
screenHeight;
|
|
@@ -163,4 +153,3 @@ export class Painter extends Frame {
|
|
|
163
153
|
}
|
|
164
154
|
}
|
|
165
155
|
}
|
|
166
|
-
export { Frame, ResourceManager };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as fs from 'fs/promises';
|
|
2
|
-
export
|
|
2
|
+
export class ResourceManager {
|
|
3
3
|
co;
|
|
4
4
|
imgFileNames = {};
|
|
5
5
|
fontFileNames = {};
|
|
@@ -18,8 +18,9 @@ export default class ResourceManager {
|
|
|
18
18
|
if (this.images[moniker] !== undefined) {
|
|
19
19
|
return this.images[moniker];
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const path = this.imgFileNames[moniker];
|
|
22
|
+
if (path !== undefined) {
|
|
23
|
+
const imgData = await fs.readFile(path);
|
|
23
24
|
this.images[moniker] = await this.co.uploadImageData(imgData);
|
|
24
25
|
return this.images[moniker];
|
|
25
26
|
}
|
|
@@ -29,8 +30,9 @@ export default class ResourceManager {
|
|
|
29
30
|
if (this.fonts[moniker] !== undefined) {
|
|
30
31
|
return this.fonts[moniker];
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const path = this.fontFileNames[moniker];
|
|
34
|
+
if (path !== undefined) {
|
|
35
|
+
const fontData = await fs.readFile(path);
|
|
34
36
|
this.fonts[moniker] = await this.co.uploadFontData(fontData);
|
|
35
37
|
return this.fonts[moniker];
|
|
36
38
|
}
|
|
@@ -22,29 +22,27 @@ export class DefaultClient {
|
|
|
22
22
|
}
|
|
23
23
|
this.httpRequestSender = new HttpRequestSender(agentOptions);
|
|
24
24
|
}
|
|
25
|
-
get
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
async get(path, parameters = {}, headers) {
|
|
29
|
-
const options = this.getBaseConnectionParams('GET', path, parameters);
|
|
30
|
-
options.headers = headers;
|
|
25
|
+
get(params) {
|
|
26
|
+
const { path, parameters, headers, timeout } = params;
|
|
27
|
+
const options = this.getBaseConnectionParams('GET', path, parameters, headers, timeout);
|
|
31
28
|
return this.httpRequestSender.sendRequest(options);
|
|
32
29
|
}
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
options
|
|
30
|
+
post(params) {
|
|
31
|
+
const { path, data, parameters, headers, timeout } = params;
|
|
32
|
+
const options = this.getBaseConnectionParams('POST', path, parameters, headers, timeout);
|
|
36
33
|
return this.httpRequestSender.sendRequest(options, data);
|
|
37
34
|
}
|
|
38
|
-
getBaseConnectionParams(method, path, params) {
|
|
39
|
-
const pathName = addParametersToPath(path, params);
|
|
35
|
+
getBaseConnectionParams(method, path, params, headers, timeout) {
|
|
40
36
|
return {
|
|
41
37
|
method: method,
|
|
42
38
|
protocol: this.tls ? 'https:' : 'http:',
|
|
43
39
|
host: this.ip,
|
|
44
40
|
port: this.port,
|
|
45
|
-
path:
|
|
41
|
+
path: addParametersToPath(path, params),
|
|
46
42
|
user: this.user,
|
|
47
43
|
pass: this.pass,
|
|
44
|
+
headers,
|
|
45
|
+
timeout,
|
|
48
46
|
};
|
|
49
47
|
}
|
|
50
48
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Digest } from '
|
|
1
|
+
import { Digest } from './Digest';
|
|
2
2
|
import { Agent, fetch as undiciFetch, Request as UndiciRequest, } from 'undici';
|
|
3
3
|
export class HttpRequestSender {
|
|
4
4
|
agent;
|
|
@@ -8,8 +8,18 @@ export class HttpRequestSender {
|
|
|
8
8
|
connect: { rejectUnauthorized: agentOptions?.rejectUnaurhorized, keepAlive: agentOptions?.keepAlive },
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
sendRequest(options, postData) {
|
|
12
|
-
|
|
11
|
+
async sendRequest(options, postData) {
|
|
12
|
+
const stackHolder = { stack: '' };
|
|
13
|
+
Error.captureStackTrace(stackHolder, this.sendRequest);
|
|
14
|
+
try {
|
|
15
|
+
return await this.sendRequestWithAuth(options, postData);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
if (err instanceof Error) {
|
|
19
|
+
err.stack = `${err.stack}\nCaptured at:\n${stackHolder.stack}`;
|
|
20
|
+
}
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
13
23
|
}
|
|
14
24
|
async sendRequestWithAuth(options, postData, wwwAuthenticateHeader) {
|
|
15
25
|
options.timeout ??= 10000;
|
|
@@ -79,7 +89,7 @@ export class HttpRequestSender {
|
|
|
79
89
|
return authData.digest.getAuthHeader(options.user, options.pass, options.method ?? 'GET', options.path, authData.wwwAuthenticateHeader);
|
|
80
90
|
}
|
|
81
91
|
else {
|
|
82
|
-
return `Basic ${
|
|
92
|
+
return `Basic ${Buffer.from(`${options.user}:${options.pass}`).toString('base64')}`;
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
}
|
package/esm/node/HttpServer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
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';
|
|
6
6
|
export class HttpServer extends EventEmitter {
|
|
7
7
|
host;
|
|
8
8
|
port;
|
package/esm/node/WsClient.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { Digest } from '
|
|
1
|
+
import EventEmitter from 'events';
|
|
2
|
+
import WebSocket from 'ws';
|
|
3
|
+
import { Digest } from './Digest';
|
|
4
4
|
export class WsClient extends EventEmitter {
|
|
5
5
|
user;
|
|
6
6
|
pass;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { pad } from '../../internal/utils';
|
|
2
|
+
import { ProxyClient } from '../../internal/ProxyClient';
|
|
3
|
+
import { DefaultClient } from '../DefaultClient';
|
|
3
4
|
export class AxisCameraStationEvents {
|
|
4
5
|
sourceKey;
|
|
5
6
|
client;
|
|
6
|
-
constructor(
|
|
7
|
+
constructor(clientOptions, sourceKey) {
|
|
7
8
|
this.sourceKey = sourceKey;
|
|
8
|
-
|
|
9
|
-
this.client = opt;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
this.client = new DefaultClient(opt);
|
|
13
|
-
}
|
|
9
|
+
this.client = new DefaultClient(clientOptions);
|
|
14
10
|
}
|
|
15
|
-
|
|
11
|
+
getClient(proxyParams) {
|
|
12
|
+
return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
|
|
13
|
+
}
|
|
14
|
+
async sendEvent(data, eventType, options) {
|
|
16
15
|
const dateString = this.getDate();
|
|
17
16
|
const event = {
|
|
18
17
|
addExternalDataRequest: {
|
|
@@ -23,9 +22,15 @@ export class AxisCameraStationEvents {
|
|
|
23
22
|
},
|
|
24
23
|
};
|
|
25
24
|
const eventData = JSON.stringify(event);
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
'
|
|
25
|
+
const agent = this.getClient(options?.proxyParams);
|
|
26
|
+
const res = await agent.post({
|
|
27
|
+
path: '/Acs/Api/ExternalDataFacade/AddExternalData',
|
|
28
|
+
data: eventData,
|
|
29
|
+
headers: {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
'Content-Length': eventData.length.toString(),
|
|
32
|
+
},
|
|
33
|
+
timeout: options?.timeout,
|
|
29
34
|
});
|
|
30
35
|
if (!res.ok) {
|
|
31
36
|
throw new Error(`ACS status code: ${res.status}`);
|