camstreamerlib 4.0.0-beta.15 → 4.0.0-beta.16
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 +30 -0
- package/cjs/PlaneTrackerAPI.js +113 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +3 -1
- package/esm/PlaneTrackerAPI.d.ts +30 -0
- package/esm/PlaneTrackerAPI.js +109 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IClient, TResponse } from './internal/types';
|
|
2
|
+
type ICAO = string;
|
|
3
|
+
export declare const BASE_URL = "/local/planetracker";
|
|
4
|
+
export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
5
|
+
private client;
|
|
6
|
+
constructor(client: Client);
|
|
7
|
+
static getProxyUrlPath: () => string;
|
|
8
|
+
checkCameraTime(): Promise<boolean>;
|
|
9
|
+
fetchCameraSettings: () => Promise<any>;
|
|
10
|
+
fetchServerSettings: () => Promise<any>;
|
|
11
|
+
fetchMapInfo: () => Promise<any>;
|
|
12
|
+
fetchFlightInfo: (icao: ICAO) => Promise<any>;
|
|
13
|
+
getZones: () => Promise<any>;
|
|
14
|
+
setZones: (zonesJsonString: string) => Promise<any>;
|
|
15
|
+
getPriorityList: () => Promise<any>;
|
|
16
|
+
setPriorityList: (priorityListJsonString: string) => Promise<any>;
|
|
17
|
+
getWhiteList: () => Promise<any>;
|
|
18
|
+
setWhiteList: (whiteListJsonString: string) => Promise<any>;
|
|
19
|
+
getBlackList: () => Promise<any>;
|
|
20
|
+
setBlackList: (blackListJsonString: string) => Promise<any>;
|
|
21
|
+
getTrackingMode: () => Promise<any>;
|
|
22
|
+
setTrackingMode: (modeJsonString: string) => Promise<any>;
|
|
23
|
+
startTrackingPlane: (icao: ICAO) => Promise<TResponse>;
|
|
24
|
+
stopTrackingPlane: () => Promise<TResponse>;
|
|
25
|
+
goToCoordinates: (lat: number, lon: number, alt?: number) => Promise<TResponse>;
|
|
26
|
+
private _get;
|
|
27
|
+
private _post;
|
|
28
|
+
private _postJsonEncoded;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlaneTrackerAPI = exports.BASE_URL = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("./internal/utils");
|
|
6
|
+
exports.BASE_URL = '/local/planetracker';
|
|
7
|
+
class PlaneTrackerAPI {
|
|
8
|
+
client;
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
static getProxyUrlPath = () => `${exports.BASE_URL}/proxy.cgi`;
|
|
13
|
+
async checkCameraTime() {
|
|
14
|
+
const responseSchema = zod_1.z.discriminatedUnion('state', [
|
|
15
|
+
zod_1.z.object({
|
|
16
|
+
state: zod_1.z.literal(true),
|
|
17
|
+
code: zod_1.z.number(),
|
|
18
|
+
}),
|
|
19
|
+
zod_1.z.object({
|
|
20
|
+
state: zod_1.z.literal(false),
|
|
21
|
+
code: zod_1.z.number(),
|
|
22
|
+
reason: zod_1.z.union([
|
|
23
|
+
zod_1.z.literal('INVALID_TIME'),
|
|
24
|
+
zod_1.z.literal('COULDNT_RESOLVE_HOST'),
|
|
25
|
+
zod_1.z.literal('CONNECTION_ERROR'),
|
|
26
|
+
]),
|
|
27
|
+
message: zod_1.z.string(),
|
|
28
|
+
}),
|
|
29
|
+
]);
|
|
30
|
+
const response = await this._get(`${exports.BASE_URL}/camera_time.cgi`);
|
|
31
|
+
const cameraTime = responseSchema.parse(response);
|
|
32
|
+
if (!cameraTime.state) {
|
|
33
|
+
console.error(`Camera time check failed: ${cameraTime.reason} - ${cameraTime.message}`);
|
|
34
|
+
}
|
|
35
|
+
return cameraTime.state;
|
|
36
|
+
}
|
|
37
|
+
fetchCameraSettings = async () => {
|
|
38
|
+
return await this._get(`${exports.BASE_URL}/package_camera_settings.cgi?action=get`);
|
|
39
|
+
};
|
|
40
|
+
fetchServerSettings = async () => {
|
|
41
|
+
return await this._get(`${exports.BASE_URL}/package_server_settings.cgi?action=get`);
|
|
42
|
+
};
|
|
43
|
+
fetchMapInfo = async () => {
|
|
44
|
+
return await this._get(`${exports.BASE_URL}/package/getMapInfo.cgi`);
|
|
45
|
+
};
|
|
46
|
+
fetchFlightInfo = async (icao) => {
|
|
47
|
+
return await this._get(`${exports.BASE_URL}/package/flightInfo.cgi?icao=${icao}`);
|
|
48
|
+
};
|
|
49
|
+
getZones = async () => {
|
|
50
|
+
return await this._get(`${exports.BASE_URL}/package/getZones.cgi`);
|
|
51
|
+
};
|
|
52
|
+
setZones = async (zonesJsonString) => {
|
|
53
|
+
return await this._postJsonEncoded(`${exports.BASE_URL}/package/setZones.cgi`, zonesJsonString);
|
|
54
|
+
};
|
|
55
|
+
getPriorityList = async () => {
|
|
56
|
+
return await this._get(`${exports.BASE_URL}/package/getPriorityList.cgi`);
|
|
57
|
+
};
|
|
58
|
+
setPriorityList = async (priorityListJsonString) => {
|
|
59
|
+
return await this._postJsonEncoded(`${exports.BASE_URL}/package/setPriorityList.cgi`, priorityListJsonString);
|
|
60
|
+
};
|
|
61
|
+
getWhiteList = async () => {
|
|
62
|
+
return await this._get(`${exports.BASE_URL}/package/getWhiteList.cgi`);
|
|
63
|
+
};
|
|
64
|
+
setWhiteList = async (whiteListJsonString) => {
|
|
65
|
+
return await this._postJsonEncoded(`${exports.BASE_URL}/package/setWhiteList.cgi`, whiteListJsonString);
|
|
66
|
+
};
|
|
67
|
+
getBlackList = async () => {
|
|
68
|
+
return await this._get(`${exports.BASE_URL}/package/getBlackList.cgi`);
|
|
69
|
+
};
|
|
70
|
+
setBlackList = async (blackListJsonString) => {
|
|
71
|
+
return await this._postJsonEncoded(`${exports.BASE_URL}/package/setBlackList.cgi`, blackListJsonString);
|
|
72
|
+
};
|
|
73
|
+
getTrackingMode = async () => {
|
|
74
|
+
return await this._get(`${exports.BASE_URL}/package/getTrackingMode.cgi`);
|
|
75
|
+
};
|
|
76
|
+
setTrackingMode = async (modeJsonString) => {
|
|
77
|
+
return await this._postJsonEncoded(`${exports.BASE_URL}/package/setTrackingMode.cgi`, modeJsonString);
|
|
78
|
+
};
|
|
79
|
+
startTrackingPlane = async (icao) => {
|
|
80
|
+
return await this.client.get(`${exports.BASE_URL}/package/trackIcao.cgi?icao=${icao}`);
|
|
81
|
+
};
|
|
82
|
+
stopTrackingPlane = async () => {
|
|
83
|
+
return await this.client.get(`${exports.BASE_URL}/package/resetIcao.cgi`);
|
|
84
|
+
};
|
|
85
|
+
goToCoordinates = async (lat, lon, alt) => {
|
|
86
|
+
const url = `${exports.BASE_URL}/package/goToCoordinates.cgi?lat=${lat}&lon=${lon}`;
|
|
87
|
+
return await this.client.get(`${url}${alt !== undefined ? `&alt=${alt}` : ''}`);
|
|
88
|
+
};
|
|
89
|
+
async _get(...args) {
|
|
90
|
+
const res = await this.client.get(...args);
|
|
91
|
+
if (res.ok) {
|
|
92
|
+
return (await res.json());
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async _post(...args) {
|
|
99
|
+
const res = await this.client.post(...args);
|
|
100
|
+
if (res.ok) {
|
|
101
|
+
return (await res.json());
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async _postJsonEncoded(...args) {
|
|
108
|
+
const [path, data, params, headers] = args;
|
|
109
|
+
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
110
|
+
return this._post(path, data, params, { ...baseHeaders, ...headers });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.PlaneTrackerAPI = PlaneTrackerAPI;
|
package/cjs/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { VapixAPI } from './VapixAPI';
|
|
|
9
9
|
export { CamOverlayAPI } from './CamOverlayAPI';
|
|
10
10
|
export { CamScripterAPI } from './CamScripterAPI';
|
|
11
11
|
export { CamStreamerAPI } from './CamStreamerAPI';
|
|
12
|
+
export { PlaneTrackerAPI } from './PlaneTrackerAPI';
|
|
12
13
|
export * from './types/CamSwitcherEvents';
|
|
13
14
|
export * from './types/CamSwitcherAPI';
|
|
14
15
|
export * from './types/VapixAPI';
|
package/cjs/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.CamStreamerAPI = exports.CamScripterAPI = exports.CamOverlayAPI = exports.VapixAPI = exports.CamSwitcherEvents = exports.CamSwitcherAPI = void 0;
|
|
17
|
+
exports.PlaneTrackerAPI = exports.CamStreamerAPI = exports.CamScripterAPI = exports.CamOverlayAPI = exports.VapixAPI = exports.CamSwitcherEvents = exports.CamSwitcherAPI = void 0;
|
|
18
18
|
__exportStar(require("./internal/types"), exports);
|
|
19
19
|
__exportStar(require("./internal/constants"), exports);
|
|
20
20
|
__exportStar(require("./internal/utils"), exports);
|
|
@@ -32,6 +32,8 @@ var CamScripterAPI_1 = require("./CamScripterAPI");
|
|
|
32
32
|
Object.defineProperty(exports, "CamScripterAPI", { enumerable: true, get: function () { return CamScripterAPI_1.CamScripterAPI; } });
|
|
33
33
|
var CamStreamerAPI_1 = require("./CamStreamerAPI");
|
|
34
34
|
Object.defineProperty(exports, "CamStreamerAPI", { enumerable: true, get: function () { return CamStreamerAPI_1.CamStreamerAPI; } });
|
|
35
|
+
var PlaneTrackerAPI_1 = require("./PlaneTrackerAPI");
|
|
36
|
+
Object.defineProperty(exports, "PlaneTrackerAPI", { enumerable: true, get: function () { return PlaneTrackerAPI_1.PlaneTrackerAPI; } });
|
|
35
37
|
__exportStar(require("./types/CamSwitcherEvents"), exports);
|
|
36
38
|
__exportStar(require("./types/CamSwitcherAPI"), exports);
|
|
37
39
|
__exportStar(require("./types/VapixAPI"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IClient, TResponse } from './internal/types';
|
|
2
|
+
type ICAO = string;
|
|
3
|
+
export declare const BASE_URL = "/local/planetracker";
|
|
4
|
+
export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
5
|
+
private client;
|
|
6
|
+
constructor(client: Client);
|
|
7
|
+
static getProxyUrlPath: () => string;
|
|
8
|
+
checkCameraTime(): Promise<boolean>;
|
|
9
|
+
fetchCameraSettings: () => Promise<any>;
|
|
10
|
+
fetchServerSettings: () => Promise<any>;
|
|
11
|
+
fetchMapInfo: () => Promise<any>;
|
|
12
|
+
fetchFlightInfo: (icao: ICAO) => Promise<any>;
|
|
13
|
+
getZones: () => Promise<any>;
|
|
14
|
+
setZones: (zonesJsonString: string) => Promise<any>;
|
|
15
|
+
getPriorityList: () => Promise<any>;
|
|
16
|
+
setPriorityList: (priorityListJsonString: string) => Promise<any>;
|
|
17
|
+
getWhiteList: () => Promise<any>;
|
|
18
|
+
setWhiteList: (whiteListJsonString: string) => Promise<any>;
|
|
19
|
+
getBlackList: () => Promise<any>;
|
|
20
|
+
setBlackList: (blackListJsonString: string) => Promise<any>;
|
|
21
|
+
getTrackingMode: () => Promise<any>;
|
|
22
|
+
setTrackingMode: (modeJsonString: string) => Promise<any>;
|
|
23
|
+
startTrackingPlane: (icao: ICAO) => Promise<TResponse>;
|
|
24
|
+
stopTrackingPlane: () => Promise<TResponse>;
|
|
25
|
+
goToCoordinates: (lat: number, lon: number, alt?: number) => Promise<TResponse>;
|
|
26
|
+
private _get;
|
|
27
|
+
private _post;
|
|
28
|
+
private _postJsonEncoded;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { responseStringify } from './internal/utils';
|
|
3
|
+
export const BASE_URL = '/local/planetracker';
|
|
4
|
+
export class PlaneTrackerAPI {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
static getProxyUrlPath = () => `${BASE_URL}/proxy.cgi`;
|
|
10
|
+
async checkCameraTime() {
|
|
11
|
+
const responseSchema = z.discriminatedUnion('state', [
|
|
12
|
+
z.object({
|
|
13
|
+
state: z.literal(true),
|
|
14
|
+
code: z.number(),
|
|
15
|
+
}),
|
|
16
|
+
z.object({
|
|
17
|
+
state: z.literal(false),
|
|
18
|
+
code: z.number(),
|
|
19
|
+
reason: z.union([
|
|
20
|
+
z.literal('INVALID_TIME'),
|
|
21
|
+
z.literal('COULDNT_RESOLVE_HOST'),
|
|
22
|
+
z.literal('CONNECTION_ERROR'),
|
|
23
|
+
]),
|
|
24
|
+
message: z.string(),
|
|
25
|
+
}),
|
|
26
|
+
]);
|
|
27
|
+
const response = await this._get(`${BASE_URL}/camera_time.cgi`);
|
|
28
|
+
const cameraTime = responseSchema.parse(response);
|
|
29
|
+
if (!cameraTime.state) {
|
|
30
|
+
console.error(`Camera time check failed: ${cameraTime.reason} - ${cameraTime.message}`);
|
|
31
|
+
}
|
|
32
|
+
return cameraTime.state;
|
|
33
|
+
}
|
|
34
|
+
fetchCameraSettings = async () => {
|
|
35
|
+
return await this._get(`${BASE_URL}/package_camera_settings.cgi?action=get`);
|
|
36
|
+
};
|
|
37
|
+
fetchServerSettings = async () => {
|
|
38
|
+
return await this._get(`${BASE_URL}/package_server_settings.cgi?action=get`);
|
|
39
|
+
};
|
|
40
|
+
fetchMapInfo = async () => {
|
|
41
|
+
return await this._get(`${BASE_URL}/package/getMapInfo.cgi`);
|
|
42
|
+
};
|
|
43
|
+
fetchFlightInfo = async (icao) => {
|
|
44
|
+
return await this._get(`${BASE_URL}/package/flightInfo.cgi?icao=${icao}`);
|
|
45
|
+
};
|
|
46
|
+
getZones = async () => {
|
|
47
|
+
return await this._get(`${BASE_URL}/package/getZones.cgi`);
|
|
48
|
+
};
|
|
49
|
+
setZones = async (zonesJsonString) => {
|
|
50
|
+
return await this._postJsonEncoded(`${BASE_URL}/package/setZones.cgi`, zonesJsonString);
|
|
51
|
+
};
|
|
52
|
+
getPriorityList = async () => {
|
|
53
|
+
return await this._get(`${BASE_URL}/package/getPriorityList.cgi`);
|
|
54
|
+
};
|
|
55
|
+
setPriorityList = async (priorityListJsonString) => {
|
|
56
|
+
return await this._postJsonEncoded(`${BASE_URL}/package/setPriorityList.cgi`, priorityListJsonString);
|
|
57
|
+
};
|
|
58
|
+
getWhiteList = async () => {
|
|
59
|
+
return await this._get(`${BASE_URL}/package/getWhiteList.cgi`);
|
|
60
|
+
};
|
|
61
|
+
setWhiteList = async (whiteListJsonString) => {
|
|
62
|
+
return await this._postJsonEncoded(`${BASE_URL}/package/setWhiteList.cgi`, whiteListJsonString);
|
|
63
|
+
};
|
|
64
|
+
getBlackList = async () => {
|
|
65
|
+
return await this._get(`${BASE_URL}/package/getBlackList.cgi`);
|
|
66
|
+
};
|
|
67
|
+
setBlackList = async (blackListJsonString) => {
|
|
68
|
+
return await this._postJsonEncoded(`${BASE_URL}/package/setBlackList.cgi`, blackListJsonString);
|
|
69
|
+
};
|
|
70
|
+
getTrackingMode = async () => {
|
|
71
|
+
return await this._get(`${BASE_URL}/package/getTrackingMode.cgi`);
|
|
72
|
+
};
|
|
73
|
+
setTrackingMode = async (modeJsonString) => {
|
|
74
|
+
return await this._postJsonEncoded(`${BASE_URL}/package/setTrackingMode.cgi`, modeJsonString);
|
|
75
|
+
};
|
|
76
|
+
startTrackingPlane = async (icao) => {
|
|
77
|
+
return await this.client.get(`${BASE_URL}/package/trackIcao.cgi?icao=${icao}`);
|
|
78
|
+
};
|
|
79
|
+
stopTrackingPlane = async () => {
|
|
80
|
+
return await this.client.get(`${BASE_URL}/package/resetIcao.cgi`);
|
|
81
|
+
};
|
|
82
|
+
goToCoordinates = async (lat, lon, alt) => {
|
|
83
|
+
const url = `${BASE_URL}/package/goToCoordinates.cgi?lat=${lat}&lon=${lon}`;
|
|
84
|
+
return await this.client.get(`${url}${alt !== undefined ? `&alt=${alt}` : ''}`);
|
|
85
|
+
};
|
|
86
|
+
async _get(...args) {
|
|
87
|
+
const res = await this.client.get(...args);
|
|
88
|
+
if (res.ok) {
|
|
89
|
+
return (await res.json());
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw new Error(await responseStringify(res));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async _post(...args) {
|
|
96
|
+
const res = await this.client.post(...args);
|
|
97
|
+
if (res.ok) {
|
|
98
|
+
return (await res.json());
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
throw new Error(await responseStringify(res));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async _postJsonEncoded(...args) {
|
|
105
|
+
const [path, data, params, headers] = args;
|
|
106
|
+
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
107
|
+
return this._post(path, data, params, { ...baseHeaders, ...headers });
|
|
108
|
+
}
|
|
109
|
+
}
|
package/esm/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { VapixAPI } from './VapixAPI';
|
|
|
9
9
|
export { CamOverlayAPI } from './CamOverlayAPI';
|
|
10
10
|
export { CamScripterAPI } from './CamScripterAPI';
|
|
11
11
|
export { CamStreamerAPI } from './CamStreamerAPI';
|
|
12
|
+
export { PlaneTrackerAPI } from './PlaneTrackerAPI';
|
|
12
13
|
export * from './types/CamSwitcherEvents';
|
|
13
14
|
export * from './types/CamSwitcherAPI';
|
|
14
15
|
export * from './types/VapixAPI';
|
package/esm/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { VapixAPI } from './VapixAPI';
|
|
|
9
9
|
export { CamOverlayAPI } from './CamOverlayAPI';
|
|
10
10
|
export { CamScripterAPI } from './CamScripterAPI';
|
|
11
11
|
export { CamStreamerAPI } from './CamStreamerAPI';
|
|
12
|
+
export { PlaneTrackerAPI } from './PlaneTrackerAPI';
|
|
12
13
|
export * from './types/CamSwitcherEvents';
|
|
13
14
|
export * from './types/CamSwitcherAPI';
|
|
14
15
|
export * from './types/VapixAPI';
|