camstreamerlib 4.0.0-beta.29 → 4.0.0-beta.30
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 +6 -2
- package/cjs/CamOverlayAPI.d.ts +38 -615
- package/cjs/CamOverlayAPI.js +128 -104
- package/cjs/CamOverlayDrawingAPI.d.ts +2 -47
- package/cjs/CamOverlayPainter/Frame.d.ts +8 -37
- package/cjs/CamOverlayPainter/Frame.js +33 -0
- package/cjs/CamOverlayPainter/Painter.d.ts +5 -10
- package/cjs/CamOverlayPainter/Painter.js +2 -4
- package/cjs/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/cjs/CamOverlayPainter/ResourceManager.js +2 -1
- package/cjs/CamScripterAPI.d.ts +12 -12
- package/cjs/CamScripterAPI.js +33 -27
- package/cjs/CamStreamerAPI.d.ts +11 -9
- package/cjs/CamStreamerAPI.js +28 -22
- package/cjs/CamSwitcherAPI.d.ts +35 -34
- package/cjs/CamSwitcherAPI.js +94 -82
- package/cjs/PlaneTrackerAPI.d.ts +30 -36
- package/cjs/PlaneTrackerAPI.js +132 -71
- package/cjs/VapixAPI.d.ts +43 -40
- package/cjs/VapixAPI.js +205 -183
- package/cjs/events/AxisCameraStationEvents.d.ts +5 -5
- package/cjs/events/AxisCameraStationEvents.js +17 -12
- package/cjs/events/GenetecAgent.d.ts +2 -0
- package/cjs/events/GenetecAgent.js +15 -4
- package/cjs/index.d.ts +7 -1
- package/cjs/index.js +12 -2
- package/cjs/internal/ProxyClient.d.ts +7 -8
- package/cjs/internal/ProxyClient.js +25 -31
- package/cjs/internal/types.d.ts +16 -9
- package/cjs/internal/utils.d.ts +1 -2
- package/cjs/internal/utils.js +1 -5
- package/cjs/node/DefaultClient.d.ts +3 -5
- package/cjs/node/DefaultClient.js +10 -14
- package/cjs/node/HttpRequestSender.d.ts +1 -0
- package/cjs/node/HttpRequestSender.js +13 -3
- package/cjs/node/WsClient.d.ts +1 -0
- package/cjs/node/index.d.ts +2 -0
- package/cjs/node/index.js +18 -1
- package/cjs/{models/CamOverlayAPI/widgetsSchema.d.ts → types/CamOverlayAPI/CamOverlayAPI.d.ts} +625 -375
- package/cjs/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/CamOverlayAPI.js} +65 -14
- package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.d.ts +40 -10
- package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.js +11 -9
- package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.d.ts +89 -5
- package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.js +9 -7
- package/{esm/models → cjs/types}/CamOverlayAPI/imagesSchema.d.ts +40 -13
- package/cjs/types/CamOverlayAPI/imagesSchema.js +12 -0
- package/cjs/{models → types}/CamOverlayAPI/index.d.ts +0 -4
- package/cjs/{models → types}/CamOverlayAPI/index.js +0 -4
- package/{esm/models → cjs/types}/CamOverlayAPI/infotickerSchema.d.ts +43 -9
- package/cjs/{models → types}/CamOverlayAPI/infotickerSchema.js +10 -8
- package/{esm/models → cjs/types}/CamOverlayAPI/pipSchema.d.ts +48 -7
- package/cjs/{models → types}/CamOverlayAPI/pipSchema.js +8 -6
- package/{esm/models → cjs/types}/CamOverlayAPI/ptzCompassSchema.d.ts +40 -7
- package/cjs/{models → types}/CamOverlayAPI/ptzCompassSchema.js +8 -6
- package/cjs/{models → types}/CamOverlayAPI/ptzSchema.d.ts +42 -14
- package/cjs/types/CamOverlayAPI/ptzSchema.js +15 -0
- package/{esm/models → cjs/types}/CamOverlayAPI/screenSharingSchema.d.ts +26 -5
- package/cjs/types/CamOverlayAPI/screenSharingSchema.js +11 -0
- package/cjs/{models → types}/CamOverlayAPI/webCameraSharingSchema.d.ts +26 -5
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +11 -0
- package/cjs/types/CamOverlayDrawingAPI.d.ts +58 -0
- package/cjs/types/CamOverlayDrawingAPI.js +2 -0
- package/cjs/types/CamOverlayPainter.d.ts +74 -0
- package/cjs/types/CamOverlayPainter.js +2 -0
- package/cjs/types/CamStreamerAPI.d.ts +4 -4
- package/cjs/types/PlaneTrackerAPI.d.ts +6 -0
- package/cjs/types/common.d.ts +12 -3
- package/cjs/web/DefaultClient.d.ts +4 -4
- package/cjs/web/DefaultClient.js +21 -11
- package/esm/CamOverlayAPI.d.ts +38 -615
- package/esm/CamOverlayAPI.js +127 -103
- package/esm/CamOverlayDrawingAPI.d.ts +2 -47
- package/esm/CamOverlayPainter/Frame.d.ts +8 -37
- package/esm/CamOverlayPainter/Frame.js +33 -0
- package/esm/CamOverlayPainter/Painter.d.ts +5 -10
- package/esm/CamOverlayPainter/Painter.js +1 -2
- package/esm/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/esm/CamOverlayPainter/ResourceManager.js +1 -1
- package/esm/CamScripterAPI.d.ts +12 -12
- package/esm/CamScripterAPI.js +32 -26
- package/esm/CamStreamerAPI.d.ts +11 -9
- package/esm/CamStreamerAPI.js +28 -22
- package/esm/CamSwitcherAPI.d.ts +35 -34
- package/esm/CamSwitcherAPI.js +95 -83
- package/esm/PlaneTrackerAPI.d.ts +30 -36
- package/esm/PlaneTrackerAPI.js +131 -70
- package/esm/VapixAPI.d.ts +43 -40
- package/esm/VapixAPI.js +204 -182
- package/esm/events/AxisCameraStationEvents.d.ts +5 -5
- package/esm/events/AxisCameraStationEvents.js +18 -13
- package/esm/events/GenetecAgent.d.ts +2 -0
- package/esm/events/GenetecAgent.js +15 -4
- package/esm/index.d.ts +7 -1
- package/esm/index.js +7 -1
- package/esm/internal/ProxyClient.d.ts +7 -8
- package/esm/internal/ProxyClient.js +25 -31
- package/esm/internal/types.d.ts +16 -9
- package/esm/internal/utils.d.ts +1 -2
- package/esm/internal/utils.js +0 -3
- package/esm/node/DefaultClient.d.ts +3 -5
- package/esm/node/DefaultClient.js +10 -14
- package/esm/node/HttpRequestSender.d.ts +1 -0
- package/esm/node/HttpRequestSender.js +13 -3
- package/esm/node/WsClient.d.ts +1 -0
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/{models/CamOverlayAPI/widgetsSchema.d.ts → types/CamOverlayAPI/CamOverlayAPI.d.ts} +625 -375
- package/esm/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/CamOverlayAPI.js} +64 -13
- package/esm/{models → types}/CamOverlayAPI/accuweatherSchema.d.ts +40 -10
- package/esm/{models → types}/CamOverlayAPI/accuweatherSchema.js +3 -2
- package/esm/{models → types}/CamOverlayAPI/customGraphicsSchema.d.ts +89 -5
- package/esm/{models → types}/CamOverlayAPI/customGraphicsSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/imagesSchema.d.ts +40 -13
- package/esm/types/CamOverlayAPI/imagesSchema.js +8 -0
- package/esm/{models → types}/CamOverlayAPI/index.d.ts +0 -4
- package/esm/{models → types}/CamOverlayAPI/index.js +0 -4
- package/{cjs/models → esm/types}/CamOverlayAPI/infotickerSchema.d.ts +43 -9
- package/esm/{models → types}/CamOverlayAPI/infotickerSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/pipSchema.d.ts +48 -7
- package/esm/{models → types}/CamOverlayAPI/pipSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/ptzCompassSchema.d.ts +40 -7
- package/esm/{models → types}/CamOverlayAPI/ptzCompassSchema.js +3 -2
- package/esm/{models → types}/CamOverlayAPI/ptzSchema.d.ts +42 -14
- package/esm/{models → types}/CamOverlayAPI/ptzSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/screenSharingSchema.d.ts +26 -5
- package/esm/types/CamOverlayAPI/screenSharingSchema.js +7 -0
- package/esm/{models → types}/CamOverlayAPI/webCameraSharingSchema.d.ts +26 -5
- package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +7 -0
- package/esm/types/CamOverlayDrawingAPI.d.ts +58 -0
- package/esm/types/CamOverlayDrawingAPI.js +1 -0
- package/esm/types/CamOverlayPainter.d.ts +74 -0
- package/esm/types/CamOverlayPainter.js +1 -0
- package/esm/types/CamStreamerAPI.d.ts +4 -4
- package/esm/types/PlaneTrackerAPI.d.ts +6 -0
- package/esm/types/common.d.ts +12 -3
- package/esm/web/DefaultClient.d.ts +4 -4
- package/esm/web/DefaultClient.js +21 -11
- package/package.json +2 -2
- package/cjs/models/CamOverlayAPI/constants.d.ts +0 -11
- package/cjs/models/CamOverlayAPI/constants.js +0 -14
- package/cjs/models/CamOverlayAPI/fileSchema.d.ts +0 -28
- package/cjs/models/CamOverlayAPI/fileSchema.js +0 -17
- package/cjs/models/CamOverlayAPI/imagesSchema.js +0 -10
- package/cjs/models/CamOverlayAPI/ptzSchema.js +0 -13
- package/cjs/models/CamOverlayAPI/screenSharingSchema.js +0 -9
- package/cjs/models/CamOverlayAPI/webCameraSharingSchema.js +0 -9
- package/cjs/models/CamOverlayAPI/widgetCommonSchema.d.ts +0 -126
- package/cjs/models/CamOverlayAPI/widgetsSchema.js +0 -27
- package/cjs/types/CamOverlayAPI.d.ts +0 -328
- package/cjs/types/CamOverlayAPI.js +0 -26
- package/esm/models/CamOverlayAPI/constants.d.ts +0 -11
- package/esm/models/CamOverlayAPI/constants.js +0 -11
- package/esm/models/CamOverlayAPI/fileSchema.d.ts +0 -28
- package/esm/models/CamOverlayAPI/fileSchema.js +0 -14
- package/esm/models/CamOverlayAPI/imagesSchema.js +0 -7
- package/esm/models/CamOverlayAPI/screenSharingSchema.js +0 -6
- package/esm/models/CamOverlayAPI/webCameraSharingSchema.js +0 -6
- package/esm/models/CamOverlayAPI/widgetCommonSchema.d.ts +0 -126
- package/esm/models/CamOverlayAPI/widgetsSchema.js +0 -24
- package/esm/types/CamOverlayAPI.d.ts +0 -328
- package/esm/types/CamOverlayAPI.js +0 -14
package/esm/CamOverlayAPI.js
CHANGED
|
@@ -1,94 +1,100 @@
|
|
|
1
1
|
import { paramToUrl, responseStringify } from './internal/utils';
|
|
2
|
-
import { ImageType, } from './types/CamOverlayAPI';
|
|
3
2
|
import { ParsingBlobError, ServiceNotFoundError } from './errors/errors';
|
|
4
3
|
import { networkCameraListSchema } from './types/common';
|
|
5
4
|
import { z } from 'zod';
|
|
6
|
-
import {
|
|
7
|
-
import { fileListSchema,
|
|
8
|
-
export const
|
|
5
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
6
|
+
import { fileListSchema, ImageType, storageDataListSchema, widgetsSchema, WSResponseSchema, } from './types/CamOverlayAPI/CamOverlayAPI';
|
|
7
|
+
export const allowedWidgetNames = {
|
|
8
|
+
accuweather: 'accuweather',
|
|
9
|
+
infoticker: 'infoticker',
|
|
10
|
+
customGraphics: 'customGraphics',
|
|
11
|
+
ptzCompass: 'ptzCompass',
|
|
12
|
+
images: 'images',
|
|
13
|
+
ptz: 'ptz',
|
|
14
|
+
pip: 'pip',
|
|
15
|
+
screenSharing: 'screenSharing',
|
|
16
|
+
web_camera: 'web_camera',
|
|
17
|
+
};
|
|
18
|
+
const BASE_PATH = '/local/camoverlay/api';
|
|
9
19
|
export class CamOverlayAPI {
|
|
10
20
|
client;
|
|
11
21
|
constructor(client) {
|
|
12
22
|
this.client = client;
|
|
13
23
|
}
|
|
14
|
-
static
|
|
15
|
-
static
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
static getBasePath = () => BASE_PATH;
|
|
25
|
+
static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
26
|
+
static getFilePreviewPath = (path) => `${BASE_PATH}/image.cgi?path=${encodeURIComponent(path)}`;
|
|
27
|
+
async checkCameraTime(options) {
|
|
28
|
+
const response = await this._get({ path: `${BASE_PATH}/camera_time.cgi` }, options);
|
|
18
29
|
return z.boolean().parse(response.state);
|
|
19
30
|
}
|
|
20
|
-
async getNetworkCameraList() {
|
|
21
|
-
const response = await this._get(`${
|
|
31
|
+
async getNetworkCameraList(options) {
|
|
32
|
+
const response = await this._get({ path: `${BASE_PATH}/network_camera_list.cgi` }, options);
|
|
22
33
|
return networkCameraListSchema.parse(response.camera_list);
|
|
23
34
|
}
|
|
24
|
-
async wsAuthorization() {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
async
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
const files = await this._get(`${BASE_URL}/upload_${fileType}.cgi`, {
|
|
42
|
-
action: 'list',
|
|
43
|
-
});
|
|
35
|
+
async wsAuthorization(options) {
|
|
36
|
+
const response = await this._get({ path: `${BASE_PATH}/ws_authorization.cgi` }, options);
|
|
37
|
+
return WSResponseSchema.parse(response).data;
|
|
38
|
+
}
|
|
39
|
+
async getMjpegStreamImage(mjpegUrl, options) {
|
|
40
|
+
return await this._getBlob({
|
|
41
|
+
path: `${BASE_PATH}/fetch_mjpeg_image.cgi?mjpeg_url=${encodeURIComponent(decodeURIComponent(mjpegUrl))}`,
|
|
42
|
+
}, options);
|
|
43
|
+
}
|
|
44
|
+
async listFiles(fileType, options) {
|
|
45
|
+
const files = await this._get({
|
|
46
|
+
path: `${BASE_PATH}/upload_${fileType}.cgi`,
|
|
47
|
+
parameters: {
|
|
48
|
+
action: 'list',
|
|
49
|
+
},
|
|
50
|
+
}, options);
|
|
44
51
|
return fileListSchema.parse(files.list);
|
|
45
52
|
}
|
|
46
|
-
async uploadFile(fileType, formData, storage) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
async uploadFile(fileType, formData, storage, options) {
|
|
54
|
+
await this._post({
|
|
55
|
+
path: `${BASE_PATH}/upload_${fileType}.cgi`,
|
|
56
|
+
data: formData,
|
|
57
|
+
parameters: {
|
|
58
|
+
action: 'upload',
|
|
59
|
+
storage: storage,
|
|
60
|
+
},
|
|
61
|
+
}, options);
|
|
62
|
+
}
|
|
63
|
+
async removeFile(fileType, fileParams, options) {
|
|
64
|
+
const path = `${BASE_PATH}/upload_${fileType}.cgi`;
|
|
55
65
|
await this._postUrlEncoded(path, {
|
|
56
66
|
action: 'remove',
|
|
57
67
|
...fileParams,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
async getFileStorage(fileType) {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
list: storageDataListSchema,
|
|
68
|
-
});
|
|
69
|
-
const data = await this._get(`${BASE_URL}/upload_${fileType}.cgi`, {
|
|
70
|
-
action: 'get_storage',
|
|
71
|
-
});
|
|
68
|
+
}, undefined, options);
|
|
69
|
+
}
|
|
70
|
+
async getFileStorage(fileType, options) {
|
|
71
|
+
const data = await this._get({
|
|
72
|
+
path: `${BASE_PATH}/upload_${fileType}.cgi`,
|
|
73
|
+
parameters: {
|
|
74
|
+
action: 'get_storage',
|
|
75
|
+
},
|
|
76
|
+
}, options);
|
|
72
77
|
if (data.code !== 200) {
|
|
73
78
|
throw new Error('Error occured while fetching file storage data');
|
|
74
79
|
}
|
|
75
80
|
return storageDataListSchema.parse(data.list);
|
|
76
81
|
}
|
|
77
|
-
async getFilePreviewFromCamera(path) {
|
|
78
|
-
return await this._getBlob(CamOverlayAPI.getFilePreviewPath(path));
|
|
82
|
+
async getFilePreviewFromCamera(path, options) {
|
|
83
|
+
return await this._getBlob({ path: CamOverlayAPI.getFilePreviewPath(path) }, options);
|
|
79
84
|
}
|
|
80
|
-
async updateInfoticker(
|
|
81
|
-
await this._get(`${
|
|
85
|
+
async updateInfoticker(serviceId, text, options) {
|
|
86
|
+
await this._get({ path: `${BASE_PATH}/infoticker.cgi?service_id=${serviceId}&text=${text}` }, options);
|
|
82
87
|
}
|
|
83
|
-
async setEnabled(
|
|
84
|
-
await this._post(`${
|
|
88
|
+
async setEnabled(serviceId, enabled, options) {
|
|
89
|
+
await this._post({ path: `${BASE_PATH}/enabled.cgi?id_${serviceId}=${enabled ? 1 : 0}`, data: '' }, options);
|
|
85
90
|
}
|
|
86
|
-
async isEnabled(
|
|
87
|
-
const
|
|
91
|
+
async isEnabled(serviceId, options) {
|
|
92
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
93
|
+
const res = await agent.get({ path: `${BASE_PATH}/services.cgi?action=get`, timeout: options?.timeout });
|
|
88
94
|
if (res.ok) {
|
|
89
95
|
const data = JSON.parse(await res.text());
|
|
90
96
|
for (const service of data.services) {
|
|
91
|
-
if (service.id ===
|
|
97
|
+
if (service.id === serviceId) {
|
|
92
98
|
return service.enabled === 1;
|
|
93
99
|
}
|
|
94
100
|
}
|
|
@@ -98,17 +104,23 @@ export class CamOverlayAPI {
|
|
|
98
104
|
throw new Error(await responseStringify(res));
|
|
99
105
|
}
|
|
100
106
|
}
|
|
101
|
-
async getSingleWidget(serviceId) {
|
|
102
|
-
const data = await this._get(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
async getSingleWidget(serviceId, options) {
|
|
108
|
+
const data = await this._get({
|
|
109
|
+
path: `${BASE_PATH}/services.cgi`,
|
|
110
|
+
parameters: {
|
|
111
|
+
action: 'get',
|
|
112
|
+
service_id: serviceId.toString(),
|
|
113
|
+
},
|
|
114
|
+
}, options);
|
|
106
115
|
return widgetsSchema.parse(data);
|
|
107
116
|
}
|
|
108
|
-
async getWidgets() {
|
|
109
|
-
const widgetList = await this._get(
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
async getWidgets(options) {
|
|
118
|
+
const widgetList = await this._get({
|
|
119
|
+
path: `${BASE_PATH}/services.cgi`,
|
|
120
|
+
parameters: {
|
|
121
|
+
action: 'get',
|
|
122
|
+
},
|
|
123
|
+
}, options);
|
|
112
124
|
const widgets = widgetList.services;
|
|
113
125
|
widgets.forEach((widget) => {
|
|
114
126
|
const parsedWidget = widgetsSchema.safeParse(widget);
|
|
@@ -118,20 +130,20 @@ export class CamOverlayAPI {
|
|
|
118
130
|
});
|
|
119
131
|
return widgets;
|
|
120
132
|
}
|
|
121
|
-
async updateSingleWidget(widget) {
|
|
122
|
-
const path = `${
|
|
133
|
+
async updateSingleWidget(widget, options) {
|
|
134
|
+
const path = `${BASE_PATH}/services.cgi`;
|
|
123
135
|
await this._postJsonEncoded(path, JSON.stringify(widget), {
|
|
124
136
|
action: 'set',
|
|
125
137
|
service_id: widget.id.toString(),
|
|
126
|
-
});
|
|
138
|
+
}, undefined, options);
|
|
127
139
|
}
|
|
128
|
-
async updateWidgets(widgets) {
|
|
129
|
-
const path = `${
|
|
140
|
+
async updateWidgets(widgets, options) {
|
|
141
|
+
const path = `${BASE_PATH}/services.cgi`;
|
|
130
142
|
await this._postJsonEncoded(path, JSON.stringify({ services: widgets }), {
|
|
131
143
|
action: 'set',
|
|
132
|
-
});
|
|
144
|
+
}, undefined, options);
|
|
133
145
|
}
|
|
134
|
-
updateCGText(
|
|
146
|
+
updateCGText(serviceId, fields, options) {
|
|
135
147
|
const params = {};
|
|
136
148
|
for (const field of fields) {
|
|
137
149
|
const name = field.field_name;
|
|
@@ -140,51 +152,59 @@ export class CamOverlayAPI {
|
|
|
140
152
|
params[`${name}_color`] = field.color;
|
|
141
153
|
}
|
|
142
154
|
}
|
|
143
|
-
return this.promiseCGUpdate(
|
|
155
|
+
return this.promiseCGUpdate(serviceId, 'update_text', params, undefined, undefined, options);
|
|
144
156
|
}
|
|
145
|
-
updateCGImagePos(
|
|
157
|
+
updateCGImagePos(serviceId, coordinates = '', x = 0, y = 0, options) {
|
|
146
158
|
const params = {
|
|
147
159
|
coord_system: coordinates,
|
|
148
160
|
pos_x: x,
|
|
149
161
|
pos_y: y,
|
|
150
162
|
};
|
|
151
|
-
return this.promiseCGUpdate(
|
|
163
|
+
return this.promiseCGUpdate(serviceId, 'update_image', params, undefined, undefined, options);
|
|
152
164
|
}
|
|
153
|
-
updateCGImage(
|
|
165
|
+
updateCGImage(serviceId, path, coordinates = '', x = 0, y = 0, options) {
|
|
154
166
|
const params = {
|
|
155
167
|
coord_system: coordinates,
|
|
156
168
|
pos_x: x,
|
|
157
169
|
pos_y: y,
|
|
158
170
|
image: path,
|
|
159
171
|
};
|
|
160
|
-
return this.promiseCGUpdate(
|
|
172
|
+
return this.promiseCGUpdate(serviceId, 'update_image', params, undefined, undefined, options);
|
|
161
173
|
}
|
|
162
|
-
updateCGImageFromData(
|
|
174
|
+
updateCGImageFromData(serviceId, imageType, imageData, coordinates = '', x = 0, y = 0, options) {
|
|
163
175
|
const contentType = imageType === ImageType.PNG ? 'image/png' : 'image/jpeg';
|
|
164
176
|
const params = {
|
|
165
177
|
coord_system: coordinates,
|
|
166
178
|
pos_x: x,
|
|
167
179
|
pos_y: y,
|
|
168
180
|
};
|
|
169
|
-
return this.promiseCGUpdate(
|
|
181
|
+
return this.promiseCGUpdate(serviceId, 'update_image', params, contentType, imageData, options);
|
|
170
182
|
}
|
|
171
|
-
async promiseCGUpdate(
|
|
172
|
-
const path = `${
|
|
183
|
+
async promiseCGUpdate(serviceId, action, params = {}, contentType, data, options) {
|
|
184
|
+
const path = `${BASE_PATH}/customGraphics.cgi`;
|
|
173
185
|
let headers = {};
|
|
174
186
|
if (contentType !== undefined && data) {
|
|
175
187
|
headers = { 'Content-Type': contentType };
|
|
176
188
|
}
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
189
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
190
|
+
const res = await agent.post({
|
|
191
|
+
path,
|
|
192
|
+
data: data ?? '',
|
|
193
|
+
parameters: {
|
|
194
|
+
action: action,
|
|
195
|
+
service_id: serviceId.toString(),
|
|
196
|
+
...params,
|
|
197
|
+
},
|
|
198
|
+
headers,
|
|
199
|
+
timeout: options?.timeout,
|
|
200
|
+
});
|
|
182
201
|
if (!res.ok) {
|
|
183
202
|
throw new Error(await responseStringify(res));
|
|
184
203
|
}
|
|
185
204
|
}
|
|
186
|
-
async _get(
|
|
187
|
-
const
|
|
205
|
+
async _get(params, options) {
|
|
206
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
207
|
+
const res = await agent.get({ ...params, timeout: options?.timeout });
|
|
188
208
|
if (res.ok) {
|
|
189
209
|
return (await res.json());
|
|
190
210
|
}
|
|
@@ -192,8 +212,9 @@ export class CamOverlayAPI {
|
|
|
192
212
|
throw new Error(await responseStringify(res));
|
|
193
213
|
}
|
|
194
214
|
}
|
|
195
|
-
async _post(
|
|
196
|
-
const
|
|
215
|
+
async _post(params, options) {
|
|
216
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
217
|
+
const res = await agent.post({ ...params, timeout: options?.timeout });
|
|
197
218
|
if (res.ok) {
|
|
198
219
|
return (await res.json());
|
|
199
220
|
}
|
|
@@ -201,8 +222,9 @@ export class CamOverlayAPI {
|
|
|
201
222
|
throw new Error(await responseStringify(res));
|
|
202
223
|
}
|
|
203
224
|
}
|
|
204
|
-
async _getBlob(
|
|
205
|
-
const
|
|
225
|
+
async _getBlob(params, options) {
|
|
226
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
227
|
+
const res = await agent.get({ ...params, timeout: options?.timeout });
|
|
206
228
|
if (res.ok) {
|
|
207
229
|
return await this.parseBlobResponse(res);
|
|
208
230
|
}
|
|
@@ -218,14 +240,16 @@ export class CamOverlayAPI {
|
|
|
218
240
|
throw new ParsingBlobError(err);
|
|
219
241
|
}
|
|
220
242
|
}
|
|
221
|
-
async _postUrlEncoded(path, params, headers) {
|
|
243
|
+
async _postUrlEncoded(path, params, headers, options) {
|
|
222
244
|
const data = paramToUrl(params);
|
|
223
245
|
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
224
|
-
return this._post(path, data,
|
|
246
|
+
return this._post({ path, data, headers: { ...baseHeaders, ...headers } }, options);
|
|
225
247
|
}
|
|
226
|
-
async _postJsonEncoded(
|
|
227
|
-
const [path, data, params, headers] = args;
|
|
248
|
+
async _postJsonEncoded(path, data, parameters, headers, options) {
|
|
228
249
|
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
229
|
-
return this._post(path, data,
|
|
250
|
+
return this._post({ path, data, parameters, headers: { ...baseHeaders, ...headers } }, options);
|
|
251
|
+
}
|
|
252
|
+
getAgent(proxyParams) {
|
|
253
|
+
return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
|
|
230
254
|
}
|
|
231
255
|
}
|
|
@@ -1,53 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
3
4
|
import * as EventEmitter from 'events';
|
|
4
|
-
import {
|
|
5
|
-
export type CamOverlayDrawingOptions = WsOptions & {
|
|
6
|
-
camera?: number | number[];
|
|
7
|
-
zIndex?: number;
|
|
8
|
-
};
|
|
9
|
-
export type TCairoResponse = {
|
|
10
|
-
message: string;
|
|
11
|
-
call_id: number;
|
|
12
|
-
};
|
|
13
|
-
export type TCairoCreateResponse = {
|
|
14
|
-
var: string;
|
|
15
|
-
call_id: number;
|
|
16
|
-
};
|
|
17
|
-
export type TUploadImageResponse = {
|
|
18
|
-
var: string;
|
|
19
|
-
width: number;
|
|
20
|
-
height: number;
|
|
21
|
-
call_id: number;
|
|
22
|
-
};
|
|
23
|
-
export type TErrorResponse = {
|
|
24
|
-
error: string;
|
|
25
|
-
call_id?: number;
|
|
26
|
-
};
|
|
27
|
-
export type TService = {
|
|
28
|
-
id: number;
|
|
29
|
-
enabled: number;
|
|
30
|
-
schedule: string;
|
|
31
|
-
name: string;
|
|
32
|
-
identifier: string;
|
|
33
|
-
cameraList: number[];
|
|
34
|
-
};
|
|
35
|
-
export type TServiceList = {
|
|
36
|
-
services: TService[];
|
|
37
|
-
};
|
|
38
|
-
export type TAlign = 'A_RIGHT' | 'A_LEFT' | 'A_CENTER';
|
|
39
|
-
export type TextFit = 'TFM_SCALE' | 'TFM_TRUNCATE' | 'TFM_OVERFLOW';
|
|
40
|
-
export type TWriteTextParams = [string, string, number, number, number, number, TAlign, TextFit?];
|
|
41
|
-
export interface CamOverlayDrawingAPI {
|
|
42
|
-
on(event: 'open', listener: () => void): this;
|
|
43
|
-
on(event: 'close', listener: () => void): this;
|
|
44
|
-
on(event: 'error', listener: (err: Error) => void): this;
|
|
45
|
-
on(event: 'message', listener: (msg: string) => void): this;
|
|
46
|
-
emit(event: 'open'): boolean;
|
|
47
|
-
emit(event: 'close'): boolean;
|
|
48
|
-
emit(event: 'error', err: Error): boolean;
|
|
49
|
-
emit(event: 'message', msg: string): boolean;
|
|
50
|
-
}
|
|
5
|
+
import { CamOverlayDrawingOptions, TCairoCreateResponse, TCairoResponse, TUploadImageResponse, TWriteTextParams } from './types/CamOverlayDrawingAPI';
|
|
51
6
|
export declare class CamOverlayDrawingAPI extends EventEmitter {
|
|
52
7
|
private tls;
|
|
53
8
|
private tlsInsecure;
|
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { CamOverlayDrawingAPI
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type TTmf = 'TFM_OVERFLOW' | 'TFM_SCALE' | 'TFM_TRUNCATE';
|
|
8
|
-
export type TObjectFitType = 'fill' | 'fit' | 'none';
|
|
9
|
-
export type TFrameOptions = {
|
|
10
|
-
enabled?: boolean;
|
|
11
|
-
x: number;
|
|
12
|
-
y: number;
|
|
13
|
-
width: number;
|
|
14
|
-
height: number;
|
|
15
|
-
text?: string;
|
|
16
|
-
fontColor?: TRgb;
|
|
17
|
-
font?: string;
|
|
18
|
-
bgColor?: TRgba;
|
|
19
|
-
bgImage?: string;
|
|
20
|
-
bgType?: TObjectFitType;
|
|
21
|
-
borderRadius?: number;
|
|
22
|
-
borderWidth?: number;
|
|
23
|
-
borderColor?: TRgba;
|
|
24
|
-
customDraw?: TDrawingCallback;
|
|
25
|
-
layer?: number;
|
|
26
|
-
};
|
|
27
|
-
export type TFrameInfo = {
|
|
28
|
-
width: number;
|
|
29
|
-
height: number;
|
|
30
|
-
};
|
|
31
|
-
export type TDrawingCallback = (cod: CamOverlayDrawingAPI, cairo: string, info: TFrameInfo) => Promise<void>;
|
|
32
|
-
export interface Frame {
|
|
33
|
-
on(event: 'open', listener: () => void): this;
|
|
34
|
-
on(event: 'close', listener: () => void): this;
|
|
35
|
-
on(event: 'layoutChanged', listener: () => void): this;
|
|
36
|
-
emit(event: 'open'): boolean;
|
|
37
|
-
emit(event: 'close'): boolean;
|
|
38
|
-
emit(event: 'layoutChanged'): boolean;
|
|
39
|
-
}
|
|
3
|
+
import { CamOverlayDrawingAPI } from '../CamOverlayDrawingAPI';
|
|
4
|
+
import { TAlign, TCairoCreateResponse, TUploadImageResponse } from '../types/CamOverlayDrawingAPI';
|
|
5
|
+
import { ResourceManager } from './ResourceManager';
|
|
6
|
+
import { TBg, TBorder, TDrawingCallback, TFrame, TFrameOptions, TObjectFitType, TRgb, TRgba, TText, TTmf } from '../types/CamOverlayPainter';
|
|
40
7
|
export declare class Frame extends EventEmitter {
|
|
41
8
|
protected enabled: boolean;
|
|
42
9
|
protected posX: number;
|
|
@@ -64,17 +31,21 @@ export declare class Frame extends EventEmitter {
|
|
|
64
31
|
disable(): void;
|
|
65
32
|
setFramePosition(x: number, y: number): void;
|
|
66
33
|
setFrameSize(width: number, height: number): void;
|
|
34
|
+
getFrameInfo(): TFrame;
|
|
67
35
|
setText(text: string, align: TAlign, textType?: TTmf, fontColor?: TRgb): void;
|
|
68
36
|
setFontColor(fontColor: TRgb): void;
|
|
69
37
|
setFont(fontName: string): void;
|
|
70
38
|
setFontData(fontData: TCairoCreateResponse): void;
|
|
39
|
+
getTextInfo(): TText;
|
|
71
40
|
setBgColor(color: TRgba): void;
|
|
72
41
|
setBgImage(imageName: string, type?: TObjectFitType): void;
|
|
73
42
|
setBgImageData(imageData: TUploadImageResponse, type?: TObjectFitType): void;
|
|
74
43
|
setBgType(type: TObjectFitType): void;
|
|
44
|
+
getBgInfo(): TBg;
|
|
75
45
|
setBorderRadius(radius: number): void;
|
|
76
46
|
setBorderWidth(width: number): void;
|
|
77
47
|
setBorderColor(color: TRgba): void;
|
|
48
|
+
getBorderInfo(): TBorder;
|
|
78
49
|
setCustomDraw(customDraw: TDrawingCallback): void;
|
|
79
50
|
resetFont(): void;
|
|
80
51
|
resetBgColor(): void;
|
|
@@ -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,6 +1,8 @@
|
|
|
1
|
-
import { CamOverlayDrawingAPI
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { CamOverlayDrawingAPI } from '../CamOverlayDrawingAPI';
|
|
2
|
+
import { CamOverlayDrawingOptions } from '../types/CamOverlayDrawingAPI';
|
|
3
|
+
import { ResourceManager } from './ResourceManager';
|
|
4
|
+
import { Frame } from './Frame';
|
|
5
|
+
import { TCoAlignment, TPainterOptions } from '../types/CamOverlayPainter';
|
|
4
6
|
export declare const COORD: {
|
|
5
7
|
readonly top_left: readonly [-1, -1];
|
|
6
8
|
readonly center_left: readonly [-1, 0];
|
|
@@ -12,12 +14,6 @@ export declare const COORD: {
|
|
|
12
14
|
readonly center_right: readonly [1, 0];
|
|
13
15
|
readonly bottom_right: readonly [1, 1];
|
|
14
16
|
};
|
|
15
|
-
type TCoAlignment = keyof typeof COORD;
|
|
16
|
-
export type TPainterOptions = TFrameOptions & {
|
|
17
|
-
screenWidth: number;
|
|
18
|
-
screenHeight: number;
|
|
19
|
-
coAlignment: TCoAlignment;
|
|
20
|
-
};
|
|
21
17
|
export declare class Painter extends Frame {
|
|
22
18
|
private screenWidth;
|
|
23
19
|
private screenHeight;
|
|
@@ -45,4 +41,3 @@ export declare class Painter extends Frame {
|
|
|
45
41
|
private cleanupSurface;
|
|
46
42
|
private positionConvertor;
|
|
47
43
|
}
|
|
48
|
-
export { Frame, TFrameOptions as FrameOptions, ResourceManager, CamOverlayDrawingOptions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CamOverlayDrawingAPI } from '../CamOverlayDrawingAPI';
|
|
2
|
-
import ResourceManager from './ResourceManager';
|
|
2
|
+
import { ResourceManager } from './ResourceManager';
|
|
3
3
|
import { Frame } from './Frame';
|
|
4
4
|
export const COORD = {
|
|
5
5
|
top_left: [-1, -1],
|
|
@@ -163,4 +163,3 @@ export class Painter extends Frame {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
export { Frame, ResourceManager };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { CamOverlayDrawingAPI
|
|
2
|
-
|
|
1
|
+
import { CamOverlayDrawingAPI } from '../CamOverlayDrawingAPI';
|
|
2
|
+
import { TUploadImageResponse, TCairoCreateResponse } from '../types/CamOverlayDrawingAPI';
|
|
3
|
+
export declare class ResourceManager {
|
|
3
4
|
private co;
|
|
4
5
|
private imgFileNames;
|
|
5
6
|
private fontFileNames;
|
package/esm/CamScripterAPI.d.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { IClient, TResponse } from './internal/types';
|
|
2
2
|
import { TNodeState, TPackageInfoList, TStorage, TStorageType } from './types/CamScripterAPI';
|
|
3
|
-
import { TNetworkCamera } from './types/common';
|
|
4
|
-
export declare const BASE_URL = "/local/camscripter";
|
|
3
|
+
import { THttpRequestOptions, TNetworkCamera } from './types/common';
|
|
5
4
|
export declare class CamScripterAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
6
5
|
client: Client;
|
|
7
6
|
constructor(client: Client);
|
|
8
7
|
static getProxyUrlPath: () => string;
|
|
9
|
-
checkCameraTime(): Promise<boolean>;
|
|
10
|
-
getNetworkCameraList(): Promise<TNetworkCamera[]>;
|
|
11
|
-
getStorageInfo(): Promise<TStorage>;
|
|
12
|
-
getPackageList(): Promise<TPackageInfoList>;
|
|
13
|
-
installPackages(formData: FormData, storage: TStorageType): Promise<{
|
|
8
|
+
checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
|
|
9
|
+
getNetworkCameraList(options?: THttpRequestOptions): Promise<TNetworkCamera[]>;
|
|
10
|
+
getStorageInfo(options?: THttpRequestOptions): Promise<TStorage>;
|
|
11
|
+
getPackageList(options?: THttpRequestOptions): Promise<TPackageInfoList>;
|
|
12
|
+
installPackages(formData: FormData, storage: TStorageType, options?: THttpRequestOptions): Promise<{
|
|
14
13
|
status: number;
|
|
15
14
|
message: string;
|
|
16
15
|
}>;
|
|
17
|
-
uninstallPackage(packageId: string): Promise<{
|
|
16
|
+
uninstallPackage(packageId: string, options?: THttpRequestOptions): Promise<{
|
|
18
17
|
status: number;
|
|
19
18
|
message: string;
|
|
20
19
|
}>;
|
|
21
|
-
importSettings(packageId: string, formData: FormData): Promise<{
|
|
20
|
+
importSettings(packageId: string, formData: FormData, options?: THttpRequestOptions): Promise<{
|
|
22
21
|
status: number;
|
|
23
22
|
message: string;
|
|
24
23
|
}>;
|
|
25
|
-
exportSettings(packageId: string, formData: FormData): Promise<{
|
|
24
|
+
exportSettings(packageId: string, formData: FormData, options?: THttpRequestOptions): Promise<{
|
|
26
25
|
status: number;
|
|
27
26
|
message: string;
|
|
28
27
|
}>;
|
|
29
|
-
getNodejsStatus(): Promise<TNodeState>;
|
|
30
|
-
installNodejs(storage: TStorageType): Promise<{
|
|
28
|
+
getNodejsStatus(options?: THttpRequestOptions): Promise<TNodeState>;
|
|
29
|
+
installNodejs(storage: TStorageType, options?: THttpRequestOptions): Promise<{
|
|
31
30
|
status: number;
|
|
32
31
|
message: string;
|
|
33
32
|
}>;
|
|
34
33
|
private get;
|
|
35
34
|
private post;
|
|
35
|
+
private getAgent;
|
|
36
36
|
}
|