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
package/esm/VapixEvents.d.ts
CHANGED
package/esm/VapixEvents.js
CHANGED
|
@@ -39,10 +39,10 @@ export class VapixEvents extends EventEmitter {
|
|
|
39
39
|
this.ws.on('open', () => {
|
|
40
40
|
const topics = [];
|
|
41
41
|
const eventNames = this.eventNames();
|
|
42
|
-
for (
|
|
43
|
-
if (!this.isReservedEventName(
|
|
42
|
+
for (const eventName of eventNames) {
|
|
43
|
+
if (!this.isReservedEventName(eventName)) {
|
|
44
44
|
const topic = {
|
|
45
|
-
topicFilter:
|
|
45
|
+
topicFilter: eventName,
|
|
46
46
|
};
|
|
47
47
|
topics.push(topic);
|
|
48
48
|
}
|
package/esm/errors/errors.d.ts
CHANGED
package/esm/errors/errors.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { HttpOptions } from '../internal/types';
|
|
2
|
+
import { THttpRequestOptions } from '../types/common';
|
|
3
3
|
export declare class AxisCameraStationEvents {
|
|
4
4
|
private sourceKey;
|
|
5
5
|
private client;
|
|
6
|
-
constructor(
|
|
7
|
-
sendEvent(data: Record<string, string>, eventType: string): Promise<void>;
|
|
6
|
+
constructor(clientOptions: HttpOptions, sourceKey: string);
|
|
7
|
+
sendEvent(data: Record<string, string>, eventType: string, options?: THttpRequestOptions): Promise<void>;
|
|
8
8
|
private getDate;
|
|
9
|
+
private getAgent;
|
|
9
10
|
}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { pad } from '../internal/utils';
|
|
2
|
+
import { ProxyClient } from '../internal/ProxyClient';
|
|
3
|
+
import { DefaultClient } from '../node';
|
|
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
|
-
async sendEvent(data, eventType) {
|
|
11
|
+
async sendEvent(data, eventType, options) {
|
|
16
12
|
const dateString = this.getDate();
|
|
17
13
|
const event = {
|
|
18
14
|
addExternalDataRequest: {
|
|
@@ -23,9 +19,15 @@ export class AxisCameraStationEvents {
|
|
|
23
19
|
},
|
|
24
20
|
};
|
|
25
21
|
const eventData = JSON.stringify(event);
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
'
|
|
22
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
23
|
+
const res = await agent.post({
|
|
24
|
+
path: '/Acs/Api/ExternalDataFacade/AddExternalData',
|
|
25
|
+
data: eventData,
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
'Content-Length': eventData.length.toString(),
|
|
29
|
+
},
|
|
30
|
+
timeout: options?.timeout,
|
|
29
31
|
});
|
|
30
32
|
if (!res.ok) {
|
|
31
33
|
throw new Error(`ACS status code: ${res.status}`);
|
|
@@ -41,4 +43,7 @@ export class AxisCameraStationEvents {
|
|
|
41
43
|
const seconds = pad(date.getUTCSeconds(), 2);
|
|
42
44
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
43
45
|
}
|
|
46
|
+
getAgent(proxyParams) {
|
|
47
|
+
return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
|
|
48
|
+
}
|
|
44
49
|
}
|
|
@@ -148,14 +148,16 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
|
|
|
148
148
|
export type TCameraDetailsResponse = z.infer<typeof cameraDetailsResponseSchema>;
|
|
149
149
|
export type TCameraDetail = z.infer<typeof cameraDetailSchema>;
|
|
150
150
|
export type TParams = Array<'Guid' | 'Name' | 'EntityType'>;
|
|
151
|
+
export type TProtocol = 'http' | 'https' | 'https_insecure';
|
|
151
152
|
export type GenetecAgentOptions = {
|
|
152
|
-
protocol?:
|
|
153
|
+
protocol?: TProtocol;
|
|
153
154
|
ip?: string;
|
|
154
155
|
port?: number;
|
|
155
|
-
|
|
156
|
+
baseUri?: string;
|
|
156
157
|
user?: string;
|
|
157
158
|
pass?: string;
|
|
158
|
-
|
|
159
|
+
appId?: string;
|
|
160
|
+
timeout?: number;
|
|
159
161
|
};
|
|
160
162
|
export declare class GenetecAgent {
|
|
161
163
|
private settings;
|
|
@@ -170,5 +172,6 @@ export declare class GenetecAgent {
|
|
|
170
172
|
sendBookmark(guids: string[], bookmarkText: string): Promise<Response>;
|
|
171
173
|
private getRequestOptions;
|
|
172
174
|
private getTimeStamp;
|
|
175
|
+
private fetchWithTimeout;
|
|
173
176
|
}
|
|
174
177
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { responseStringify, pad } from '../internal/
|
|
2
|
+
import { responseStringify, pad } from '../internal/utils';
|
|
3
3
|
const ACTION = 'AddCameraBookmark';
|
|
4
4
|
const GET_CAMERAS_URL = 'report/EntityConfiguration?q=EntityTypes@Camera';
|
|
5
5
|
const GET_CAMERAS_DETAILS_URL = '/entity?q=';
|
|
@@ -34,17 +34,18 @@ export class GenetecAgent {
|
|
|
34
34
|
protocol: options.protocol ?? 'http',
|
|
35
35
|
ip: options.ip ?? '127.0.0.1',
|
|
36
36
|
port: options.port ?? 80,
|
|
37
|
-
|
|
37
|
+
baseUri: options.baseUri ?? 'WebSdk',
|
|
38
38
|
user: options.user ?? 'root',
|
|
39
39
|
pass: options.pass ?? '',
|
|
40
|
-
|
|
40
|
+
appId: options.appId ?? '',
|
|
41
|
+
timeout: options.timeout ?? 10000,
|
|
41
42
|
};
|
|
42
|
-
this.baseUrl = `${this.settings.protocol}://${this.settings.ip}:${this.settings.port}/${this.settings.
|
|
43
|
-
this.credentials = btoa(`${this.settings.user};${this.settings.
|
|
43
|
+
this.baseUrl = `${this.settings.protocol}://${this.settings.ip}:${this.settings.port}/${this.settings.baseUri}`;
|
|
44
|
+
this.credentials = btoa(`${this.settings.user};${this.settings.appId}:${this.settings.pass}`);
|
|
44
45
|
}
|
|
45
46
|
async checkConnection() {
|
|
46
47
|
const requestOptions = this.getRequestOptions('GET');
|
|
47
|
-
const res = await
|
|
48
|
+
const res = await this.fetchWithTimeout(`${this.baseUrl}/`, requestOptions);
|
|
48
49
|
if (!res.ok) {
|
|
49
50
|
throw new Error(await responseStringify(res));
|
|
50
51
|
}
|
|
@@ -52,7 +53,7 @@ export class GenetecAgent {
|
|
|
52
53
|
}
|
|
53
54
|
async getAllCameraGuids() {
|
|
54
55
|
const requestOptions = this.getRequestOptions('GET');
|
|
55
|
-
const res = await
|
|
56
|
+
const res = await this.fetchWithTimeout(`${this.baseUrl}/${GET_CAMERAS_URL}`, requestOptions);
|
|
56
57
|
if (!res.ok) {
|
|
57
58
|
throw new Error(await responseStringify(res));
|
|
58
59
|
}
|
|
@@ -72,7 +73,7 @@ export class GenetecAgent {
|
|
|
72
73
|
for (const guid of camerasGuids) {
|
|
73
74
|
camerasDetailsUrl.push(`entity=${guid},${params}`);
|
|
74
75
|
}
|
|
75
|
-
const res = await
|
|
76
|
+
const res = await this.fetchWithTimeout(`${this.baseUrl}/${GET_CAMERAS_DETAILS_URL}${camerasDetailsUrl.join(',')}`, requestOptions);
|
|
76
77
|
if (!res.ok) {
|
|
77
78
|
throw new Error(await responseStringify(res));
|
|
78
79
|
}
|
|
@@ -89,7 +90,7 @@ export class GenetecAgent {
|
|
|
89
90
|
for (const guid of guids) {
|
|
90
91
|
cameraEntitiesUrl.push(`${ACTION}(${guid},${timeStamp},${bookmarkText})`);
|
|
91
92
|
}
|
|
92
|
-
const res = await
|
|
93
|
+
const res = await this.fetchWithTimeout(`${this.baseUrl}/action?q=${cameraEntitiesUrl.join(',')}`, requestOptions);
|
|
93
94
|
if (!res.ok) {
|
|
94
95
|
throw new Error(await responseStringify(res));
|
|
95
96
|
}
|
|
@@ -116,4 +117,14 @@ export class GenetecAgent {
|
|
|
116
117
|
const miliSeconds = pad(date.getUTCMilliseconds(), 2);
|
|
117
118
|
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${miliSeconds}Z`;
|
|
118
119
|
}
|
|
120
|
+
async fetchWithTimeout(url, options) {
|
|
121
|
+
const controller = new AbortController();
|
|
122
|
+
const timeoutId = setTimeout(() => controller.abort(), this.settings.timeout);
|
|
123
|
+
try {
|
|
124
|
+
return await fetch(url, { ...options, signal: controller.signal });
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
clearTimeout(timeoutId);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
119
130
|
}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
@@ -6,6 +6,19 @@ export * from './types/common';
|
|
|
6
6
|
export { CamSwitcherAPI } from './CamSwitcherAPI';
|
|
7
7
|
export { CamSwitcherEvents } from './CamSwitcherEvents';
|
|
8
8
|
export { VapixAPI } from './VapixAPI';
|
|
9
|
+
export { CamOverlayAPI } from './CamOverlayAPI';
|
|
10
|
+
export { CamScripterAPI } from './CamScripterAPI';
|
|
11
|
+
export { CamStreamerAPI } from './CamStreamerAPI';
|
|
12
|
+
export { PlaneTrackerAPI } from './PlaneTrackerAPI';
|
|
9
13
|
export * from './types/CamSwitcherEvents';
|
|
10
14
|
export * from './types/CamSwitcherAPI';
|
|
11
15
|
export * from './types/VapixAPI';
|
|
16
|
+
export * from './types/CamOverlayAPI';
|
|
17
|
+
export * from './types/CamOverlayAPI/CamOverlayAPI';
|
|
18
|
+
export * from './types/PlaneTrackerAPI';
|
|
19
|
+
export { Frame } from './CamOverlayPainter/Frame';
|
|
20
|
+
export { Painter } from './CamOverlayPainter/Painter';
|
|
21
|
+
export { ResourceManager } from './CamOverlayPainter/ResourceManager';
|
|
22
|
+
export * from './types/CamOverlayPainter';
|
|
23
|
+
export { CamOverlayDrawingAPI } from './CamOverlayDrawingAPI';
|
|
24
|
+
export * from './types/CamOverlayDrawingAPI';
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
@@ -6,6 +6,19 @@ export * from './types/common';
|
|
|
6
6
|
export { CamSwitcherAPI } from './CamSwitcherAPI';
|
|
7
7
|
export { CamSwitcherEvents } from './CamSwitcherEvents';
|
|
8
8
|
export { VapixAPI } from './VapixAPI';
|
|
9
|
+
export { CamOverlayAPI } from './CamOverlayAPI';
|
|
10
|
+
export { CamScripterAPI } from './CamScripterAPI';
|
|
11
|
+
export { CamStreamerAPI } from './CamStreamerAPI';
|
|
12
|
+
export { PlaneTrackerAPI } from './PlaneTrackerAPI';
|
|
9
13
|
export * from './types/CamSwitcherEvents';
|
|
10
14
|
export * from './types/CamSwitcherAPI';
|
|
11
15
|
export * from './types/VapixAPI';
|
|
16
|
+
export * from './types/CamOverlayAPI';
|
|
17
|
+
export * from './types/CamOverlayAPI/CamOverlayAPI';
|
|
18
|
+
export * from './types/PlaneTrackerAPI';
|
|
19
|
+
export { Frame } from './CamOverlayPainter/Frame';
|
|
20
|
+
export { Painter } from './CamOverlayPainter/Painter';
|
|
21
|
+
export { ResourceManager } from './CamOverlayPainter/ResourceManager';
|
|
22
|
+
export * from './types/CamOverlayPainter';
|
|
23
|
+
export { CamOverlayDrawingAPI } from './CamOverlayDrawingAPI';
|
|
24
|
+
export * from './types/CamOverlayDrawingAPI';
|
package/esm/internal/Digest.js
CHANGED
|
@@ -4,17 +4,17 @@ export class Digest {
|
|
|
4
4
|
getAuthHeader(user, pass, method, uri, wwwAuthenticateHeader) {
|
|
5
5
|
const digestItems = {};
|
|
6
6
|
const digestArr = wwwAuthenticateHeader.substring(wwwAuthenticateHeader.indexOf('Digest') + 6).split(',');
|
|
7
|
-
for (
|
|
8
|
-
const pos =
|
|
9
|
-
const key =
|
|
10
|
-
const value =
|
|
7
|
+
for (const arg of digestArr) {
|
|
8
|
+
const pos = arg.indexOf('=');
|
|
9
|
+
const key = arg.substring(0, pos).trim();
|
|
10
|
+
const value = arg.substring(pos + 1).trim();
|
|
11
11
|
digestItems[key] = value.replace(/"/g, '');
|
|
12
12
|
}
|
|
13
13
|
const HA1 = crypto.createHash('md5').update(`${user}:${digestItems['realm']}:${pass}`).digest('hex');
|
|
14
14
|
const HA2 = crypto.createHash('md5').update(`${method}:${uri}`).digest('hex');
|
|
15
15
|
const ncValue = ('00000000' + this.nonceCount.toString(16)).slice(-8);
|
|
16
16
|
let response;
|
|
17
|
-
if (digestItems['qop']) {
|
|
17
|
+
if (digestItems['qop'] !== undefined) {
|
|
18
18
|
response = crypto
|
|
19
19
|
.createHash('md5')
|
|
20
20
|
.update(`${HA1}:${digestItems['nonce']}:${ncValue}:162d50aa594e9648:auth:${HA2}`)
|
|
@@ -29,7 +29,7 @@ export class Digest {
|
|
|
29
29
|
`nonce="${digestItems['nonce']}",` +
|
|
30
30
|
`uri="${uri}",` +
|
|
31
31
|
`response="${response}"`;
|
|
32
|
-
if (digestItems['qop']) {
|
|
32
|
+
if (digestItems['qop'] !== undefined) {
|
|
33
33
|
header += `,qop=auth,nc=${ncValue},cnonce="162d50aa594e9648"`;
|
|
34
34
|
}
|
|
35
35
|
this.nonceCount++;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
post: (proxy: TProxyParam, path: string, data: string | Buffer | FormData, parameters?: TParameters, headers?: Record<string, string>) => Promise<import("./common").TResponse>;
|
|
1
|
+
import { IClient, TGetParams, TPostParams, TResponse } from './types';
|
|
2
|
+
import { TProxyParams } from '../types/common';
|
|
3
|
+
export declare class ProxyClient<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
4
|
+
private client;
|
|
5
|
+
private proxyParams;
|
|
6
|
+
constructor(client: Client, proxyParams: TProxyParams);
|
|
7
|
+
get: (params: TGetParams) => Promise<TResponse>;
|
|
8
|
+
post: (params: TPostParams) => Promise<TResponse>;
|
|
10
9
|
private getReal;
|
|
11
10
|
}
|
|
@@ -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
|
-
|
|
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 });
|
|
13
14
|
};
|
|
14
|
-
post = (
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
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 });
|
|
18
20
|
};
|
|
19
|
-
getReal = (
|
|
20
|
-
if (proxy !== null) {
|
|
21
|
-
return {
|
|
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
|
-
}
|
|
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,42 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Response as UndiciResponse } from 'undici';
|
|
4
|
+
export type Options = {
|
|
5
|
+
ip?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
user?: string;
|
|
8
|
+
pass?: string;
|
|
9
|
+
tls?: boolean;
|
|
10
|
+
tlsInsecure?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type HttpOptions = Options & {
|
|
13
|
+
keepAlive?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type WsOptions = Options;
|
|
16
|
+
export type TParameters = Record<string, string | number | boolean | null | undefined>;
|
|
17
|
+
export type TResponse = Response | UndiciResponse;
|
|
18
|
+
export type TGetParams = {
|
|
19
|
+
path: string;
|
|
20
|
+
parameters?: TParameters;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
timeout?: number;
|
|
23
|
+
};
|
|
24
|
+
export type TPostParams = {
|
|
25
|
+
path: string;
|
|
26
|
+
data: string | Buffer | FormData;
|
|
27
|
+
parameters?: TParameters;
|
|
28
|
+
headers?: Record<string, string>;
|
|
29
|
+
timeout?: number;
|
|
30
|
+
};
|
|
31
|
+
export interface IClient<TRes extends TResponse> {
|
|
32
|
+
get: (params: TGetParams) => Promise<TRes>;
|
|
33
|
+
post: (params: TPostParams) => Promise<TRes>;
|
|
34
|
+
}
|
|
35
|
+
export type TBlobResponse<Client extends IClient<TResponse>> = Awaited<ReturnType<Awaited<ReturnType<Client['get']>>['blob']>>;
|
|
36
|
+
export interface IWebsocket<Event extends {
|
|
37
|
+
readonly data: string;
|
|
38
|
+
}> {
|
|
39
|
+
destroy: () => void;
|
|
40
|
+
onmessage: null | ((event: Event) => void);
|
|
41
|
+
send: (data: string) => void;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/internal/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TPlaylistPlayType } from '../types/CamSwitcherAPI';
|
|
2
|
-
import { TParameters } from './
|
|
2
|
+
import { TParameters, TResponse } from './types';
|
|
3
3
|
export declare const addParametersToPath: (path: string, params?: TParameters) => string;
|
|
4
4
|
export declare const paramToUrl: (params?: TParameters) => string;
|
|
5
5
|
export declare const arrayToUrl: (arr: string | string[]) => string;
|
|
@@ -9,3 +9,6 @@ export declare const isClip: (id?: string) => boolean;
|
|
|
9
9
|
export declare const isTracker: (id?: string) => boolean;
|
|
10
10
|
export declare const isPlaylist: (id?: string) => boolean;
|
|
11
11
|
export declare const isLoopPlayType: (playType: TPlaylistPlayType) => boolean;
|
|
12
|
+
export declare function responseStringify(res: TResponse): Promise<string>;
|
|
13
|
+
export declare function pad(num: number, size: number): string;
|
|
14
|
+
export declare function isNullish<T>(value: T | undefined | null): value is undefined | null;
|
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
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const assertVersionString: (s: string, msg?: string) => void;
|
|
2
2
|
export declare const isFirmwareVersionAtLeast: (version: string, compareVersion: string) => boolean;
|
|
3
3
|
export declare const isVersionAtLeast: (version: string, compareVersion: string) => boolean;
|
|
4
|
-
export declare const firmwareVersionCompare: (a: string, b: string) =>
|
|
5
|
-
export declare const versionCompare: (a: string, b: string) =>
|
|
4
|
+
export declare const firmwareVersionCompare: (a: string, b: string) => 0 | 1 | -1;
|
|
5
|
+
export declare const versionCompare: (a: string, b: string) => 0 | 1 | -1;
|
|
6
6
|
export declare const fixVersionToDots: (version: string) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
export declare class DefaultClient implements IClient {
|
|
1
|
+
import { IClient, HttpOptions, TGetParams, TPostParams } from '../internal/types';
|
|
2
|
+
import { Response as UndiciResponse } from 'undici';
|
|
3
|
+
export declare class DefaultClient implements IClient<UndiciResponse> {
|
|
4
4
|
private tls;
|
|
5
5
|
private ip;
|
|
6
6
|
private port;
|
|
@@ -8,8 +8,7 @@ export declare class DefaultClient implements IClient {
|
|
|
8
8
|
private pass;
|
|
9
9
|
private httpRequestSender;
|
|
10
10
|
constructor(opt?: HttpOptions);
|
|
11
|
-
get
|
|
12
|
-
|
|
13
|
-
post(path: string, data: string | FormData | Buffer, parameters?: TParameters, headers?: Record<string, string>): Promise<import("undici").Response>;
|
|
11
|
+
get: (params: TGetParams) => Promise<UndiciResponse>;
|
|
12
|
+
post: (params: TPostParams) => Promise<UndiciResponse>;
|
|
14
13
|
private getBaseConnectionParams;
|
|
15
14
|
}
|
|
@@ -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
|
-
}
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
options
|
|
29
|
+
};
|
|
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
|
-
}
|
|
38
|
-
getBaseConnectionParams(method, path, params) {
|
|
39
|
-
let pathName = addParametersToPath(path, params);
|
|
34
|
+
};
|
|
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
|
}
|
|
@@ -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
package/esm/node/WsClient.d.ts
CHANGED
|
@@ -1,7 +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 { WsOptions } from '../internal/
|
|
5
|
+
import { WsOptions } from '../internal/types';
|
|
5
6
|
export type WsClientOptions = WsOptions & {
|
|
6
7
|
address: string;
|
|
7
8
|
headers?: Record<string, string>;
|
package/esm/node/index.d.ts
CHANGED
package/esm/node/index.js
CHANGED