camstreamerlib 4.0.0-beta.2 → 4.0.0-beta.20
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 +5 -1
- package/cjs/CamOverlayAPI.d.ts +629 -0
- package/cjs/CamOverlayAPI.js +255 -0
- package/{CamOverlayDrawingAPI.d.ts → cjs/CamOverlayDrawingAPI.d.ts} +1 -1
- package/cjs/CamOverlayDrawingAPI.js +235 -0
- package/cjs/CamOverlayPainter/Frame.js +301 -0
- package/{CamOverlayPainter → cjs/CamOverlayPainter}/Painter.d.ts +14 -3
- package/cjs/CamOverlayPainter/Painter.js +171 -0
- package/cjs/CamOverlayPainter/ResourceManager.js +46 -0
- package/{CamScripterAPI.d.ts → cjs/CamScripterAPI.d.ts} +5 -5
- package/cjs/CamScripterAPI.js +64 -0
- package/{CamScripterAPICameraEventsGenerator.d.ts → cjs/CamScripterAPICameraEventsGenerator.d.ts} +1 -1
- package/cjs/CamScripterAPICameraEventsGenerator.js +162 -0
- package/{CamStreamerAPI.d.ts → cjs/CamStreamerAPI.d.ts} +5 -5
- package/cjs/CamStreamerAPI.js +59 -0
- package/{CamSwitcherAPI.d.ts → cjs/CamSwitcherAPI.d.ts} +10 -6
- package/cjs/CamSwitcherAPI.js +351 -0
- package/{CamSwitcherEvents.d.ts → cjs/CamSwitcherEvents.d.ts} +2 -2
- package/cjs/CamSwitcherEvents.js +67 -0
- package/cjs/CreatePackage.js +106 -0
- package/cjs/PlaneTrackerAPI.d.ts +47 -0
- package/cjs/PlaneTrackerAPI.js +176 -0
- package/{VapixAPI.d.ts → cjs/VapixAPI.d.ts} +19 -7
- package/cjs/VapixAPI.js +491 -0
- package/{VapixEvents.d.ts → cjs/VapixEvents.d.ts} +1 -1
- package/cjs/VapixEvents.js +88 -0
- package/{errors → cjs/errors}/errors.d.ts +3 -0
- package/cjs/errors/errors.js +86 -0
- package/{events → cjs/events}/AxisCameraStationEvents.d.ts +3 -2
- package/cjs/events/AxisCameraStationEvents.js +48 -0
- package/{events → cjs/events}/GenetecAgent.d.ts +4 -3
- package/cjs/events/GenetecAgent.js +123 -0
- package/cjs/index.d.ts +18 -0
- package/cjs/index.js +42 -0
- package/cjs/internal/Digest.js +42 -0
- package/cjs/internal/ProxyClient.d.ts +11 -0
- package/cjs/internal/ProxyClient.js +46 -0
- package/cjs/internal/constants.js +4 -0
- package/cjs/internal/transformers.js +32 -0
- package/cjs/internal/types.d.ts +35 -0
- package/cjs/internal/types.js +2 -0
- package/{internal → cjs/internal}/utils.d.ts +5 -1
- package/cjs/internal/utils.js +69 -0
- package/{internal → cjs/internal}/versionCompare.d.ts +2 -2
- package/cjs/internal/versionCompare.js +53 -0
- package/cjs/models/CamOverlayAPI/accuweatherSchema.d.ts +84 -0
- package/cjs/models/CamOverlayAPI/accuweatherSchema.js +48 -0
- package/cjs/models/CamOverlayAPI/constants.d.ts +11 -0
- package/cjs/models/CamOverlayAPI/constants.js +14 -0
- package/cjs/models/CamOverlayAPI/customGraphicsSchema.d.ts +699 -0
- package/cjs/models/CamOverlayAPI/customGraphicsSchema.js +73 -0
- package/cjs/models/CamOverlayAPI/fileSchema.d.ts +28 -0
- package/cjs/models/CamOverlayAPI/fileSchema.js +17 -0
- package/cjs/models/CamOverlayAPI/imagesSchema.d.ts +95 -0
- package/cjs/models/CamOverlayAPI/imagesSchema.js +10 -0
- package/cjs/models/CamOverlayAPI/index.d.ts +13 -0
- package/cjs/models/CamOverlayAPI/index.js +29 -0
- package/cjs/models/CamOverlayAPI/infotickerSchema.d.ts +96 -0
- package/cjs/models/CamOverlayAPI/infotickerSchema.js +27 -0
- package/cjs/models/CamOverlayAPI/pipSchema.d.ts +125 -0
- package/cjs/models/CamOverlayAPI/pipSchema.js +40 -0
- package/cjs/models/CamOverlayAPI/ptzCompassSchema.d.ts +93 -0
- package/cjs/models/CamOverlayAPI/ptzCompassSchema.js +26 -0
- package/cjs/models/CamOverlayAPI/ptzSchema.d.ts +118 -0
- package/cjs/models/CamOverlayAPI/ptzSchema.js +13 -0
- package/cjs/models/CamOverlayAPI/screenSharingSchema.d.ts +58 -0
- package/cjs/models/CamOverlayAPI/screenSharingSchema.js +9 -0
- package/cjs/models/CamOverlayAPI/webCameraSharingSchema.d.ts +58 -0
- package/cjs/models/CamOverlayAPI/webCameraSharingSchema.js +9 -0
- package/cjs/models/CamOverlayAPI/widgetCommonSchema.d.ts +126 -0
- package/cjs/models/CamOverlayAPI/widgetCommonSchema.js +76 -0
- package/cjs/models/CamOverlayAPI/widgetsSchema.d.ts +2823 -0
- package/cjs/models/CamOverlayAPI/widgetsSchema.js +27 -0
- package/cjs/node/DefaultClient.d.ts +16 -0
- package/cjs/node/DefaultClient.js +56 -0
- package/cjs/node/HttpRequestSender.js +89 -0
- package/cjs/node/HttpServer.js +96 -0
- package/{node → cjs/node}/WsClient.d.ts +1 -1
- package/cjs/node/WsClient.js +149 -0
- package/{node → cjs/node}/WsEventClient.d.ts +1 -1
- package/cjs/node/WsEventClient.js +22 -0
- package/cjs/node/index.d.ts +2 -0
- package/cjs/node/index.js +7 -0
- package/cjs/types/CamOverlayAPI.d.ts +328 -0
- package/cjs/types/CamOverlayAPI.js +26 -0
- package/{types → cjs/types}/CamScripterAPI.d.ts +55 -7
- package/cjs/types/CamScripterAPI.js +31 -0
- package/{types → cjs/types}/CamStreamerAPI.d.ts +16 -5
- package/cjs/types/CamStreamerAPI.js +32 -0
- package/{types → cjs/types}/CamSwitcherAPI.d.ts +5 -5
- package/cjs/types/CamSwitcherAPI.js +137 -0
- package/{types/CamswitcherEvents.d.ts → cjs/types/CamSwitcherEvents.d.ts} +77 -0
- package/cjs/types/CamSwitcherEvents.js +70 -0
- package/cjs/types/PlaneTrackerAPI.d.ts +2 -0
- package/cjs/types/PlaneTrackerAPI.js +2 -0
- package/{types → cjs/types}/VapixAPI.d.ts +479 -519
- package/cjs/types/VapixAPI.js +139 -0
- package/cjs/types/common.js +14 -0
- package/cjs/web/DefaultClient.d.ts +6 -0
- package/cjs/web/DefaultClient.js +22 -0
- package/cjs/web/WsClient.js +62 -0
- package/cjs/web/index.d.ts +2 -0
- package/cjs/web/index.js +7 -0
- package/esm/CamOverlayAPI.d.ts +629 -0
- package/esm/CamOverlayAPI.js +251 -0
- package/esm/CamOverlayDrawingAPI.d.ts +86 -0
- package/{CamOverlayDrawingAPI.js → esm/CamOverlayDrawingAPI.js} +6 -3
- package/esm/CamOverlayPainter/Frame.d.ts +96 -0
- package/esm/CamOverlayPainter/Painter.d.ts +48 -0
- package/{CamOverlayPainter → esm/CamOverlayPainter}/Painter.js +4 -1
- package/esm/CamOverlayPainter/ResourceManager.d.ts +14 -0
- package/{CamOverlayPainter → esm/CamOverlayPainter}/ResourceManager.js +6 -10
- package/esm/CamScripterAPI.d.ts +19 -0
- package/{CamScripterAPI.js → esm/CamScripterAPI.js} +4 -10
- package/esm/CamScripterAPICameraEventsGenerator.d.ts +74 -0
- package/{CamScripterAPICameraEventsGenerator.js → esm/CamScripterAPICameraEventsGenerator.js} +6 -3
- package/esm/CamStreamerAPI.d.ts +16 -0
- package/{CamStreamerAPI.js → esm/CamStreamerAPI.js} +4 -10
- package/esm/CamSwitcherAPI.d.ts +52 -0
- package/{CamSwitcherAPI.js → esm/CamSwitcherAPI.js} +24 -27
- package/esm/CamSwitcherEvents.d.ts +18 -0
- package/{CamSwitcherEvents.js → esm/CamSwitcherEvents.js} +1 -1
- package/esm/CreatePackage.d.ts +1 -0
- package/esm/PlaneTrackerAPI.d.ts +47 -0
- package/esm/PlaneTrackerAPI.js +172 -0
- package/esm/VapixAPI.d.ts +78 -0
- package/{VapixAPI.js → esm/VapixAPI.js} +93 -60
- package/esm/VapixEvents.d.ts +43 -0
- package/{VapixEvents.js → esm/VapixEvents.js} +3 -3
- package/esm/errors/errors.d.ts +37 -0
- package/{errors → esm/errors}/errors.js +6 -0
- package/esm/events/AxisCameraStationEvents.d.ts +10 -0
- package/{events → esm/events}/AxisCameraStationEvents.js +1 -1
- package/esm/events/GenetecAgent.d.ts +175 -0
- package/{events → esm/events}/GenetecAgent.js +5 -5
- package/esm/index.d.ts +18 -0
- package/esm/index.js +18 -0
- package/esm/internal/Digest.d.ts +4 -0
- package/{internal → esm/internal}/Digest.js +6 -6
- package/esm/internal/ProxyClient.d.ts +11 -0
- package/{internal → esm/internal}/ProxyClient.js +6 -4
- package/esm/internal/constants.d.ts +1 -0
- package/esm/internal/transformers.d.ts +5 -0
- package/esm/internal/types.d.ts +35 -0
- package/esm/internal/types.js +1 -0
- package/esm/internal/utils.d.ts +15 -0
- package/{internal → esm/internal}/utils.js +20 -1
- package/esm/internal/versionCompare.d.ts +6 -0
- package/esm/models/CamOverlayAPI/accuweatherSchema.d.ts +84 -0
- package/esm/models/CamOverlayAPI/accuweatherSchema.js +45 -0
- package/esm/models/CamOverlayAPI/constants.d.ts +11 -0
- package/esm/models/CamOverlayAPI/constants.js +11 -0
- package/esm/models/CamOverlayAPI/customGraphicsSchema.d.ts +699 -0
- package/esm/models/CamOverlayAPI/customGraphicsSchema.js +70 -0
- package/esm/models/CamOverlayAPI/fileSchema.d.ts +28 -0
- package/esm/models/CamOverlayAPI/fileSchema.js +14 -0
- package/esm/models/CamOverlayAPI/imagesSchema.d.ts +95 -0
- package/esm/models/CamOverlayAPI/imagesSchema.js +7 -0
- package/esm/models/CamOverlayAPI/index.d.ts +13 -0
- package/esm/models/CamOverlayAPI/index.js +13 -0
- package/esm/models/CamOverlayAPI/infotickerSchema.d.ts +96 -0
- package/esm/models/CamOverlayAPI/infotickerSchema.js +24 -0
- package/esm/models/CamOverlayAPI/pipSchema.d.ts +125 -0
- package/esm/models/CamOverlayAPI/pipSchema.js +37 -0
- package/esm/models/CamOverlayAPI/ptzCompassSchema.d.ts +93 -0
- package/esm/models/CamOverlayAPI/ptzCompassSchema.js +23 -0
- package/esm/models/CamOverlayAPI/ptzSchema.d.ts +118 -0
- package/esm/models/CamOverlayAPI/ptzSchema.js +10 -0
- package/esm/models/CamOverlayAPI/screenSharingSchema.d.ts +58 -0
- package/esm/models/CamOverlayAPI/screenSharingSchema.js +6 -0
- package/esm/models/CamOverlayAPI/webCameraSharingSchema.d.ts +58 -0
- package/esm/models/CamOverlayAPI/webCameraSharingSchema.js +6 -0
- package/esm/models/CamOverlayAPI/widgetCommonSchema.d.ts +126 -0
- package/esm/models/CamOverlayAPI/widgetCommonSchema.js +73 -0
- package/esm/models/CamOverlayAPI/widgetsSchema.d.ts +2823 -0
- package/esm/models/CamOverlayAPI/widgetsSchema.js +24 -0
- package/esm/node/DefaultClient.d.ts +16 -0
- package/{node → esm/node}/DefaultClient.js +9 -7
- package/esm/node/HttpRequestSender.d.ts +28 -0
- package/esm/node/HttpServer.d.ts +21 -0
- package/{node → esm/node}/HttpServer.js +1 -1
- package/esm/node/WsClient.d.ts +39 -0
- package/esm/node/WsEventClient.d.ts +13 -0
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/types/CamOverlayAPI.d.ts +328 -0
- package/esm/types/CamOverlayAPI.js +14 -0
- package/esm/types/CamScripterAPI.d.ts +115 -0
- package/esm/types/CamScripterAPI.js +28 -0
- package/esm/types/CamStreamerAPI.d.ts +150 -0
- package/{types → esm/types}/CamStreamerAPI.js +4 -0
- package/esm/types/CamSwitcherAPI.d.ts +814 -0
- package/esm/types/CamSwitcherEvents.d.ts +568 -0
- package/{types/CamswitcherEvents.js → esm/types/CamSwitcherEvents.js} +8 -0
- package/esm/types/PlaneTrackerAPI.d.ts +2 -0
- package/esm/types/PlaneTrackerAPI.js +1 -0
- package/esm/types/VapixAPI.d.ts +1664 -0
- package/{types → esm/types}/VapixAPI.js +30 -23
- package/esm/types/common.d.ts +37 -0
- package/esm/web/DefaultClient.d.ts +6 -0
- package/{web → esm/web}/DefaultClient.js +6 -4
- package/esm/web/WsClient.d.ts +13 -0
- package/{web → esm/web}/WsClient.js +2 -2
- package/esm/web/index.d.ts +2 -0
- package/esm/web/index.js +2 -0
- package/package.json +6 -6
- package/CamOverlayAPI.d.ts +0 -31
- package/CamOverlayAPI.js +0 -172
- package/internal/ProxyClient.d.ts +0 -11
- package/internal/common.d.ts +0 -40
- package/internal/common.js +0 -23
- package/node/DefaultClient.d.ts +0 -15
- package/types/CamOverlayAPI.d.ts +0 -188
- package/types/CamOverlayAPI.js +0 -44
- package/types/CamScripterAPI.js +0 -17
- package/web/DefaultClient.d.ts +0 -6
- package/{CamOverlayPainter → cjs/CamOverlayPainter}/Frame.d.ts +0 -0
- package/{CamOverlayPainter → cjs/CamOverlayPainter}/ResourceManager.d.ts +0 -0
- package/{CreatePackage.d.ts → cjs/CreatePackage.d.ts} +0 -0
- package/{internal → cjs/internal}/Digest.d.ts +0 -0
- package/{internal → cjs/internal}/constants.d.ts +0 -0
- package/{internal → cjs/internal}/transformers.d.ts +0 -0
- package/{node → cjs/node}/HttpRequestSender.d.ts +0 -0
- package/{node → cjs/node}/HttpServer.d.ts +0 -0
- package/{types → cjs/types}/common.d.ts +2 -2
- /package/{web → cjs/web}/WsClient.d.ts +0 -0
- /package/{CamOverlayPainter → esm/CamOverlayPainter}/Frame.js +0 -0
- /package/{CreatePackage.js → esm/CreatePackage.js} +0 -0
- /package/{internal → esm/internal}/constants.js +0 -0
- /package/{internal → esm/internal}/transformers.js +0 -0
- /package/{internal → esm/internal}/versionCompare.js +0 -0
- /package/{node → esm/node}/HttpRequestSender.js +0 -0
- /package/{node → esm/node}/WsClient.js +0 -0
- /package/{node → esm/node}/WsEventClient.js +0 -0
- /package/{types → esm/types}/CamSwitcherAPI.js +0 -0
- /package/{types → esm/types}/common.js +0 -0
|
@@ -19,15 +19,8 @@ export const APP_IDS = [
|
|
|
19
19
|
'CamScripter',
|
|
20
20
|
'PlaneTracker',
|
|
21
21
|
'Ndihxplugin',
|
|
22
|
+
'SportTracker',
|
|
22
23
|
];
|
|
23
|
-
export const applicationListSchema = z.object({
|
|
24
|
-
reply: z.object({
|
|
25
|
-
$: z.object({ result: z.string() }),
|
|
26
|
-
application: z.array(z.object({
|
|
27
|
-
$: applicationSchema,
|
|
28
|
-
})),
|
|
29
|
-
}),
|
|
30
|
-
});
|
|
31
24
|
export const guardTourSchema = z.object({
|
|
32
25
|
id: z.string(),
|
|
33
26
|
camNbr: z.unknown(),
|
|
@@ -67,7 +60,7 @@ export const audioDeviceSignalingChannelTypeSchema = z.object({
|
|
|
67
60
|
});
|
|
68
61
|
export const audioDeviceSignalingTypeSchema = z.object({
|
|
69
62
|
id: z.string(),
|
|
70
|
-
powerType: z.string(),
|
|
63
|
+
powerType: z.string().optional(),
|
|
71
64
|
channels: z.array(audioDeviceSignalingChannelTypeSchema),
|
|
72
65
|
});
|
|
73
66
|
export const audioDeviceConnectionTypeSchema = z.object({
|
|
@@ -94,15 +87,19 @@ const audioDeviceFromRequestSchema = z.object({
|
|
|
94
87
|
inputs: z.array(audioDeviceInputOutputSchema).optional(),
|
|
95
88
|
outputs: z.array(audioDeviceInputOutputSchema).optional(),
|
|
96
89
|
});
|
|
97
|
-
export const audioDeviceRequestSchema = z.object({
|
|
90
|
+
export const audioDeviceRequestSchema = z.object({
|
|
91
|
+
data: z.object({ devices: z.array(audioDeviceFromRequestSchema) }),
|
|
92
|
+
});
|
|
98
93
|
export const maxFpsResponseSchema = z.object({
|
|
99
|
-
data: z
|
|
94
|
+
data: z
|
|
95
|
+
.array(z.object({
|
|
100
96
|
channel: z.number(),
|
|
101
97
|
captureMode: z.array(z.object({
|
|
102
98
|
enabled: z.boolean(),
|
|
103
99
|
maxFPS: z.number().optional(),
|
|
104
100
|
})),
|
|
105
|
-
}))
|
|
101
|
+
}))
|
|
102
|
+
.optional(),
|
|
106
103
|
});
|
|
107
104
|
export const dateTimeinfoSchema = z.object({
|
|
108
105
|
data: z.object({
|
|
@@ -110,20 +107,30 @@ export const dateTimeinfoSchema = z.object({
|
|
|
110
107
|
dstEnabled: z.boolean(),
|
|
111
108
|
localDateTime: z.string(),
|
|
112
109
|
posixTimeZone: z.string(),
|
|
113
|
-
timeZone: z.string(),
|
|
110
|
+
timeZone: z.string().optional(),
|
|
114
111
|
}),
|
|
115
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
|
+
]);
|
|
116
127
|
export const audioSampleRatesResponseSchema = z.object({
|
|
117
128
|
data: z.object({
|
|
118
|
-
encoders: z
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
AAC: z.array(audioSampleRatesSchema),
|
|
125
|
-
aac: z.undefined(),
|
|
126
|
-
}),
|
|
127
|
-
]),
|
|
129
|
+
encoders: z
|
|
130
|
+
.object({
|
|
131
|
+
aac: z.array(audioSampleRatesSchema),
|
|
132
|
+
AAC: z.array(audioSampleRatesSchema),
|
|
133
|
+
})
|
|
134
|
+
.partial(),
|
|
128
135
|
}),
|
|
129
136
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const audioChannelSchema: z.ZodUnion<[z.ZodLiteral<"mono">, z.ZodLiteral<"stereo">]>;
|
|
3
|
+
export type TAudioChannel = z.infer<typeof audioChannelSchema>;
|
|
4
|
+
export declare const audioChannelCountSchema: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
5
|
+
export type TAudioChannelCount = z.infer<typeof audioChannelCountSchema>;
|
|
6
|
+
export declare const h264ProfileSchema: z.ZodUnion<[z.ZodLiteral<"high">, z.ZodLiteral<"main">, z.ZodLiteral<"baseline">]>;
|
|
7
|
+
export type TH264Profile = z.infer<typeof h264ProfileSchema>;
|
|
8
|
+
export declare const storageTypeSchema: z.ZodUnion<[z.ZodLiteral<"SD_DISK">, z.ZodLiteral<"FLASH">]>;
|
|
9
|
+
export type TStorageType = z.infer<typeof storageTypeSchema>;
|
|
10
|
+
export declare const networkCameraListSchema: z.ZodArray<z.ZodObject<{
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
ip: z.ZodString;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
name: string;
|
|
15
|
+
ip: string;
|
|
16
|
+
}, {
|
|
17
|
+
name: string;
|
|
18
|
+
ip: string;
|
|
19
|
+
}>, "many">;
|
|
20
|
+
export type TNetworkCamera = z.infer<typeof networkCameraListSchema>[number];
|
|
21
|
+
export declare const keyboardShortcutSchema: z.ZodNullable<z.ZodString>;
|
|
22
|
+
export declare const keyboardShortcutsSchema: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
|
|
23
|
+
export type TKeyboardShortcut = z.infer<typeof keyboardShortcutSchema>;
|
|
24
|
+
export type TKeyboardShortcuts = z.infer<typeof keyboardShortcutsSchema>;
|
|
25
|
+
export type TProxyParam = {
|
|
26
|
+
ip: string;
|
|
27
|
+
mdnsName: string;
|
|
28
|
+
port: number;
|
|
29
|
+
user: string;
|
|
30
|
+
pass: string;
|
|
31
|
+
} | null;
|
|
32
|
+
export type TCameraImageConfig = {
|
|
33
|
+
camera?: string;
|
|
34
|
+
resolution?: string;
|
|
35
|
+
compression?: number;
|
|
36
|
+
overlays?: 'off';
|
|
37
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IClient } from '../internal/types';
|
|
3
|
+
export declare class DefaultClient implements IClient<Response> {
|
|
4
|
+
get: (url: string, parameters?: import("../internal/types").TParameters | undefined, headers?: Record<string, string> | undefined) => Promise<Response>;
|
|
5
|
+
post: (url: string, data: string | Buffer | FormData, parameters?: import("../internal/types").TParameters | undefined, headers?: Record<string, string> | undefined) => Promise<Response>;
|
|
6
|
+
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { addParametersToPath } from '../internal/utils';
|
|
2
2
|
export class DefaultClient {
|
|
3
|
-
get
|
|
3
|
+
get = (...params) => {
|
|
4
|
+
const [url, parameters, headers] = params;
|
|
4
5
|
return fetch(addParametersToPath(url, parameters), {
|
|
5
6
|
method: 'GET',
|
|
6
7
|
headers: headers,
|
|
7
8
|
});
|
|
8
|
-
}
|
|
9
|
-
post
|
|
9
|
+
};
|
|
10
|
+
post = (...params) => {
|
|
11
|
+
const [url, data, parameters, headers] = params;
|
|
10
12
|
return fetch(addParametersToPath(url, parameters), {
|
|
11
13
|
method: 'POST',
|
|
12
14
|
body: data,
|
|
13
15
|
headers: headers,
|
|
14
16
|
});
|
|
15
|
-
}
|
|
17
|
+
};
|
|
16
18
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class WsClient {
|
|
2
|
+
private getUrl;
|
|
3
|
+
private getAuthToken;
|
|
4
|
+
isDestroyed: boolean;
|
|
5
|
+
private ws;
|
|
6
|
+
private restartTimeout;
|
|
7
|
+
constructor(getUrl: () => string, getAuthToken: () => Promise<string>);
|
|
8
|
+
init(): void;
|
|
9
|
+
send: (msg: string) => void;
|
|
10
|
+
onmessage: (_: MessageEvent) => void;
|
|
11
|
+
destroy: () => void;
|
|
12
|
+
private destroyWebsocket;
|
|
13
|
+
}
|
|
@@ -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
|
}
|
package/esm/web/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "camstreamerlib",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.20",
|
|
4
4
|
"description": "Helper library for CamStreamer ACAP applications.",
|
|
5
5
|
"prettier": "@camstreamer/prettier-config",
|
|
6
|
-
"type": "module",
|
|
7
6
|
"dependencies": {
|
|
8
7
|
"adm-zip": "^0.5.9",
|
|
9
8
|
"eventemitter2": "^5.0.1",
|
|
9
|
+
"fast-xml-parser": "^5.2.5",
|
|
10
10
|
"lodash": "^4.17.21",
|
|
11
11
|
"prettify-xml": "^1.2.0",
|
|
12
12
|
"type-fest": "^4.41.0",
|
|
13
13
|
"undici": "^6.21.3",
|
|
14
14
|
"ws": "^8.18.0",
|
|
15
|
-
"xml2js": "^0.5.0",
|
|
16
15
|
"zod": "^3.24.3"
|
|
17
16
|
},
|
|
18
17
|
"engine": {
|
|
@@ -26,7 +25,6 @@
|
|
|
26
25
|
"@types/lodash": "^4.17.18",
|
|
27
26
|
"@types/node": "^18.19.39",
|
|
28
27
|
"@types/ws": "^8.5.10",
|
|
29
|
-
"@types/xml2js": "^0.4.14",
|
|
30
28
|
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
31
29
|
"@typescript-eslint/parser": "^6.8.0",
|
|
32
30
|
"eslint": "^8.51.0",
|
|
@@ -41,9 +39,11 @@
|
|
|
41
39
|
},
|
|
42
40
|
"scripts": {
|
|
43
41
|
"clean": "rimraf dist/*",
|
|
44
|
-
"build": "npm-run-all clean
|
|
45
|
-
"
|
|
42
|
+
"build": "npm-run-all clean build:cjs build:esm copyPackage",
|
|
43
|
+
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
44
|
+
"build:esm": "tsc --project tsconfig.esm.json",
|
|
46
45
|
"copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/",
|
|
46
|
+
"prepublish": "npm run build",
|
|
47
47
|
"lint": "eslint \"src/**/*.ts\"",
|
|
48
48
|
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
49
49
|
"pretty": "prettier --write \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
|
package/CamOverlayAPI.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IClient } from './internal/common';
|
|
3
|
-
import { CamOverlayOptions, ImageType, TCoordinates, TField, TFile, TFileList, TFileType, TService, TServiceList, TStorage } from './types/CamOverlayAPI';
|
|
4
|
-
import { TNetworkCamera } from './types/common';
|
|
5
|
-
export declare class CamOverlayAPI {
|
|
6
|
-
private client;
|
|
7
|
-
constructor(options?: CamOverlayOptions | IClient);
|
|
8
|
-
checkCameraTime(): Promise<boolean>;
|
|
9
|
-
getNetworkCameraList(): Promise<TNetworkCamera[]>;
|
|
10
|
-
wsAutoratization(): Promise<string>;
|
|
11
|
-
getMjpegStreamImage(mjpegUrl: string): Promise<Blob>;
|
|
12
|
-
listFiles(fileType: TFileType): Promise<TFileList>;
|
|
13
|
-
uploadFile(fileType: TFileType, file: Blob, fileName: string): Promise<void>;
|
|
14
|
-
removeFile(fileType: TFileType, file: TFile): Promise<void>;
|
|
15
|
-
getFileStorage(fileType: TFileType): Promise<TStorage>;
|
|
16
|
-
updateInfoticker(serviceID: number, text: string): Promise<void>;
|
|
17
|
-
setEnabled(serviceID: number, enabled: boolean): Promise<void>;
|
|
18
|
-
isEnabled(serviceID: number): Promise<boolean>;
|
|
19
|
-
getSingleService(serviceId: number): Promise<TService>;
|
|
20
|
-
getServices(): Promise<TService[]>;
|
|
21
|
-
updateSingleService(serviceId: number, serviceJson: TService): Promise<void>;
|
|
22
|
-
updateServices(servicesJson: TServiceList): Promise<void>;
|
|
23
|
-
updateCGText(serviceID: number, fields: TField[]): Promise<void>;
|
|
24
|
-
updateCGImagePos(serviceID: number, coordinates?: TCoordinates, x?: number, y?: number): Promise<void>;
|
|
25
|
-
updateCGImage(serviceID: number, path: string, coordinates?: TCoordinates, x?: number, y?: number): Promise<void>;
|
|
26
|
-
updateCGImageFromData(serviceID: number, imageType: ImageType, imageData: Buffer, coordinates?: TCoordinates, x?: number, y?: number): Promise<void>;
|
|
27
|
-
private promiseCGUpdate;
|
|
28
|
-
private get;
|
|
29
|
-
private post;
|
|
30
|
-
private parseBlobResponse;
|
|
31
|
-
}
|
package/CamOverlayAPI.js
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { isClient, responseStringify } from './internal/common';
|
|
2
|
-
import { DefaultClient } from './node/DefaultClient';
|
|
3
|
-
import { fileListSchema, ImageType, serviceSchema, storageSchema, } from './types/CamOverlayAPI';
|
|
4
|
-
import { ParsingBlobError, ServiceNotFoundError } from './errors/errors';
|
|
5
|
-
import { networkCameraListSchema } from './types/common';
|
|
6
|
-
export class CamOverlayAPI {
|
|
7
|
-
client;
|
|
8
|
-
constructor(options = {}) {
|
|
9
|
-
if (isClient(options)) {
|
|
10
|
-
this.client = options;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
this.client = new DefaultClient(options);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
async checkCameraTime() {
|
|
17
|
-
const cameraTime = await this.get('/local/camoverlay/api/camera_time.cgi');
|
|
18
|
-
return cameraTime.state;
|
|
19
|
-
}
|
|
20
|
-
async getNetworkCameraList() {
|
|
21
|
-
const response = await this.get('/local/camoverlay/api/network_camera_list.cgi');
|
|
22
|
-
return networkCameraListSchema.parse(response.camera_list);
|
|
23
|
-
}
|
|
24
|
-
async wsAutoratization() {
|
|
25
|
-
const response = await this.get(`/local/camoverlay/api/ws_authorization.cgi`);
|
|
26
|
-
return response.data;
|
|
27
|
-
}
|
|
28
|
-
async getMjpegStreamImage(mjpegUrl) {
|
|
29
|
-
const res = await this.get(`/local/camoverlay/api/fetch_mjpeg_image.cgi?mjpeg_url=${encodeURIComponent(decodeURIComponent(mjpegUrl))}`);
|
|
30
|
-
return await this.parseBlobResponse(res);
|
|
31
|
-
}
|
|
32
|
-
async listFiles(fileType) {
|
|
33
|
-
const files = await this.get(`/local/camoverlay/api/upload_${fileType}.cgi?action=list`);
|
|
34
|
-
return fileListSchema.parse(files.list);
|
|
35
|
-
}
|
|
36
|
-
async uploadFile(fileType, file, fileName) {
|
|
37
|
-
const formData = new FormData();
|
|
38
|
-
formData.append('target', 'SD0');
|
|
39
|
-
formData.append('uploadedFile[]', file, fileName);
|
|
40
|
-
const path = `/local/camoverlay/api/upload_${fileType}.cgi?action=upload`;
|
|
41
|
-
await this.post(path, formData);
|
|
42
|
-
}
|
|
43
|
-
async removeFile(fileType, file) {
|
|
44
|
-
const path = `/local/camoverlay/api/upload_${fileType}.cgi?action=remove`;
|
|
45
|
-
await this.post(path, JSON.stringify(file));
|
|
46
|
-
}
|
|
47
|
-
async getFileStorage(fileType) {
|
|
48
|
-
const data = await this.get(`/local/camoverlay/api/upload_${fileType}.cgi?action=get_storage`);
|
|
49
|
-
return storageSchema.parse(data);
|
|
50
|
-
}
|
|
51
|
-
async updateInfoticker(serviceID, text) {
|
|
52
|
-
await this.get(`/local/camoverlay/api/infoticker.cgi?service_id=${serviceID}&text=${text}`);
|
|
53
|
-
}
|
|
54
|
-
async setEnabled(serviceID, enabled) {
|
|
55
|
-
await this.post(`/local/camoverlay/api/enabled.cgi?id_${serviceID}=${enabled ? 1 : 0}`, '');
|
|
56
|
-
}
|
|
57
|
-
async isEnabled(serviceID) {
|
|
58
|
-
const res = await this.client.get('/local/camoverlay/api/services.cgi?action=get');
|
|
59
|
-
if (res.ok) {
|
|
60
|
-
const data = JSON.parse(await res.text());
|
|
61
|
-
for (const service of data.services) {
|
|
62
|
-
if (service.id === serviceID) {
|
|
63
|
-
return service.enabled === 1;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
throw new ServiceNotFoundError();
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
throw new Error(await responseStringify(res));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async getSingleService(serviceId) {
|
|
73
|
-
const data = await this.get('/local/camoverlay/api/services.cgi', {
|
|
74
|
-
action: 'get',
|
|
75
|
-
service_id: serviceId.toString(),
|
|
76
|
-
});
|
|
77
|
-
return serviceSchema.parse(data);
|
|
78
|
-
}
|
|
79
|
-
async getServices() {
|
|
80
|
-
const serviceList = await this.get('/local/camoverlay/api/services.cgi?action=get');
|
|
81
|
-
return serviceSchema.parse(serviceList).services;
|
|
82
|
-
}
|
|
83
|
-
async updateSingleService(serviceId, serviceJson) {
|
|
84
|
-
const path = '/local/camoverlay/api/services.cgi';
|
|
85
|
-
await this.post(path, JSON.stringify(serviceJson), {
|
|
86
|
-
action: 'set',
|
|
87
|
-
service_id: serviceId.toString(),
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
async updateServices(servicesJson) {
|
|
91
|
-
const path = '/local/camoverlay/api/services.cgi?action=set';
|
|
92
|
-
await this.post(path, JSON.stringify(servicesJson));
|
|
93
|
-
}
|
|
94
|
-
updateCGText(serviceID, fields) {
|
|
95
|
-
const params = {};
|
|
96
|
-
for (const field of fields) {
|
|
97
|
-
const name = field.field_name;
|
|
98
|
-
params[name] = field.text;
|
|
99
|
-
if (field.color !== undefined) {
|
|
100
|
-
params[`${name}_color`] = field.color;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return this.promiseCGUpdate(serviceID, 'update_text', params);
|
|
104
|
-
}
|
|
105
|
-
updateCGImagePos(serviceID, coordinates = '', x = 0, y = 0) {
|
|
106
|
-
const params = {
|
|
107
|
-
coord_system: coordinates,
|
|
108
|
-
pos_x: x,
|
|
109
|
-
pos_y: y,
|
|
110
|
-
};
|
|
111
|
-
return this.promiseCGUpdate(serviceID, 'update_image', params);
|
|
112
|
-
}
|
|
113
|
-
updateCGImage(serviceID, path, coordinates = '', x = 0, y = 0) {
|
|
114
|
-
const params = {
|
|
115
|
-
coord_system: coordinates,
|
|
116
|
-
pos_x: x,
|
|
117
|
-
pos_y: y,
|
|
118
|
-
image: path,
|
|
119
|
-
};
|
|
120
|
-
return this.promiseCGUpdate(serviceID, 'update_image', params);
|
|
121
|
-
}
|
|
122
|
-
updateCGImageFromData(serviceID, imageType, imageData, coordinates = '', x = 0, y = 0) {
|
|
123
|
-
const contentType = imageType === ImageType.PNG ? 'image/png' : 'image/jpeg';
|
|
124
|
-
const params = {
|
|
125
|
-
coord_system: coordinates,
|
|
126
|
-
pos_x: x,
|
|
127
|
-
pos_y: y,
|
|
128
|
-
};
|
|
129
|
-
return this.promiseCGUpdate(serviceID, 'update_image', params, contentType, imageData);
|
|
130
|
-
}
|
|
131
|
-
async promiseCGUpdate(serviceID, action, params = {}, contentType, data) {
|
|
132
|
-
const path = `/local/camoverlay/api/customGraphics.cgi`;
|
|
133
|
-
let headers = {};
|
|
134
|
-
if (contentType !== undefined && data) {
|
|
135
|
-
headers = { 'Content-Type': contentType };
|
|
136
|
-
}
|
|
137
|
-
const res = await this.client.post(path, data ?? '', {
|
|
138
|
-
action: action,
|
|
139
|
-
service_id: serviceID.toString(),
|
|
140
|
-
...params,
|
|
141
|
-
}, headers);
|
|
142
|
-
if (!res.ok) {
|
|
143
|
-
throw new Error(await responseStringify(res));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
async get(path, params) {
|
|
147
|
-
const res = await this.client.get(path, params);
|
|
148
|
-
if (res.ok) {
|
|
149
|
-
return await res.json();
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
throw new Error(await responseStringify(res));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
async post(path, data, params) {
|
|
156
|
-
const res = await this.client.post(path, data, params);
|
|
157
|
-
if (res.ok) {
|
|
158
|
-
return await res.json();
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
throw new Error(await responseStringify(res));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
async parseBlobResponse(response) {
|
|
165
|
-
try {
|
|
166
|
-
return await response.blob();
|
|
167
|
-
}
|
|
168
|
-
catch (err) {
|
|
169
|
-
throw new ParsingBlobError(err);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IClient, TParameters } from './common';
|
|
3
|
-
import { TProxyParam } from '../types/common';
|
|
4
|
-
export declare class ProxyClient<Client extends IClient = IClient> {
|
|
5
|
-
client: Client;
|
|
6
|
-
getProxyUrl: () => string;
|
|
7
|
-
constructor(client: Client, getProxyUrl: () => string);
|
|
8
|
-
get: (proxy: TProxyParam, path: string, parameters?: TParameters, headers?: Record<string, string>) => Promise<import("./common").TResponse>;
|
|
9
|
-
post: (proxy: TProxyParam, path: string, data: string | Buffer | FormData, parameters?: TParameters, headers?: Record<string, string>) => Promise<import("./common").TResponse>;
|
|
10
|
-
private getReal;
|
|
11
|
-
}
|
package/internal/common.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
type Options = {
|
|
3
|
-
ip?: string;
|
|
4
|
-
port?: number;
|
|
5
|
-
user?: string;
|
|
6
|
-
pass?: string;
|
|
7
|
-
tls?: boolean;
|
|
8
|
-
tlsInsecure?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export type HttpOptions = Options & {
|
|
11
|
-
keepAlive?: boolean;
|
|
12
|
-
};
|
|
13
|
-
export type WsOptions = Options;
|
|
14
|
-
export type TResponse = {
|
|
15
|
-
ok: boolean;
|
|
16
|
-
json: () => Promise<any>;
|
|
17
|
-
text: () => Promise<string>;
|
|
18
|
-
status: number;
|
|
19
|
-
body: any | null;
|
|
20
|
-
};
|
|
21
|
-
export type TParameters = Record<string, string | number | boolean | null | undefined>;
|
|
22
|
-
export type TGetFunction = (url: string, parameters?: TParameters, headers?: Record<string, string>) => Promise<TResponse>;
|
|
23
|
-
export type TPostFunction = (url: string, data: string | Buffer | FormData, parameters?: TParameters, headers?: Record<string, string>) => Promise<TResponse>;
|
|
24
|
-
export interface IClient {
|
|
25
|
-
get: TGetFunction;
|
|
26
|
-
post: TPostFunction;
|
|
27
|
-
}
|
|
28
|
-
export interface IWebsocket<Event extends {
|
|
29
|
-
readonly data: string;
|
|
30
|
-
}> {
|
|
31
|
-
destroy: () => void;
|
|
32
|
-
onmessage: null | ((event: Event) => void);
|
|
33
|
-
send: (data: string) => void;
|
|
34
|
-
}
|
|
35
|
-
export declare function isClient(arg?: Options | IClient): arg is IClient;
|
|
36
|
-
export declare function isBrowserEnvironment(): boolean;
|
|
37
|
-
export declare function responseStringify(res: TResponse): Promise<string>;
|
|
38
|
-
export declare function pad(num: number, size: number): string;
|
|
39
|
-
export declare function isNullish<T>(value: T | undefined | null): value is undefined | null;
|
|
40
|
-
export {};
|
package/internal/common.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export function isClient(arg = {}) {
|
|
2
|
-
return 'get' in arg && 'post' in arg;
|
|
3
|
-
}
|
|
4
|
-
export function isBrowserEnvironment() {
|
|
5
|
-
return typeof process === 'undefined' || !process.versions.node;
|
|
6
|
-
}
|
|
7
|
-
export async function responseStringify(res) {
|
|
8
|
-
return JSON.stringify({
|
|
9
|
-
status: res.status,
|
|
10
|
-
body: await res.text(),
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
export function pad(num, size) {
|
|
14
|
-
const sign = Math.sign(num) === -1 ? '-' : '';
|
|
15
|
-
return (sign +
|
|
16
|
-
new Array(size)
|
|
17
|
-
.concat([Math.abs(num)])
|
|
18
|
-
.join('0')
|
|
19
|
-
.slice(-size));
|
|
20
|
-
}
|
|
21
|
-
export function isNullish(value) {
|
|
22
|
-
return value === null || value === undefined;
|
|
23
|
-
}
|
package/node/DefaultClient.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IClient, HttpOptions, TParameters } from '../internal/common';
|
|
3
|
-
export declare class DefaultClient implements IClient {
|
|
4
|
-
private tls;
|
|
5
|
-
private ip;
|
|
6
|
-
private port;
|
|
7
|
-
private user;
|
|
8
|
-
private pass;
|
|
9
|
-
private httpRequestSender;
|
|
10
|
-
constructor(opt?: HttpOptions);
|
|
11
|
-
get url(): string;
|
|
12
|
-
get(path: string, parameters?: TParameters, headers?: Record<string, string>): Promise<import("undici").Response>;
|
|
13
|
-
post(path: string, data: string | FormData | Buffer, parameters?: TParameters, headers?: Record<string, string>): Promise<import("undici").Response>;
|
|
14
|
-
private getBaseConnectionParams;
|
|
15
|
-
}
|