camstreamerlib 4.0.0-beta.16 → 4.0.0-beta.17
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/cjs/PlaneTrackerAPI.d.ts +18 -8
- package/cjs/PlaneTrackerAPI.js +67 -17
- package/cjs/VapixAPI.d.ts +1 -1
- package/cjs/VapixAPI.js +21 -3
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +1 -0
- package/cjs/types/PlaneTrackerAPI.d.ts +2 -0
- package/cjs/types/PlaneTrackerAPI.js +2 -0
- package/cjs/types/VapixAPI.d.ts +44 -5
- package/cjs/types/VapixAPI.js +16 -2
- package/cjs/web/WsClient.js +2 -2
- package/esm/PlaneTrackerAPI.d.ts +18 -8
- package/esm/PlaneTrackerAPI.js +68 -18
- package/esm/VapixAPI.d.ts +1 -1
- package/esm/VapixAPI.js +22 -4
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/types/PlaneTrackerAPI.d.ts +2 -0
- package/esm/types/PlaneTrackerAPI.js +1 -0
- package/esm/types/VapixAPI.d.ts +44 -5
- package/esm/types/VapixAPI.js +15 -1
- package/esm/web/WsClient.js +2 -2
- package/package.json +1 -1
package/cjs/PlaneTrackerAPI.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { IClient, TResponse } from './internal/types';
|
|
1
|
+
import { IClient, TBlobResponse, TParameters, TResponse } from './internal/types';
|
|
2
|
+
import { TExportDataType, TImportDataType } from './types/PlaneTrackerAPI';
|
|
2
3
|
type ICAO = string;
|
|
3
4
|
export declare const BASE_URL = "/local/planetracker";
|
|
4
5
|
export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
@@ -7,24 +8,33 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient
|
|
|
7
8
|
static getProxyUrlPath: () => string;
|
|
8
9
|
checkCameraTime(): Promise<boolean>;
|
|
9
10
|
fetchCameraSettings: () => Promise<any>;
|
|
11
|
+
setCameraSettings: (settingsJsonString: string) => Promise<TResponse>;
|
|
10
12
|
fetchServerSettings: () => Promise<any>;
|
|
11
13
|
fetchMapInfo: () => Promise<any>;
|
|
12
14
|
fetchFlightInfo: (icao: ICAO) => Promise<any>;
|
|
13
15
|
getZones: () => Promise<any>;
|
|
14
|
-
setZones: (zonesJsonString: string) => Promise<
|
|
16
|
+
setZones: (zonesJsonString: string) => Promise<TResponse>;
|
|
15
17
|
getPriorityList: () => Promise<any>;
|
|
16
|
-
setPriorityList: (priorityListJsonString: string) => Promise<
|
|
18
|
+
setPriorityList: (priorityListJsonString: string) => Promise<TResponse>;
|
|
17
19
|
getWhiteList: () => Promise<any>;
|
|
18
|
-
setWhiteList: (whiteListJsonString: string) => Promise<
|
|
20
|
+
setWhiteList: (whiteListJsonString: string) => Promise<TResponse>;
|
|
19
21
|
getBlackList: () => Promise<any>;
|
|
20
|
-
setBlackList: (blackListJsonString: string) => Promise<
|
|
22
|
+
setBlackList: (blackListJsonString: string) => Promise<TResponse>;
|
|
21
23
|
getTrackingMode: () => Promise<any>;
|
|
22
|
-
setTrackingMode: (modeJsonString: string) => Promise<
|
|
24
|
+
setTrackingMode: (modeJsonString: string) => Promise<TResponse>;
|
|
23
25
|
startTrackingPlane: (icao: ICAO) => Promise<TResponse>;
|
|
24
26
|
stopTrackingPlane: () => Promise<TResponse>;
|
|
25
27
|
goToCoordinates: (lat: number, lon: number, alt?: number) => Promise<TResponse>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
exportAppSettings: (dataType: TExportDataType) => Promise<TBlobResponse<Client>>;
|
|
29
|
+
importAppSettings: (dataType: TImportDataType, formData: FormData) => Promise<TResponse>;
|
|
30
|
+
resetPtzCalibration: () => Promise<TResponse>;
|
|
31
|
+
checkGenetecConnection: (params: TParameters) => Promise<TResponse>;
|
|
32
|
+
getGenetecCameraList: (params: TParameters) => Promise<any>;
|
|
33
|
+
serverRunCheck: () => Promise<TResponse>;
|
|
34
|
+
private _getJson;
|
|
35
|
+
private _getBlob;
|
|
36
|
+
private parseBlobResponse;
|
|
28
37
|
private _postJsonEncoded;
|
|
38
|
+
private _postUrlEncoded;
|
|
29
39
|
}
|
|
30
40
|
export {};
|
package/cjs/PlaneTrackerAPI.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PlaneTrackerAPI = exports.BASE_URL = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const utils_1 = require("./internal/utils");
|
|
6
|
+
const errors_1 = require("./errors/errors");
|
|
6
7
|
exports.BASE_URL = '/local/planetracker';
|
|
7
8
|
class PlaneTrackerAPI {
|
|
8
9
|
client;
|
|
@@ -27,7 +28,7 @@ class PlaneTrackerAPI {
|
|
|
27
28
|
message: zod_1.z.string(),
|
|
28
29
|
}),
|
|
29
30
|
]);
|
|
30
|
-
const response = await this.
|
|
31
|
+
const response = await this._getJson(`${exports.BASE_URL}/camera_time.cgi`);
|
|
31
32
|
const cameraTime = responseSchema.parse(response);
|
|
32
33
|
if (!cameraTime.state) {
|
|
33
34
|
console.error(`Camera time check failed: ${cameraTime.reason} - ${cameraTime.message}`);
|
|
@@ -35,49 +36,54 @@ class PlaneTrackerAPI {
|
|
|
35
36
|
return cameraTime.state;
|
|
36
37
|
}
|
|
37
38
|
fetchCameraSettings = async () => {
|
|
38
|
-
return await this.
|
|
39
|
+
return await this._getJson(`${exports.BASE_URL}/package_camera_settings.cgi`, { action: 'get' });
|
|
40
|
+
};
|
|
41
|
+
setCameraSettings = async (settingsJsonString) => {
|
|
42
|
+
return await this._postJsonEncoded(`${exports.BASE_URL}/package_camera_settings.cgi`, settingsJsonString, {
|
|
43
|
+
action: 'set',
|
|
44
|
+
});
|
|
39
45
|
};
|
|
40
46
|
fetchServerSettings = async () => {
|
|
41
|
-
return await this.
|
|
47
|
+
return await this._getJson(`${exports.BASE_URL}/package_server_settings.cgi`, { action: 'get' });
|
|
42
48
|
};
|
|
43
49
|
fetchMapInfo = async () => {
|
|
44
|
-
return await this.
|
|
50
|
+
return await this._getJson(`${exports.BASE_URL}/package/getMapInfo.cgi`);
|
|
45
51
|
};
|
|
46
52
|
fetchFlightInfo = async (icao) => {
|
|
47
|
-
return await this.
|
|
53
|
+
return await this._getJson(`${exports.BASE_URL}/package/flightInfo.cgi`, { icao });
|
|
48
54
|
};
|
|
49
55
|
getZones = async () => {
|
|
50
|
-
return await this.
|
|
56
|
+
return await this._getJson(`${exports.BASE_URL}/package/getZones.cgi`);
|
|
51
57
|
};
|
|
52
58
|
setZones = async (zonesJsonString) => {
|
|
53
59
|
return await this._postJsonEncoded(`${exports.BASE_URL}/package/setZones.cgi`, zonesJsonString);
|
|
54
60
|
};
|
|
55
61
|
getPriorityList = async () => {
|
|
56
|
-
return await this.
|
|
62
|
+
return await this._getJson(`${exports.BASE_URL}/package/getPriorityList.cgi`);
|
|
57
63
|
};
|
|
58
64
|
setPriorityList = async (priorityListJsonString) => {
|
|
59
65
|
return await this._postJsonEncoded(`${exports.BASE_URL}/package/setPriorityList.cgi`, priorityListJsonString);
|
|
60
66
|
};
|
|
61
67
|
getWhiteList = async () => {
|
|
62
|
-
return await this.
|
|
68
|
+
return await this._getJson(`${exports.BASE_URL}/package/getWhiteList.cgi`);
|
|
63
69
|
};
|
|
64
70
|
setWhiteList = async (whiteListJsonString) => {
|
|
65
71
|
return await this._postJsonEncoded(`${exports.BASE_URL}/package/setWhiteList.cgi`, whiteListJsonString);
|
|
66
72
|
};
|
|
67
73
|
getBlackList = async () => {
|
|
68
|
-
return await this.
|
|
74
|
+
return await this._getJson(`${exports.BASE_URL}/package/getBlackList.cgi`);
|
|
69
75
|
};
|
|
70
76
|
setBlackList = async (blackListJsonString) => {
|
|
71
77
|
return await this._postJsonEncoded(`${exports.BASE_URL}/package/setBlackList.cgi`, blackListJsonString);
|
|
72
78
|
};
|
|
73
79
|
getTrackingMode = async () => {
|
|
74
|
-
return await this.
|
|
80
|
+
return await this._getJson(`${exports.BASE_URL}/package/getTrackingMode.cgi`);
|
|
75
81
|
};
|
|
76
82
|
setTrackingMode = async (modeJsonString) => {
|
|
77
83
|
return await this._postJsonEncoded(`${exports.BASE_URL}/package/setTrackingMode.cgi`, modeJsonString);
|
|
78
84
|
};
|
|
79
85
|
startTrackingPlane = async (icao) => {
|
|
80
|
-
return await this.client.get(`${exports.BASE_URL}/package/trackIcao.cgi
|
|
86
|
+
return await this.client.get(`${exports.BASE_URL}/package/trackIcao.cgi`, { icao });
|
|
81
87
|
};
|
|
82
88
|
stopTrackingPlane = async () => {
|
|
83
89
|
return await this.client.get(`${exports.BASE_URL}/package/resetIcao.cgi`);
|
|
@@ -86,28 +92,72 @@ class PlaneTrackerAPI {
|
|
|
86
92
|
const url = `${exports.BASE_URL}/package/goToCoordinates.cgi?lat=${lat}&lon=${lon}`;
|
|
87
93
|
return await this.client.get(`${url}${alt !== undefined ? `&alt=${alt}` : ''}`);
|
|
88
94
|
};
|
|
89
|
-
async
|
|
95
|
+
exportAppSettings = async (dataType) => {
|
|
96
|
+
return await this._getBlob(`${exports.BASE_URL}/package_data.cgi`, { action: 'EXPORT', dataType });
|
|
97
|
+
};
|
|
98
|
+
importAppSettings = async (dataType, formData) => {
|
|
99
|
+
return await this.client.post(`${exports.BASE_URL}/package_data.cgi`, formData, { action: 'IMPORT', dataType });
|
|
100
|
+
};
|
|
101
|
+
resetPtzCalibration = async () => {
|
|
102
|
+
return await this.client.get(`${exports.BASE_URL}/package/resetPtzCalibration.cgi`);
|
|
103
|
+
};
|
|
104
|
+
checkGenetecConnection = async (params) => {
|
|
105
|
+
return await this._postUrlEncoded(`${exports.BASE_URL}/package/checkGenetecConnection.cgi`, params);
|
|
106
|
+
};
|
|
107
|
+
getGenetecCameraList = async (params) => {
|
|
108
|
+
const res = await this._postUrlEncoded(`${exports.BASE_URL}/package/getGenetecCameraList.cgi`, params);
|
|
109
|
+
return await res.json();
|
|
110
|
+
};
|
|
111
|
+
serverRunCheck = async () => {
|
|
112
|
+
return await this.client.get(`${exports.BASE_URL}/package/serverRunCheck.cgi`);
|
|
113
|
+
};
|
|
114
|
+
async _getJson(...args) {
|
|
90
115
|
const res = await this.client.get(...args);
|
|
91
116
|
if (res.ok) {
|
|
92
|
-
return
|
|
117
|
+
return await res.json();
|
|
93
118
|
}
|
|
94
119
|
else {
|
|
95
120
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
96
121
|
}
|
|
97
122
|
}
|
|
98
|
-
async
|
|
99
|
-
const res = await this.client.
|
|
123
|
+
async _getBlob(...args) {
|
|
124
|
+
const res = await this.client.get(...args);
|
|
100
125
|
if (res.ok) {
|
|
101
|
-
return
|
|
126
|
+
return await this.parseBlobResponse(res);
|
|
102
127
|
}
|
|
103
128
|
else {
|
|
104
129
|
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
105
130
|
}
|
|
106
131
|
}
|
|
132
|
+
async parseBlobResponse(response) {
|
|
133
|
+
try {
|
|
134
|
+
return (await response.blob());
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
throw new errors_1.ParsingBlobError(err);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
107
140
|
async _postJsonEncoded(...args) {
|
|
108
141
|
const [path, data, params, headers] = args;
|
|
109
142
|
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
110
|
-
|
|
143
|
+
const res = await this.client.post(path, data, params, { ...baseHeaders, ...headers });
|
|
144
|
+
if (res.ok) {
|
|
145
|
+
return res;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async _postUrlEncoded(path, params, headers) {
|
|
152
|
+
const data = (0, utils_1.paramToUrl)(params);
|
|
153
|
+
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
154
|
+
const res = await this.client.post(path, data, {}, { ...baseHeaders, ...headers });
|
|
155
|
+
if (res.ok) {
|
|
156
|
+
return res;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
160
|
+
}
|
|
111
161
|
}
|
|
112
162
|
}
|
|
113
163
|
exports.PlaneTrackerAPI = PlaneTrackerAPI;
|
package/cjs/VapixAPI.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare class VapixAPI<Client extends IClient<TResponse> = IClient<TRespo
|
|
|
26
26
|
dstEnabled: boolean;
|
|
27
27
|
localDateTime: string;
|
|
28
28
|
posixTimeZone: string;
|
|
29
|
-
timeZone
|
|
29
|
+
timeZone?: string | undefined;
|
|
30
30
|
};
|
|
31
31
|
}>;
|
|
32
32
|
getDevicesSettings(proxy?: TProxyParam): Promise<TAudioDevice[]>;
|
package/cjs/VapixAPI.js
CHANGED
|
@@ -171,9 +171,27 @@ class VapixAPI {
|
|
|
171
171
|
return captureMode.maxFPS;
|
|
172
172
|
}
|
|
173
173
|
async getTimezone(proxy = null) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
try {
|
|
175
|
+
const resV2 = await this.client.get(proxy, '/config/rest/time/v2/timeZone');
|
|
176
|
+
if (!resV2.ok) {
|
|
177
|
+
throw new Error(await (0, utils_1.responseStringify)(resV2));
|
|
178
|
+
}
|
|
179
|
+
const json = await resV2.json();
|
|
180
|
+
const data = VapixAPI_1.timeZoneSchema.parse(json);
|
|
181
|
+
if (data.status === 'error') {
|
|
182
|
+
throw new Error(data.error.message);
|
|
183
|
+
}
|
|
184
|
+
return data.data.activeTimeZone;
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : JSON.stringify(error));
|
|
188
|
+
console.warn('Falling back to deprecated time API v1');
|
|
189
|
+
}
|
|
190
|
+
const data = await this.getDateTimeInfo(proxy);
|
|
191
|
+
if (data.data.timeZone === undefined) {
|
|
192
|
+
throw new Error('Time zone not setup on the device');
|
|
193
|
+
}
|
|
194
|
+
return data.data.timeZone;
|
|
177
195
|
}
|
|
178
196
|
async getDateTimeInfo(proxy = null) {
|
|
179
197
|
const data = { apiVersion: '1.0', method: 'getDateTimeInfo' };
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -39,3 +39,4 @@ __exportStar(require("./types/CamSwitcherAPI"), exports);
|
|
|
39
39
|
__exportStar(require("./types/VapixAPI"), exports);
|
|
40
40
|
__exportStar(require("./types/CamOverlayAPI"), exports);
|
|
41
41
|
__exportStar(require("./models/CamOverlayAPI"), exports);
|
|
42
|
+
__exportStar(require("./types/PlaneTrackerAPI"), exports);
|
package/cjs/types/VapixAPI.d.ts
CHANGED
|
@@ -1499,19 +1499,19 @@ export declare const dateTimeinfoSchema: z.ZodObject<{
|
|
|
1499
1499
|
dstEnabled: z.ZodBoolean;
|
|
1500
1500
|
localDateTime: z.ZodString;
|
|
1501
1501
|
posixTimeZone: z.ZodString;
|
|
1502
|
-
timeZone: z.ZodString
|
|
1502
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
1503
1503
|
}, "strip", z.ZodTypeAny, {
|
|
1504
1504
|
dateTime: string;
|
|
1505
1505
|
dstEnabled: boolean;
|
|
1506
1506
|
localDateTime: string;
|
|
1507
1507
|
posixTimeZone: string;
|
|
1508
|
-
timeZone
|
|
1508
|
+
timeZone?: string | undefined;
|
|
1509
1509
|
}, {
|
|
1510
1510
|
dateTime: string;
|
|
1511
1511
|
dstEnabled: boolean;
|
|
1512
1512
|
localDateTime: string;
|
|
1513
1513
|
posixTimeZone: string;
|
|
1514
|
-
timeZone
|
|
1514
|
+
timeZone?: string | undefined;
|
|
1515
1515
|
}>;
|
|
1516
1516
|
}, "strip", z.ZodTypeAny, {
|
|
1517
1517
|
data: {
|
|
@@ -1519,7 +1519,7 @@ export declare const dateTimeinfoSchema: z.ZodObject<{
|
|
|
1519
1519
|
dstEnabled: boolean;
|
|
1520
1520
|
localDateTime: string;
|
|
1521
1521
|
posixTimeZone: string;
|
|
1522
|
-
timeZone
|
|
1522
|
+
timeZone?: string | undefined;
|
|
1523
1523
|
};
|
|
1524
1524
|
}, {
|
|
1525
1525
|
data: {
|
|
@@ -1527,9 +1527,48 @@ export declare const dateTimeinfoSchema: z.ZodObject<{
|
|
|
1527
1527
|
dstEnabled: boolean;
|
|
1528
1528
|
localDateTime: string;
|
|
1529
1529
|
posixTimeZone: string;
|
|
1530
|
-
timeZone
|
|
1530
|
+
timeZone?: string | undefined;
|
|
1531
1531
|
};
|
|
1532
1532
|
}>;
|
|
1533
|
+
export declare const timeZoneSchema: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
|
|
1534
|
+
status: z.ZodLiteral<"success">;
|
|
1535
|
+
data: z.ZodObject<{
|
|
1536
|
+
activeTimeZone: z.ZodString;
|
|
1537
|
+
}, "strip", z.ZodTypeAny, {
|
|
1538
|
+
activeTimeZone: string;
|
|
1539
|
+
}, {
|
|
1540
|
+
activeTimeZone: string;
|
|
1541
|
+
}>;
|
|
1542
|
+
}, "strip", z.ZodTypeAny, {
|
|
1543
|
+
status: "success";
|
|
1544
|
+
data: {
|
|
1545
|
+
activeTimeZone: string;
|
|
1546
|
+
};
|
|
1547
|
+
}, {
|
|
1548
|
+
status: "success";
|
|
1549
|
+
data: {
|
|
1550
|
+
activeTimeZone: string;
|
|
1551
|
+
};
|
|
1552
|
+
}>, z.ZodObject<{
|
|
1553
|
+
status: z.ZodLiteral<"error">;
|
|
1554
|
+
error: z.ZodObject<{
|
|
1555
|
+
message: z.ZodString;
|
|
1556
|
+
}, "strip", z.ZodTypeAny, {
|
|
1557
|
+
message: string;
|
|
1558
|
+
}, {
|
|
1559
|
+
message: string;
|
|
1560
|
+
}>;
|
|
1561
|
+
}, "strip", z.ZodTypeAny, {
|
|
1562
|
+
status: "error";
|
|
1563
|
+
error: {
|
|
1564
|
+
message: string;
|
|
1565
|
+
};
|
|
1566
|
+
}, {
|
|
1567
|
+
status: "error";
|
|
1568
|
+
error: {
|
|
1569
|
+
message: string;
|
|
1570
|
+
};
|
|
1571
|
+
}>]>;
|
|
1533
1572
|
export declare const audioSampleRatesResponseSchema: z.ZodObject<{
|
|
1534
1573
|
data: z.ZodObject<{
|
|
1535
1574
|
encoders: z.ZodObject<{
|
package/cjs/types/VapixAPI.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.audioSampleRatesResponseSchema = exports.dateTimeinfoSchema = exports.maxFpsResponseSchema = exports.audioDeviceRequestSchema = exports.audioDeviceSchema = exports.audioDeviceInputOutputSchema = exports.audioDeviceConnectionTypeSchema = exports.audioDeviceSignalingTypeSchema = exports.audioDeviceSignalingChannelTypeSchema = exports.cameraPTZItemSchema = exports.cameraPTZItemDataSchema = exports.PtzOverviewSchema = exports.sdCardWatchedStatuses = exports.guardTourSchema = exports.APP_IDS = exports.applicationSchema = void 0;
|
|
3
|
+
exports.audioSampleRatesResponseSchema = exports.timeZoneSchema = exports.dateTimeinfoSchema = exports.maxFpsResponseSchema = exports.audioDeviceRequestSchema = exports.audioDeviceSchema = exports.audioDeviceInputOutputSchema = exports.audioDeviceConnectionTypeSchema = exports.audioDeviceSignalingTypeSchema = exports.audioDeviceSignalingChannelTypeSchema = exports.cameraPTZItemSchema = exports.cameraPTZItemDataSchema = exports.PtzOverviewSchema = exports.sdCardWatchedStatuses = exports.guardTourSchema = exports.APP_IDS = exports.applicationSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const transformers_1 = require("../internal/transformers");
|
|
6
6
|
exports.applicationSchema = zod_1.z.object({
|
|
@@ -110,9 +110,23 @@ exports.dateTimeinfoSchema = zod_1.z.object({
|
|
|
110
110
|
dstEnabled: zod_1.z.boolean(),
|
|
111
111
|
localDateTime: zod_1.z.string(),
|
|
112
112
|
posixTimeZone: zod_1.z.string(),
|
|
113
|
-
timeZone: zod_1.z.string(),
|
|
113
|
+
timeZone: zod_1.z.string().optional(),
|
|
114
114
|
}),
|
|
115
115
|
});
|
|
116
|
+
exports.timeZoneSchema = zod_1.z.discriminatedUnion('status', [
|
|
117
|
+
zod_1.z.object({
|
|
118
|
+
status: zod_1.z.literal('success'),
|
|
119
|
+
data: zod_1.z.object({
|
|
120
|
+
activeTimeZone: zod_1.z.string(),
|
|
121
|
+
}),
|
|
122
|
+
}),
|
|
123
|
+
zod_1.z.object({
|
|
124
|
+
status: zod_1.z.literal('error'),
|
|
125
|
+
error: zod_1.z.object({
|
|
126
|
+
message: zod_1.z.string(),
|
|
127
|
+
}),
|
|
128
|
+
}),
|
|
129
|
+
]);
|
|
116
130
|
exports.audioSampleRatesResponseSchema = zod_1.z.object({
|
|
117
131
|
data: zod_1.z.object({
|
|
118
132
|
encoders: zod_1.z
|
package/cjs/web/WsClient.js
CHANGED
|
@@ -30,7 +30,7 @@ class WsClient {
|
|
|
30
30
|
};
|
|
31
31
|
ws.onmessage = (e) => this.onmessage(e);
|
|
32
32
|
ws.onclose = () => {
|
|
33
|
-
this.restartTimeout = setTimeout(() => this.init(), REFRESH_TIMEOUT);
|
|
33
|
+
this.restartTimeout = window.setTimeout(() => this.init(), REFRESH_TIMEOUT);
|
|
34
34
|
};
|
|
35
35
|
this.ws = ws;
|
|
36
36
|
}
|
|
@@ -43,7 +43,7 @@ class WsClient {
|
|
|
43
43
|
this.destroyWebsocket();
|
|
44
44
|
};
|
|
45
45
|
destroyWebsocket() {
|
|
46
|
-
if (this.restartTimeout) {
|
|
46
|
+
if (this.restartTimeout !== null) {
|
|
47
47
|
clearTimeout(this.restartTimeout);
|
|
48
48
|
this.restartTimeout = null;
|
|
49
49
|
}
|
package/esm/PlaneTrackerAPI.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { IClient, TResponse } from './internal/types';
|
|
1
|
+
import { IClient, TBlobResponse, TParameters, TResponse } from './internal/types';
|
|
2
|
+
import { TExportDataType, TImportDataType } from './types/PlaneTrackerAPI';
|
|
2
3
|
type ICAO = string;
|
|
3
4
|
export declare const BASE_URL = "/local/planetracker";
|
|
4
5
|
export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
@@ -7,24 +8,33 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient
|
|
|
7
8
|
static getProxyUrlPath: () => string;
|
|
8
9
|
checkCameraTime(): Promise<boolean>;
|
|
9
10
|
fetchCameraSettings: () => Promise<any>;
|
|
11
|
+
setCameraSettings: (settingsJsonString: string) => Promise<TResponse>;
|
|
10
12
|
fetchServerSettings: () => Promise<any>;
|
|
11
13
|
fetchMapInfo: () => Promise<any>;
|
|
12
14
|
fetchFlightInfo: (icao: ICAO) => Promise<any>;
|
|
13
15
|
getZones: () => Promise<any>;
|
|
14
|
-
setZones: (zonesJsonString: string) => Promise<
|
|
16
|
+
setZones: (zonesJsonString: string) => Promise<TResponse>;
|
|
15
17
|
getPriorityList: () => Promise<any>;
|
|
16
|
-
setPriorityList: (priorityListJsonString: string) => Promise<
|
|
18
|
+
setPriorityList: (priorityListJsonString: string) => Promise<TResponse>;
|
|
17
19
|
getWhiteList: () => Promise<any>;
|
|
18
|
-
setWhiteList: (whiteListJsonString: string) => Promise<
|
|
20
|
+
setWhiteList: (whiteListJsonString: string) => Promise<TResponse>;
|
|
19
21
|
getBlackList: () => Promise<any>;
|
|
20
|
-
setBlackList: (blackListJsonString: string) => Promise<
|
|
22
|
+
setBlackList: (blackListJsonString: string) => Promise<TResponse>;
|
|
21
23
|
getTrackingMode: () => Promise<any>;
|
|
22
|
-
setTrackingMode: (modeJsonString: string) => Promise<
|
|
24
|
+
setTrackingMode: (modeJsonString: string) => Promise<TResponse>;
|
|
23
25
|
startTrackingPlane: (icao: ICAO) => Promise<TResponse>;
|
|
24
26
|
stopTrackingPlane: () => Promise<TResponse>;
|
|
25
27
|
goToCoordinates: (lat: number, lon: number, alt?: number) => Promise<TResponse>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
exportAppSettings: (dataType: TExportDataType) => Promise<TBlobResponse<Client>>;
|
|
29
|
+
importAppSettings: (dataType: TImportDataType, formData: FormData) => Promise<TResponse>;
|
|
30
|
+
resetPtzCalibration: () => Promise<TResponse>;
|
|
31
|
+
checkGenetecConnection: (params: TParameters) => Promise<TResponse>;
|
|
32
|
+
getGenetecCameraList: (params: TParameters) => Promise<any>;
|
|
33
|
+
serverRunCheck: () => Promise<TResponse>;
|
|
34
|
+
private _getJson;
|
|
35
|
+
private _getBlob;
|
|
36
|
+
private parseBlobResponse;
|
|
28
37
|
private _postJsonEncoded;
|
|
38
|
+
private _postUrlEncoded;
|
|
29
39
|
}
|
|
30
40
|
export {};
|
package/esm/PlaneTrackerAPI.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { responseStringify } from './internal/utils';
|
|
2
|
+
import { paramToUrl, responseStringify } from './internal/utils';
|
|
3
|
+
import { ParsingBlobError } from './errors/errors';
|
|
3
4
|
export const BASE_URL = '/local/planetracker';
|
|
4
5
|
export class PlaneTrackerAPI {
|
|
5
6
|
client;
|
|
@@ -24,7 +25,7 @@ export class PlaneTrackerAPI {
|
|
|
24
25
|
message: z.string(),
|
|
25
26
|
}),
|
|
26
27
|
]);
|
|
27
|
-
const response = await this.
|
|
28
|
+
const response = await this._getJson(`${BASE_URL}/camera_time.cgi`);
|
|
28
29
|
const cameraTime = responseSchema.parse(response);
|
|
29
30
|
if (!cameraTime.state) {
|
|
30
31
|
console.error(`Camera time check failed: ${cameraTime.reason} - ${cameraTime.message}`);
|
|
@@ -32,49 +33,54 @@ export class PlaneTrackerAPI {
|
|
|
32
33
|
return cameraTime.state;
|
|
33
34
|
}
|
|
34
35
|
fetchCameraSettings = async () => {
|
|
35
|
-
return await this.
|
|
36
|
+
return await this._getJson(`${BASE_URL}/package_camera_settings.cgi`, { action: 'get' });
|
|
37
|
+
};
|
|
38
|
+
setCameraSettings = async (settingsJsonString) => {
|
|
39
|
+
return await this._postJsonEncoded(`${BASE_URL}/package_camera_settings.cgi`, settingsJsonString, {
|
|
40
|
+
action: 'set',
|
|
41
|
+
});
|
|
36
42
|
};
|
|
37
43
|
fetchServerSettings = async () => {
|
|
38
|
-
return await this.
|
|
44
|
+
return await this._getJson(`${BASE_URL}/package_server_settings.cgi`, { action: 'get' });
|
|
39
45
|
};
|
|
40
46
|
fetchMapInfo = async () => {
|
|
41
|
-
return await this.
|
|
47
|
+
return await this._getJson(`${BASE_URL}/package/getMapInfo.cgi`);
|
|
42
48
|
};
|
|
43
49
|
fetchFlightInfo = async (icao) => {
|
|
44
|
-
return await this.
|
|
50
|
+
return await this._getJson(`${BASE_URL}/package/flightInfo.cgi`, { icao });
|
|
45
51
|
};
|
|
46
52
|
getZones = async () => {
|
|
47
|
-
return await this.
|
|
53
|
+
return await this._getJson(`${BASE_URL}/package/getZones.cgi`);
|
|
48
54
|
};
|
|
49
55
|
setZones = async (zonesJsonString) => {
|
|
50
56
|
return await this._postJsonEncoded(`${BASE_URL}/package/setZones.cgi`, zonesJsonString);
|
|
51
57
|
};
|
|
52
58
|
getPriorityList = async () => {
|
|
53
|
-
return await this.
|
|
59
|
+
return await this._getJson(`${BASE_URL}/package/getPriorityList.cgi`);
|
|
54
60
|
};
|
|
55
61
|
setPriorityList = async (priorityListJsonString) => {
|
|
56
62
|
return await this._postJsonEncoded(`${BASE_URL}/package/setPriorityList.cgi`, priorityListJsonString);
|
|
57
63
|
};
|
|
58
64
|
getWhiteList = async () => {
|
|
59
|
-
return await this.
|
|
65
|
+
return await this._getJson(`${BASE_URL}/package/getWhiteList.cgi`);
|
|
60
66
|
};
|
|
61
67
|
setWhiteList = async (whiteListJsonString) => {
|
|
62
68
|
return await this._postJsonEncoded(`${BASE_URL}/package/setWhiteList.cgi`, whiteListJsonString);
|
|
63
69
|
};
|
|
64
70
|
getBlackList = async () => {
|
|
65
|
-
return await this.
|
|
71
|
+
return await this._getJson(`${BASE_URL}/package/getBlackList.cgi`);
|
|
66
72
|
};
|
|
67
73
|
setBlackList = async (blackListJsonString) => {
|
|
68
74
|
return await this._postJsonEncoded(`${BASE_URL}/package/setBlackList.cgi`, blackListJsonString);
|
|
69
75
|
};
|
|
70
76
|
getTrackingMode = async () => {
|
|
71
|
-
return await this.
|
|
77
|
+
return await this._getJson(`${BASE_URL}/package/getTrackingMode.cgi`);
|
|
72
78
|
};
|
|
73
79
|
setTrackingMode = async (modeJsonString) => {
|
|
74
80
|
return await this._postJsonEncoded(`${BASE_URL}/package/setTrackingMode.cgi`, modeJsonString);
|
|
75
81
|
};
|
|
76
82
|
startTrackingPlane = async (icao) => {
|
|
77
|
-
return await this.client.get(`${BASE_URL}/package/trackIcao.cgi
|
|
83
|
+
return await this.client.get(`${BASE_URL}/package/trackIcao.cgi`, { icao });
|
|
78
84
|
};
|
|
79
85
|
stopTrackingPlane = async () => {
|
|
80
86
|
return await this.client.get(`${BASE_URL}/package/resetIcao.cgi`);
|
|
@@ -83,27 +89,71 @@ export class PlaneTrackerAPI {
|
|
|
83
89
|
const url = `${BASE_URL}/package/goToCoordinates.cgi?lat=${lat}&lon=${lon}`;
|
|
84
90
|
return await this.client.get(`${url}${alt !== undefined ? `&alt=${alt}` : ''}`);
|
|
85
91
|
};
|
|
86
|
-
async
|
|
92
|
+
exportAppSettings = async (dataType) => {
|
|
93
|
+
return await this._getBlob(`${BASE_URL}/package_data.cgi`, { action: 'EXPORT', dataType });
|
|
94
|
+
};
|
|
95
|
+
importAppSettings = async (dataType, formData) => {
|
|
96
|
+
return await this.client.post(`${BASE_URL}/package_data.cgi`, formData, { action: 'IMPORT', dataType });
|
|
97
|
+
};
|
|
98
|
+
resetPtzCalibration = async () => {
|
|
99
|
+
return await this.client.get(`${BASE_URL}/package/resetPtzCalibration.cgi`);
|
|
100
|
+
};
|
|
101
|
+
checkGenetecConnection = async (params) => {
|
|
102
|
+
return await this._postUrlEncoded(`${BASE_URL}/package/checkGenetecConnection.cgi`, params);
|
|
103
|
+
};
|
|
104
|
+
getGenetecCameraList = async (params) => {
|
|
105
|
+
const res = await this._postUrlEncoded(`${BASE_URL}/package/getGenetecCameraList.cgi`, params);
|
|
106
|
+
return await res.json();
|
|
107
|
+
};
|
|
108
|
+
serverRunCheck = async () => {
|
|
109
|
+
return await this.client.get(`${BASE_URL}/package/serverRunCheck.cgi`);
|
|
110
|
+
};
|
|
111
|
+
async _getJson(...args) {
|
|
87
112
|
const res = await this.client.get(...args);
|
|
88
113
|
if (res.ok) {
|
|
89
|
-
return
|
|
114
|
+
return await res.json();
|
|
90
115
|
}
|
|
91
116
|
else {
|
|
92
117
|
throw new Error(await responseStringify(res));
|
|
93
118
|
}
|
|
94
119
|
}
|
|
95
|
-
async
|
|
96
|
-
const res = await this.client.
|
|
120
|
+
async _getBlob(...args) {
|
|
121
|
+
const res = await this.client.get(...args);
|
|
97
122
|
if (res.ok) {
|
|
98
|
-
return
|
|
123
|
+
return await this.parseBlobResponse(res);
|
|
99
124
|
}
|
|
100
125
|
else {
|
|
101
126
|
throw new Error(await responseStringify(res));
|
|
102
127
|
}
|
|
103
128
|
}
|
|
129
|
+
async parseBlobResponse(response) {
|
|
130
|
+
try {
|
|
131
|
+
return (await response.blob());
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
throw new ParsingBlobError(err);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
104
137
|
async _postJsonEncoded(...args) {
|
|
105
138
|
const [path, data, params, headers] = args;
|
|
106
139
|
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
107
|
-
|
|
140
|
+
const res = await this.client.post(path, data, params, { ...baseHeaders, ...headers });
|
|
141
|
+
if (res.ok) {
|
|
142
|
+
return res;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
throw new Error(await responseStringify(res));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async _postUrlEncoded(path, params, headers) {
|
|
149
|
+
const data = paramToUrl(params);
|
|
150
|
+
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
151
|
+
const res = await this.client.post(path, data, {}, { ...baseHeaders, ...headers });
|
|
152
|
+
if (res.ok) {
|
|
153
|
+
return res;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
throw new Error(await responseStringify(res));
|
|
157
|
+
}
|
|
108
158
|
}
|
|
109
159
|
}
|
package/esm/VapixAPI.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare class VapixAPI<Client extends IClient<TResponse> = IClient<TRespo
|
|
|
26
26
|
dstEnabled: boolean;
|
|
27
27
|
localDateTime: string;
|
|
28
28
|
posixTimeZone: string;
|
|
29
|
-
timeZone
|
|
29
|
+
timeZone?: string | undefined;
|
|
30
30
|
};
|
|
31
31
|
}>;
|
|
32
32
|
getDevicesSettings(proxy?: TProxyParam): Promise<TAudioDevice[]>;
|
package/esm/VapixAPI.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as prettifyXml from 'prettify-xml';
|
|
2
2
|
import { arrayToUrl, isNullish, paramToUrl, responseStringify } from './internal/utils';
|
|
3
|
-
import { sdCardWatchedStatuses, APP_IDS, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, } from './types/VapixAPI';
|
|
3
|
+
import { sdCardWatchedStatuses, APP_IDS, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, timeZoneSchema, } from './types/VapixAPI';
|
|
4
4
|
import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, SDCardActionError, SDCardJobError, } from './errors/errors';
|
|
5
5
|
import { ProxyClient } from './internal/ProxyClient';
|
|
6
6
|
import { z } from 'zod';
|
|
@@ -168,9 +168,27 @@ export class VapixAPI {
|
|
|
168
168
|
return captureMode.maxFPS;
|
|
169
169
|
}
|
|
170
170
|
async getTimezone(proxy = null) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
try {
|
|
172
|
+
const resV2 = await this.client.get(proxy, '/config/rest/time/v2/timeZone');
|
|
173
|
+
if (!resV2.ok) {
|
|
174
|
+
throw new Error(await responseStringify(resV2));
|
|
175
|
+
}
|
|
176
|
+
const json = await resV2.json();
|
|
177
|
+
const data = timeZoneSchema.parse(json);
|
|
178
|
+
if (data.status === 'error') {
|
|
179
|
+
throw new Error(data.error.message);
|
|
180
|
+
}
|
|
181
|
+
return data.data.activeTimeZone;
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : JSON.stringify(error));
|
|
185
|
+
console.warn('Falling back to deprecated time API v1');
|
|
186
|
+
}
|
|
187
|
+
const data = await this.getDateTimeInfo(proxy);
|
|
188
|
+
if (data.data.timeZone === undefined) {
|
|
189
|
+
throw new Error('Time zone not setup on the device');
|
|
190
|
+
}
|
|
191
|
+
return data.data.timeZone;
|
|
174
192
|
}
|
|
175
193
|
async getDateTimeInfo(proxy = null) {
|
|
176
194
|
const data = { apiVersion: '1.0', method: 'getDateTimeInfo' };
|
package/esm/index.d.ts
CHANGED
package/esm/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/types/VapixAPI.d.ts
CHANGED
|
@@ -1499,19 +1499,19 @@ export declare const dateTimeinfoSchema: z.ZodObject<{
|
|
|
1499
1499
|
dstEnabled: z.ZodBoolean;
|
|
1500
1500
|
localDateTime: z.ZodString;
|
|
1501
1501
|
posixTimeZone: z.ZodString;
|
|
1502
|
-
timeZone: z.ZodString
|
|
1502
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
1503
1503
|
}, "strip", z.ZodTypeAny, {
|
|
1504
1504
|
dateTime: string;
|
|
1505
1505
|
dstEnabled: boolean;
|
|
1506
1506
|
localDateTime: string;
|
|
1507
1507
|
posixTimeZone: string;
|
|
1508
|
-
timeZone
|
|
1508
|
+
timeZone?: string | undefined;
|
|
1509
1509
|
}, {
|
|
1510
1510
|
dateTime: string;
|
|
1511
1511
|
dstEnabled: boolean;
|
|
1512
1512
|
localDateTime: string;
|
|
1513
1513
|
posixTimeZone: string;
|
|
1514
|
-
timeZone
|
|
1514
|
+
timeZone?: string | undefined;
|
|
1515
1515
|
}>;
|
|
1516
1516
|
}, "strip", z.ZodTypeAny, {
|
|
1517
1517
|
data: {
|
|
@@ -1519,7 +1519,7 @@ export declare const dateTimeinfoSchema: z.ZodObject<{
|
|
|
1519
1519
|
dstEnabled: boolean;
|
|
1520
1520
|
localDateTime: string;
|
|
1521
1521
|
posixTimeZone: string;
|
|
1522
|
-
timeZone
|
|
1522
|
+
timeZone?: string | undefined;
|
|
1523
1523
|
};
|
|
1524
1524
|
}, {
|
|
1525
1525
|
data: {
|
|
@@ -1527,9 +1527,48 @@ export declare const dateTimeinfoSchema: z.ZodObject<{
|
|
|
1527
1527
|
dstEnabled: boolean;
|
|
1528
1528
|
localDateTime: string;
|
|
1529
1529
|
posixTimeZone: string;
|
|
1530
|
-
timeZone
|
|
1530
|
+
timeZone?: string | undefined;
|
|
1531
1531
|
};
|
|
1532
1532
|
}>;
|
|
1533
|
+
export declare const timeZoneSchema: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
|
|
1534
|
+
status: z.ZodLiteral<"success">;
|
|
1535
|
+
data: z.ZodObject<{
|
|
1536
|
+
activeTimeZone: z.ZodString;
|
|
1537
|
+
}, "strip", z.ZodTypeAny, {
|
|
1538
|
+
activeTimeZone: string;
|
|
1539
|
+
}, {
|
|
1540
|
+
activeTimeZone: string;
|
|
1541
|
+
}>;
|
|
1542
|
+
}, "strip", z.ZodTypeAny, {
|
|
1543
|
+
status: "success";
|
|
1544
|
+
data: {
|
|
1545
|
+
activeTimeZone: string;
|
|
1546
|
+
};
|
|
1547
|
+
}, {
|
|
1548
|
+
status: "success";
|
|
1549
|
+
data: {
|
|
1550
|
+
activeTimeZone: string;
|
|
1551
|
+
};
|
|
1552
|
+
}>, z.ZodObject<{
|
|
1553
|
+
status: z.ZodLiteral<"error">;
|
|
1554
|
+
error: z.ZodObject<{
|
|
1555
|
+
message: z.ZodString;
|
|
1556
|
+
}, "strip", z.ZodTypeAny, {
|
|
1557
|
+
message: string;
|
|
1558
|
+
}, {
|
|
1559
|
+
message: string;
|
|
1560
|
+
}>;
|
|
1561
|
+
}, "strip", z.ZodTypeAny, {
|
|
1562
|
+
status: "error";
|
|
1563
|
+
error: {
|
|
1564
|
+
message: string;
|
|
1565
|
+
};
|
|
1566
|
+
}, {
|
|
1567
|
+
status: "error";
|
|
1568
|
+
error: {
|
|
1569
|
+
message: string;
|
|
1570
|
+
};
|
|
1571
|
+
}>]>;
|
|
1533
1572
|
export declare const audioSampleRatesResponseSchema: z.ZodObject<{
|
|
1534
1573
|
data: z.ZodObject<{
|
|
1535
1574
|
encoders: z.ZodObject<{
|
package/esm/types/VapixAPI.js
CHANGED
|
@@ -107,9 +107,23 @@ export const dateTimeinfoSchema = z.object({
|
|
|
107
107
|
dstEnabled: z.boolean(),
|
|
108
108
|
localDateTime: z.string(),
|
|
109
109
|
posixTimeZone: z.string(),
|
|
110
|
-
timeZone: z.string(),
|
|
110
|
+
timeZone: z.string().optional(),
|
|
111
111
|
}),
|
|
112
112
|
});
|
|
113
|
+
export const timeZoneSchema = z.discriminatedUnion('status', [
|
|
114
|
+
z.object({
|
|
115
|
+
status: z.literal('success'),
|
|
116
|
+
data: z.object({
|
|
117
|
+
activeTimeZone: z.string(),
|
|
118
|
+
}),
|
|
119
|
+
}),
|
|
120
|
+
z.object({
|
|
121
|
+
status: z.literal('error'),
|
|
122
|
+
error: z.object({
|
|
123
|
+
message: z.string(),
|
|
124
|
+
}),
|
|
125
|
+
}),
|
|
126
|
+
]);
|
|
113
127
|
export const audioSampleRatesResponseSchema = z.object({
|
|
114
128
|
data: z.object({
|
|
115
129
|
encoders: z
|
package/esm/web/WsClient.js
CHANGED
|
@@ -27,7 +27,7 @@ export class WsClient {
|
|
|
27
27
|
};
|
|
28
28
|
ws.onmessage = (e) => this.onmessage(e);
|
|
29
29
|
ws.onclose = () => {
|
|
30
|
-
this.restartTimeout = setTimeout(() => this.init(), REFRESH_TIMEOUT);
|
|
30
|
+
this.restartTimeout = window.setTimeout(() => this.init(), REFRESH_TIMEOUT);
|
|
31
31
|
};
|
|
32
32
|
this.ws = ws;
|
|
33
33
|
}
|
|
@@ -40,7 +40,7 @@ export class WsClient {
|
|
|
40
40
|
this.destroyWebsocket();
|
|
41
41
|
};
|
|
42
42
|
destroyWebsocket() {
|
|
43
|
-
if (this.restartTimeout) {
|
|
43
|
+
if (this.restartTimeout !== null) {
|
|
44
44
|
clearTimeout(this.restartTimeout);
|
|
45
45
|
this.restartTimeout = null;
|
|
46
46
|
}
|