camstreamerlib 4.0.0-beta.3 → 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 +8 -2
- package/cjs/CamOverlayAPI.d.ts +47 -26
- package/cjs/CamOverlayAPI.js +171 -88
- package/cjs/CamOverlayDrawingAPI.d.ts +2 -47
- package/cjs/CamOverlayDrawingAPI.js +6 -3
- package/cjs/CamOverlayPainter/Frame.d.ts +8 -37
- package/cjs/CamOverlayPainter/Frame.js +33 -0
- package/cjs/CamOverlayPainter/Painter.d.ts +16 -10
- package/cjs/CamOverlayPainter/Painter.js +6 -5
- package/cjs/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/cjs/CamOverlayPainter/ResourceManager.js +8 -11
- package/cjs/CamScripterAPI.d.ts +33 -16
- package/cjs/CamScripterAPI.js +50 -41
- package/cjs/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/cjs/CamScripterAPICameraEventsGenerator.js +6 -3
- package/cjs/CamStreamerAPI.d.ts +16 -14
- package/cjs/CamStreamerAPI.js +32 -32
- package/cjs/CamSwitcherAPI.d.ts +42 -37
- package/cjs/CamSwitcherAPI.js +123 -114
- package/cjs/CamSwitcherEvents.d.ts +1 -1
- package/cjs/PlaneTrackerAPI.d.ts +42 -0
- package/cjs/PlaneTrackerAPI.js +211 -0
- package/cjs/VapixAPI.d.ts +56 -43
- package/cjs/VapixAPI.js +305 -216
- package/cjs/VapixEvents.d.ts +1 -1
- package/cjs/VapixEvents.js +3 -3
- package/cjs/errors/errors.d.ts +3 -0
- package/cjs/errors/errors.js +8 -1
- package/cjs/events/AxisCameraStationEvents.d.ts +5 -4
- package/cjs/events/AxisCameraStationEvents.js +23 -18
- package/cjs/events/GenetecAgent.d.ts +6 -3
- package/cjs/events/GenetecAgent.js +30 -19
- package/cjs/index.d.ts +14 -1
- package/cjs/index.js +23 -2
- package/cjs/internal/Digest.js +6 -6
- package/cjs/internal/ProxyClient.d.ts +8 -9
- package/cjs/internal/ProxyClient.js +25 -29
- package/cjs/internal/types.d.ts +42 -0
- package/cjs/internal/types.js +2 -0
- package/cjs/internal/utils.d.ts +4 -1
- package/cjs/internal/utils.js +22 -3
- package/cjs/internal/versionCompare.d.ts +2 -2
- package/cjs/node/DefaultClient.d.ts +5 -6
- package/cjs/node/DefaultClient.js +12 -14
- package/cjs/node/HttpRequestSender.d.ts +1 -0
- package/cjs/node/HttpRequestSender.js +13 -3
- package/cjs/node/HttpServer.js +1 -1
- package/cjs/node/WsClient.d.ts +2 -1
- package/cjs/node/WsEventClient.d.ts +1 -1
- package/cjs/node/index.d.ts +2 -0
- package/cjs/node/index.js +18 -1
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.d.ts +3073 -0
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +127 -0
- package/cjs/types/CamOverlayAPI/accuweatherSchema.d.ts +114 -0
- package/cjs/types/CamOverlayAPI/accuweatherSchema.js +50 -0
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.d.ts +783 -0
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.js +75 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.d.ts +122 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.js +12 -0
- package/cjs/types/CamOverlayAPI/index.d.ts +9 -0
- package/cjs/types/CamOverlayAPI/index.js +25 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.d.ts +130 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.js +29 -0
- package/cjs/types/CamOverlayAPI/pipSchema.d.ts +166 -0
- package/cjs/types/CamOverlayAPI/pipSchema.js +42 -0
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.d.ts +126 -0
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.js +28 -0
- package/cjs/types/CamOverlayAPI/ptzSchema.d.ts +146 -0
- package/cjs/types/CamOverlayAPI/ptzSchema.js +15 -0
- package/cjs/types/CamOverlayAPI/screenSharingSchema.d.ts +79 -0
- package/cjs/types/CamOverlayAPI/screenSharingSchema.js +11 -0
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.d.ts +79 -0
- 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/CamScripterAPI.d.ts +82 -17
- package/cjs/types/CamScripterAPI.js +22 -7
- package/cjs/types/CamStreamerAPI.d.ts +16 -5
- package/cjs/types/CamStreamerAPI.js +5 -1
- package/cjs/types/CamSwitcherAPI.d.ts +5 -5
- package/cjs/types/CamSwitcherEvents.d.ts +77 -0
- package/cjs/types/CamSwitcherEvents.js +8 -0
- package/cjs/types/PlaneTrackerAPI.d.ts +8 -0
- package/cjs/types/PlaneTrackerAPI.js +2 -0
- package/cjs/types/VapixAPI.d.ts +636 -519
- package/cjs/types/VapixAPI.js +62 -24
- package/cjs/types/common.d.ts +14 -5
- package/cjs/web/DefaultClient.d.ts +5 -5
- package/cjs/web/DefaultClient.js +22 -10
- package/cjs/web/WsClient.js +2 -2
- package/esm/CamOverlayAPI.d.ts +47 -26
- package/esm/CamOverlayAPI.js +169 -86
- package/esm/CamOverlayDrawingAPI.d.ts +2 -47
- package/esm/CamOverlayDrawingAPI.js +6 -3
- package/esm/CamOverlayPainter/Frame.d.ts +8 -37
- package/esm/CamOverlayPainter/Frame.js +33 -0
- package/esm/CamOverlayPainter/Painter.d.ts +16 -10
- package/esm/CamOverlayPainter/Painter.js +5 -3
- package/esm/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/esm/CamOverlayPainter/ResourceManager.js +7 -11
- package/esm/CamScripterAPI.d.ts +33 -16
- package/esm/CamScripterAPI.js +46 -37
- package/esm/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/esm/CamScripterAPICameraEventsGenerator.js +6 -3
- package/esm/CamStreamerAPI.d.ts +16 -14
- package/esm/CamStreamerAPI.js +32 -32
- package/esm/CamSwitcherAPI.d.ts +42 -37
- package/esm/CamSwitcherAPI.js +116 -107
- package/esm/CamSwitcherEvents.d.ts +1 -1
- package/esm/PlaneTrackerAPI.d.ts +42 -0
- package/esm/PlaneTrackerAPI.js +207 -0
- package/esm/VapixAPI.d.ts +56 -43
- package/esm/VapixAPI.js +297 -208
- package/esm/VapixEvents.d.ts +1 -1
- package/esm/VapixEvents.js +3 -3
- package/esm/errors/errors.d.ts +3 -0
- package/esm/errors/errors.js +6 -0
- package/esm/events/AxisCameraStationEvents.d.ts +5 -4
- package/esm/events/AxisCameraStationEvents.js +18 -13
- package/esm/events/GenetecAgent.d.ts +6 -3
- package/esm/events/GenetecAgent.js +20 -9
- package/esm/index.d.ts +14 -1
- package/esm/index.js +14 -1
- package/esm/internal/Digest.js +6 -6
- package/esm/internal/ProxyClient.d.ts +8 -9
- package/esm/internal/ProxyClient.js +25 -29
- package/esm/internal/types.d.ts +42 -0
- package/esm/internal/types.js +1 -0
- package/esm/internal/utils.d.ts +4 -1
- package/esm/internal/utils.js +17 -1
- package/esm/internal/versionCompare.d.ts +2 -2
- package/esm/node/DefaultClient.d.ts +5 -6
- package/esm/node/DefaultClient.js +12 -14
- package/esm/node/HttpRequestSender.d.ts +1 -0
- package/esm/node/HttpRequestSender.js +13 -3
- package/esm/node/HttpServer.js +1 -1
- package/esm/node/WsClient.d.ts +2 -1
- package/esm/node/WsEventClient.d.ts +1 -1
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/types/CamOverlayAPI/CamOverlayAPI.d.ts +3073 -0
- package/esm/types/CamOverlayAPI/CamOverlayAPI.js +124 -0
- package/esm/types/CamOverlayAPI/accuweatherSchema.d.ts +114 -0
- package/esm/types/CamOverlayAPI/accuweatherSchema.js +46 -0
- package/esm/types/CamOverlayAPI/customGraphicsSchema.d.ts +783 -0
- package/esm/types/CamOverlayAPI/customGraphicsSchema.js +71 -0
- package/esm/types/CamOverlayAPI/imagesSchema.d.ts +122 -0
- package/esm/types/CamOverlayAPI/imagesSchema.js +8 -0
- package/esm/types/CamOverlayAPI/index.d.ts +9 -0
- package/esm/types/CamOverlayAPI/index.js +9 -0
- package/esm/types/CamOverlayAPI/infotickerSchema.d.ts +130 -0
- package/esm/types/CamOverlayAPI/infotickerSchema.js +25 -0
- package/esm/types/CamOverlayAPI/pipSchema.d.ts +166 -0
- package/esm/types/CamOverlayAPI/pipSchema.js +38 -0
- package/esm/types/CamOverlayAPI/ptzCompassSchema.d.ts +126 -0
- package/esm/types/CamOverlayAPI/ptzCompassSchema.js +24 -0
- package/esm/types/CamOverlayAPI/ptzSchema.d.ts +146 -0
- package/esm/types/CamOverlayAPI/ptzSchema.js +11 -0
- package/esm/types/CamOverlayAPI/screenSharingSchema.d.ts +79 -0
- package/esm/types/CamOverlayAPI/screenSharingSchema.js +7 -0
- package/esm/types/CamOverlayAPI/webCameraSharingSchema.d.ts +79 -0
- 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/CamScripterAPI.d.ts +82 -17
- package/esm/types/CamScripterAPI.js +21 -6
- package/esm/types/CamStreamerAPI.d.ts +16 -5
- package/esm/types/CamStreamerAPI.js +4 -0
- package/esm/types/CamSwitcherAPI.d.ts +5 -5
- package/esm/types/CamSwitcherEvents.d.ts +77 -0
- package/esm/types/CamSwitcherEvents.js +8 -0
- package/esm/types/PlaneTrackerAPI.d.ts +8 -0
- package/esm/types/PlaneTrackerAPI.js +1 -0
- package/esm/types/VapixAPI.d.ts +636 -519
- package/esm/types/VapixAPI.js +61 -23
- package/esm/types/common.d.ts +14 -5
- package/esm/web/DefaultClient.d.ts +5 -5
- package/esm/web/DefaultClient.js +22 -10
- package/esm/web/WsClient.js +2 -2
- package/package.json +9 -8
- package/cjs/internal/common.d.ts +0 -39
- package/cjs/internal/common.js +0 -27
- package/cjs/types/CamOverlayAPI.d.ts +0 -188
- package/cjs/types/CamOverlayAPI.js +0 -47
- package/esm/internal/common.d.ts +0 -39
- package/esm/internal/common.js +0 -20
- package/esm/types/CamOverlayAPI.d.ts +0 -188
- package/esm/types/CamOverlayAPI.js +0 -44
|
@@ -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,11 +1,18 @@
|
|
|
1
|
-
import { CamOverlayDrawingAPI
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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';
|
|
6
|
+
export declare const COORD: {
|
|
7
|
+
readonly top_left: readonly [-1, -1];
|
|
8
|
+
readonly center_left: readonly [-1, 0];
|
|
9
|
+
readonly bottom_left: readonly [-1, 1];
|
|
10
|
+
readonly top_center: readonly [0, -1];
|
|
11
|
+
readonly center: readonly [0, 0];
|
|
12
|
+
readonly bottom_center: readonly [0, 1];
|
|
13
|
+
readonly top_right: readonly [1, -1];
|
|
14
|
+
readonly center_right: readonly [1, 0];
|
|
15
|
+
readonly bottom_right: readonly [1, 1];
|
|
9
16
|
};
|
|
10
17
|
export declare class Painter extends Frame {
|
|
11
18
|
private screenWidth;
|
|
@@ -24,7 +31,7 @@ export declare class Painter extends Frame {
|
|
|
24
31
|
registerImage(moniker: string, fileName: string): void;
|
|
25
32
|
registerFont(moniker: string, fileName: string): void;
|
|
26
33
|
setScreenSize(sw: number, sh: number): void;
|
|
27
|
-
setCoAlignment(coAlignment:
|
|
34
|
+
setCoAlignment(coAlignment: TCoAlignment): void;
|
|
28
35
|
protected layoutChanged(): void;
|
|
29
36
|
display(scale?: number): Promise<void>;
|
|
30
37
|
hide(): Promise<void>;
|
|
@@ -34,4 +41,3 @@ export declare class Painter extends Frame {
|
|
|
34
41
|
private cleanupSurface;
|
|
35
42
|
private positionConvertor;
|
|
36
43
|
}
|
|
37
|
-
export { Frame, TFrameOptions as FrameOptions, ResourceManager, CamOverlayDrawingOptions };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Painter = exports.COORD = 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
|
-
Object.defineProperty(exports, "Frame", { enumerable: true, get: function () { return Frame_1.Frame; } });
|
|
9
7
|
exports.COORD = {
|
|
10
8
|
top_left: [-1, -1],
|
|
11
9
|
center_left: [-1, 0],
|
|
@@ -31,7 +29,7 @@ class Painter extends Frame_1.Frame {
|
|
|
31
29
|
this.screenWidth = opt.screenWidth;
|
|
32
30
|
this.screenHeight = opt.screenHeight;
|
|
33
31
|
this.cod = new CamOverlayDrawingAPI_1.CamOverlayDrawingAPI(coopt);
|
|
34
|
-
this.rm = new ResourceManager_1.
|
|
32
|
+
this.rm = new ResourceManager_1.ResourceManager(this.cod);
|
|
35
33
|
}
|
|
36
34
|
get camOverlayDrawingAPI() {
|
|
37
35
|
return this.cod;
|
|
@@ -87,6 +85,9 @@ class Painter extends Frame_1.Frame {
|
|
|
87
85
|
let lastCachedLayer;
|
|
88
86
|
for (let i = 0; i < this.layers.length; i++) {
|
|
89
87
|
const layer = this.layers[i];
|
|
88
|
+
if (layer === undefined) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
90
91
|
if (layer.cairoCache !== undefined &&
|
|
91
92
|
layer.surfaceCache !== undefined &&
|
|
92
93
|
surface === undefined &&
|
|
@@ -120,7 +121,7 @@ class Painter extends Frame_1.Frame {
|
|
|
120
121
|
}
|
|
121
122
|
for (let i = layerIdx; i < this.layers.length; i++) {
|
|
122
123
|
const currentLayer = this.layers[i];
|
|
123
|
-
if (currentLayer
|
|
124
|
+
if (currentLayer?.surfaceCache !== undefined && currentLayer.cairoCache !== undefined) {
|
|
124
125
|
await this.cleanupSurface(currentLayer.surfaceCache, currentLayer.cairoCache);
|
|
125
126
|
currentLayer.surfaceCache = undefined;
|
|
126
127
|
currentLayer.cairoCache = undefined;
|
|
@@ -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;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResourceManager = void 0;
|
|
3
4
|
const fs = require("fs/promises");
|
|
4
5
|
class ResourceManager {
|
|
5
6
|
co;
|
|
@@ -17,34 +18,30 @@ class ResourceManager {
|
|
|
17
18
|
this.fontFileNames[moniker] = process.env.INSTALL_PATH + '/fonts/' + fileName;
|
|
18
19
|
}
|
|
19
20
|
async image(moniker) {
|
|
20
|
-
if (moniker
|
|
21
|
+
if (this.images[moniker] !== undefined) {
|
|
21
22
|
return this.images[moniker];
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
if (this.imgFileNames[moniker] !== undefined) {
|
|
24
25
|
const imgData = await fs.readFile(this.imgFileNames[moniker]);
|
|
25
26
|
this.images[moniker] = await this.co.uploadImageData(imgData);
|
|
26
27
|
return this.images[moniker];
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
throw new Error('Error! Unknown image requested!');
|
|
30
|
-
}
|
|
29
|
+
throw new Error('Error! Unknown image requested!');
|
|
31
30
|
}
|
|
32
31
|
async font(moniker) {
|
|
33
|
-
if (moniker
|
|
32
|
+
if (this.fonts[moniker] !== undefined) {
|
|
34
33
|
return this.fonts[moniker];
|
|
35
34
|
}
|
|
36
|
-
|
|
35
|
+
if (this.fontFileNames[moniker] !== undefined) {
|
|
37
36
|
const fontData = await fs.readFile(this.fontFileNames[moniker]);
|
|
38
37
|
this.fonts[moniker] = await this.co.uploadFontData(fontData);
|
|
39
38
|
return this.fonts[moniker];
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
throw new Error('Error! Unknown font requested!');
|
|
43
|
-
}
|
|
40
|
+
throw new Error('Error! Unknown font requested!');
|
|
44
41
|
}
|
|
45
42
|
clear() {
|
|
46
43
|
this.images = {};
|
|
47
44
|
this.fonts = {};
|
|
48
45
|
}
|
|
49
46
|
}
|
|
50
|
-
exports.
|
|
47
|
+
exports.ResourceManager = ResourceManager;
|
package/cjs/CamScripterAPI.d.ts
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
|
-
import { IClient } from './internal/
|
|
2
|
-
import {
|
|
3
|
-
import { TNetworkCamera } from './types/common';
|
|
4
|
-
export declare class
|
|
5
|
-
|
|
6
|
-
constructor(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
getNetworkCameraList(): Promise<TNetworkCamera[]>;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { IClient, TResponse } from './internal/types';
|
|
2
|
+
import { TNodeState, TPackageInfoList, TStorage, TStorageType } from './types/CamScripterAPI';
|
|
3
|
+
import { THttpRequestOptions, TNetworkCamera } from './types/common';
|
|
4
|
+
export declare class CamScripterAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
5
|
+
client: Client;
|
|
6
|
+
constructor(client: Client);
|
|
7
|
+
static getProxyUrlPath: () => string;
|
|
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<{
|
|
13
|
+
status: number;
|
|
14
|
+
message: string;
|
|
15
|
+
}>;
|
|
16
|
+
uninstallPackage(packageId: string, options?: THttpRequestOptions): Promise<{
|
|
17
|
+
status: number;
|
|
18
|
+
message: string;
|
|
19
|
+
}>;
|
|
20
|
+
importSettings(packageId: string, formData: FormData, options?: THttpRequestOptions): Promise<{
|
|
21
|
+
status: number;
|
|
22
|
+
message: string;
|
|
23
|
+
}>;
|
|
24
|
+
exportSettings(packageId: string, formData: FormData, options?: THttpRequestOptions): Promise<{
|
|
25
|
+
status: number;
|
|
26
|
+
message: string;
|
|
27
|
+
}>;
|
|
28
|
+
getNodejsStatus(options?: THttpRequestOptions): Promise<TNodeState>;
|
|
29
|
+
installNodejs(storage: TStorageType, options?: THttpRequestOptions): Promise<{
|
|
30
|
+
status: number;
|
|
31
|
+
message: string;
|
|
32
|
+
}>;
|
|
17
33
|
private get;
|
|
18
34
|
private post;
|
|
35
|
+
private getAgent;
|
|
19
36
|
}
|
package/cjs/CamScripterAPI.js
CHANGED
|
@@ -1,70 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
exports.CamScripterAPI = void 0;
|
|
4
|
+
const ProxyClient_1 = require("./internal/ProxyClient");
|
|
5
|
+
const utils_1 = require("./internal/utils");
|
|
6
6
|
const CamScripterAPI_1 = require("./types/CamScripterAPI");
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const common_1 = require("./types/common");
|
|
8
|
+
const BASE_PATH = '/local/camscripter';
|
|
9
|
+
class CamScripterAPI {
|
|
9
10
|
client;
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
12
|
-
this.client = options;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
this.client = new DefaultClient_1.DefaultClient(options);
|
|
16
|
-
}
|
|
11
|
+
constructor(client) {
|
|
12
|
+
this.client = client;
|
|
17
13
|
}
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
15
|
+
async checkCameraTime(options) {
|
|
16
|
+
const data = await this.get(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
17
|
+
return CamScripterAPI_1.cameraTimeResponseSchema.parse(data).state;
|
|
20
18
|
}
|
|
21
|
-
async
|
|
22
|
-
const data = await this.get(
|
|
23
|
-
return
|
|
19
|
+
async getNetworkCameraList(options) {
|
|
20
|
+
const data = await this.get(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
|
|
21
|
+
return common_1.networkCameraListSchema.parse(data.camera_list);
|
|
24
22
|
}
|
|
25
|
-
async
|
|
26
|
-
const
|
|
27
|
-
return
|
|
23
|
+
async getStorageInfo(options) {
|
|
24
|
+
const data = await this.get(`${BASE_PATH}/package/get_storage.cgi`, undefined, options);
|
|
25
|
+
return CamScripterAPI_1.storageSchema.parse(data);
|
|
28
26
|
}
|
|
29
|
-
async getPackageList() {
|
|
30
|
-
const data = await this.get(
|
|
27
|
+
async getPackageList(options) {
|
|
28
|
+
const data = await this.get(`${BASE_PATH}/package/list.cgi`, undefined, options);
|
|
31
29
|
return CamScripterAPI_1.packageInfoListSchema.parse(data);
|
|
32
30
|
}
|
|
33
|
-
async installPackages(formData, storage) {
|
|
34
|
-
await this.post(
|
|
31
|
+
async installPackages(formData, storage, options) {
|
|
32
|
+
const data = await this.post(`${BASE_PATH}/package/install.cgi?storage=${storage}`, formData, undefined, options);
|
|
33
|
+
return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
|
|
35
34
|
}
|
|
36
|
-
async uninstallPackage(packageId) {
|
|
37
|
-
await this.get(
|
|
35
|
+
async uninstallPackage(packageId, options) {
|
|
36
|
+
const data = await this.get(`${BASE_PATH}/package/remove.cgi?package_name=${packageId}`, undefined, options);
|
|
37
|
+
return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
|
|
38
38
|
}
|
|
39
|
-
async importSettings(packageId, formData) {
|
|
40
|
-
await this.post(
|
|
39
|
+
async importSettings(packageId, formData, options) {
|
|
40
|
+
const data = await this.post(`${BASE_PATH}/package/data.cgi?action=IMPORT&package_name=${packageId}`, formData, undefined, options);
|
|
41
|
+
return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
|
|
41
42
|
}
|
|
42
|
-
async exportSettings(packageId, formData) {
|
|
43
|
-
await this.post(
|
|
43
|
+
async exportSettings(packageId, formData, options) {
|
|
44
|
+
const data = await this.post(`${BASE_PATH}/package/data.cgi?action=EXPORT&package_name=${packageId}`, formData, undefined, options);
|
|
45
|
+
return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
|
|
44
46
|
}
|
|
45
|
-
async getNodejsStatus() {
|
|
46
|
-
|
|
47
|
+
async getNodejsStatus(options) {
|
|
48
|
+
const data = await this.get(`${BASE_PATH}/diagnostics.cgi`, undefined, options);
|
|
49
|
+
return CamScripterAPI_1.nodeStateSchema.parse(data);
|
|
47
50
|
}
|
|
48
|
-
async installNodejs(storage) {
|
|
49
|
-
await this.get(
|
|
51
|
+
async installNodejs(storage, options) {
|
|
52
|
+
const data = await this.get(`${BASE_PATH}/node_update.cgi?storage=${storage}`, undefined, options);
|
|
53
|
+
return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
|
|
50
54
|
}
|
|
51
|
-
async get(path,
|
|
52
|
-
const
|
|
55
|
+
async get(path, parameters, options) {
|
|
56
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
57
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
53
58
|
if (res.ok) {
|
|
54
59
|
return await res.json();
|
|
55
60
|
}
|
|
56
61
|
else {
|
|
57
|
-
throw new Error(await (0,
|
|
62
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
|
-
async post(path, data,
|
|
61
|
-
const
|
|
65
|
+
async post(path, data, parameters, options) {
|
|
66
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
67
|
+
const res = await agent.post({ path, data, parameters, timeout: options?.timeout });
|
|
62
68
|
if (res.ok) {
|
|
63
69
|
return await res.json();
|
|
64
70
|
}
|
|
65
71
|
else {
|
|
66
|
-
throw new Error(await (0,
|
|
72
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
67
73
|
}
|
|
68
74
|
}
|
|
75
|
+
getAgent(proxyParams) {
|
|
76
|
+
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
77
|
+
}
|
|
69
78
|
}
|
|
70
|
-
exports.
|
|
79
|
+
exports.CamScripterAPI = CamScripterAPI;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as EventEmitter from 'events';
|
|
3
|
-
import { WsOptions } from './internal/
|
|
3
|
+
import { WsOptions } from './internal/types';
|
|
4
4
|
export type CamScripterOptions = WsOptions;
|
|
5
5
|
export type TDeclaration = {
|
|
6
6
|
type?: '' | 'SOURCE' | 'DATA';
|
|
@@ -91,10 +91,10 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
91
91
|
}
|
|
92
92
|
if (dataJSON.call_id !== undefined) {
|
|
93
93
|
if (errorResponse !== undefined) {
|
|
94
|
-
this.sendMessages[dataJSON.call_id]
|
|
94
|
+
this.sendMessages[dataJSON.call_id]?.reject(new Error(errorResponse.error));
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
97
|
-
this.sendMessages[dataJSON.call_id]
|
|
97
|
+
this.sendMessages[dataJSON.call_id]?.resolve(dataJSON);
|
|
98
98
|
}
|
|
99
99
|
delete this.sendMessages[dataJSON.call_id];
|
|
100
100
|
}
|
|
@@ -127,6 +127,9 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
127
127
|
const now = Date.now();
|
|
128
128
|
for (const callId in this.sendMessages) {
|
|
129
129
|
const msg = this.sendMessages[callId];
|
|
130
|
+
if (!msg) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
130
133
|
if (now - msg.sentTimestamp > 10000) {
|
|
131
134
|
reconnect = true;
|
|
132
135
|
msg.reject(new Error('Message timeout'));
|
|
@@ -150,7 +153,7 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
150
153
|
}
|
|
151
154
|
reportClose() {
|
|
152
155
|
for (const callId in this.sendMessages) {
|
|
153
|
-
this.sendMessages[callId]
|
|
156
|
+
this.sendMessages[callId]?.reject(new Error('Connection lost'));
|
|
154
157
|
}
|
|
155
158
|
this.sendMessages = {};
|
|
156
159
|
this.emit('close');
|
package/cjs/CamStreamerAPI.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { IClient } from './internal/
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { IClient, TResponse } from './internal/types';
|
|
2
|
+
import { TStreamAttributes, TStreamList } from './types/CamStreamerAPI';
|
|
3
|
+
import { THttpRequestOptions } from './types/common';
|
|
4
|
+
export declare class CamStreamerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
5
|
+
client: Client;
|
|
6
|
+
constructor(client: Client);
|
|
7
|
+
getStreamList(options?: THttpRequestOptions): Promise<TStreamList>;
|
|
8
|
+
getStream(streamId: string, options?: THttpRequestOptions): Promise<TStreamAttributes>;
|
|
9
|
+
getStreamParameter(streamId: string, paramName: string, options?: THttpRequestOptions): Promise<string>;
|
|
10
|
+
setStream(streamId: string, params: Partial<TStreamAttributes>, options?: THttpRequestOptions): Promise<void>;
|
|
11
|
+
setStreamParameter(streamId: string, paramName: string, value: string, options?: THttpRequestOptions): Promise<void>;
|
|
12
|
+
isStreaming(streamId: string, options?: THttpRequestOptions): Promise<boolean>;
|
|
13
|
+
deleteStream(streamId: string, options?: THttpRequestOptions): Promise<void>;
|
|
14
|
+
wsAuthorization(options?: THttpRequestOptions): Promise<string>;
|
|
15
|
+
getUtcTime(options?: THttpRequestOptions): Promise<number>;
|
|
15
16
|
private get;
|
|
17
|
+
private getAgent;
|
|
16
18
|
}
|
package/cjs/CamStreamerAPI.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CamStreamerAPI = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const ProxyClient_1 = require("./internal/ProxyClient");
|
|
5
|
+
const utils_1 = require("./internal/utils");
|
|
6
6
|
const CamStreamerAPI_1 = require("./types/CamStreamerAPI");
|
|
7
|
+
const BASE_PATH = '/local/camstreamer';
|
|
7
8
|
class CamStreamerAPI {
|
|
8
9
|
client;
|
|
9
|
-
constructor(
|
|
10
|
-
|
|
11
|
-
this.client = options;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
this.client = new DefaultClient_1.DefaultClient(options);
|
|
15
|
-
}
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.client = client;
|
|
16
12
|
}
|
|
17
|
-
async getStreamList() {
|
|
18
|
-
const streamListRes = await this.get(
|
|
13
|
+
async getStreamList(options) {
|
|
14
|
+
const streamListRes = await this.get(`${BASE_PATH}/stream/list.cgi`, undefined, options);
|
|
19
15
|
return CamStreamerAPI_1.streamListSchema.parse(streamListRes.data);
|
|
20
16
|
}
|
|
21
|
-
async getStream(
|
|
22
|
-
const stream = await this.get(
|
|
17
|
+
async getStream(streamId, options) {
|
|
18
|
+
const stream = await this.get(`${BASE_PATH}/stream/get.cgi?stream_id=${streamId}`, undefined, options);
|
|
23
19
|
return CamStreamerAPI_1.streamAttributesSchema.parse(stream.data);
|
|
24
20
|
}
|
|
25
|
-
async getStreamParameter(
|
|
26
|
-
const stream = await this.get(
|
|
21
|
+
async getStreamParameter(streamId, paramName, options) {
|
|
22
|
+
const stream = await this.get(`${BASE_PATH}/stream/get.cgi?stream_id=${streamId}`, undefined, options);
|
|
27
23
|
return stream.data[paramName];
|
|
28
24
|
}
|
|
29
|
-
async setStream(
|
|
25
|
+
async setStream(streamId, params, options) {
|
|
30
26
|
const { streamDelay, startTime, stopTime, ...rest } = params;
|
|
31
|
-
await this.get(
|
|
32
|
-
stream_id:
|
|
27
|
+
await this.get(`${BASE_PATH}/stream/set.cgi`, {
|
|
28
|
+
stream_id: streamId,
|
|
33
29
|
streamDelay: streamDelay ?? '',
|
|
34
30
|
startTime: startTime ?? 'null',
|
|
35
31
|
stopTime: stopTime ?? 'null',
|
|
36
32
|
...rest,
|
|
37
|
-
});
|
|
33
|
+
}, options);
|
|
38
34
|
}
|
|
39
|
-
async setStreamParameter(
|
|
40
|
-
await this.get(
|
|
35
|
+
async setStreamParameter(streamId, paramName, value, options) {
|
|
36
|
+
await this.get(`${BASE_PATH}/stream/set.cgi?stream_id=${streamId}&${paramName}=${value}`, undefined, options);
|
|
41
37
|
}
|
|
42
|
-
async isStreaming(
|
|
43
|
-
const response = await this.get(
|
|
38
|
+
async isStreaming(streamId, options) {
|
|
39
|
+
const response = await this.get(`${BASE_PATH}/get_streamstat.cgi?stream_id=${streamId}`, undefined, options);
|
|
44
40
|
return response.data.is_streaming === 1;
|
|
45
41
|
}
|
|
46
|
-
async deleteStream(
|
|
47
|
-
await this.get(
|
|
42
|
+
async deleteStream(streamId, options) {
|
|
43
|
+
await this.get(`${BASE_PATH}/stream/remove.cgi`, { stream_id: streamId }, options);
|
|
48
44
|
}
|
|
49
|
-
|
|
50
|
-
return this.get(
|
|
45
|
+
wsAuthorization(options) {
|
|
46
|
+
return this.get(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
51
47
|
}
|
|
52
|
-
async getUtcTime() {
|
|
53
|
-
return await this.get(
|
|
48
|
+
async getUtcTime(options) {
|
|
49
|
+
return await this.get(`${BASE_PATH}/get_utc_time.cgi`, undefined, options);
|
|
54
50
|
}
|
|
55
|
-
async get(path, parameters) {
|
|
56
|
-
const
|
|
51
|
+
async get(path, parameters, options) {
|
|
52
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
53
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
57
54
|
if (res.ok) {
|
|
58
55
|
return await res.json();
|
|
59
56
|
}
|
|
60
57
|
else {
|
|
61
|
-
throw new Error(await (0,
|
|
58
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
62
59
|
}
|
|
63
60
|
}
|
|
61
|
+
getAgent(proxyParams) {
|
|
62
|
+
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
63
|
+
}
|
|
64
64
|
}
|
|
65
65
|
exports.CamStreamerAPI = CamStreamerAPI;
|