camstreamerlib 4.0.0-beta.4 → 4.0.0-beta.41
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 +112 -0
- package/cjs/CamOverlayAPI.js +135 -92
- package/cjs/CamScripterAPI.js +52 -42
- package/cjs/CamStreamerAPI.js +83 -39
- package/cjs/CamSwitcherAPI.js +141 -123
- package/cjs/CamSwitcherEvents.js +4 -60
- package/cjs/PlaneTrackerAPI.js +210 -0
- package/cjs/VapixAPI.js +323 -233
- package/cjs/{CreatePackage.js → bin/CreatePackage.js} +22 -19
- package/cjs/errors/errors.js +78 -1
- package/cjs/index.js +17 -4
- package/cjs/internal/ProxyClient.js +28 -32
- package/cjs/internal/WsEvents.js +72 -0
- package/cjs/internal/types.js +2 -0
- package/cjs/internal/utils.js +22 -3
- package/cjs/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +7 -4
- package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
- package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +5 -17
- package/cjs/node/CamOverlayPainter/ResourceManager.js +72 -0
- package/cjs/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +7 -4
- package/cjs/node/DefaultClient.js +10 -12
- package/cjs/{internal → node}/Digest.js +8 -5
- package/cjs/node/HttpRequestSender.js +14 -4
- package/cjs/node/HttpServer.js +15 -12
- package/cjs/{VapixEvents.js → node/VapixEvents.js} +1 -1
- package/cjs/node/WsClient.js +12 -9
- package/cjs/node/events/AxisCameraStationEvents.js +53 -0
- package/cjs/node/events/GenetecAgent.js +123 -0
- package/cjs/node/index.js +38 -5
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +92 -0
- package/cjs/types/CamOverlayAPI/accuweatherSchema.js +47 -0
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.js +72 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.js +9 -0
- package/cjs/types/CamOverlayAPI/index.js +27 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.js +26 -0
- package/cjs/types/CamOverlayAPI/pipSchema.js +39 -0
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.js +25 -0
- package/cjs/types/CamOverlayAPI/ptzSchema.js +12 -0
- package/cjs/types/CamOverlayAPI/scoreBoardSchema.js +132 -0
- package/cjs/types/CamOverlayAPI/screenSharingSchema.js +8 -0
- package/cjs/types/CamOverlayAPI/serviceCommonTypes.js +91 -0
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +8 -0
- package/cjs/types/CamOverlayDrawingAPI.js +2 -0
- package/cjs/types/CamOverlayPainter.js +14 -0
- package/cjs/types/CamScripterAPI.js +22 -7
- package/cjs/types/CamScripterAPICameraEventsGenerator.js +2 -0
- package/cjs/types/CamStreamerAPI.js +34 -3
- package/cjs/types/CamSwitcherAPI.js +38 -1
- package/cjs/types/CamSwitcherEvents.js +8 -0
- package/cjs/types/GenetecAgent.js +31 -0
- package/cjs/types/PlaneTrackerAPI.js +286 -0
- package/cjs/types/VapixAPI.js +71 -13
- package/cjs/types/VapixEvents.js +2 -0
- package/cjs/web/DefaultClient.js +22 -10
- package/cjs/web/WsClient.js +3 -3
- package/esm/CamOverlayAPI.js +131 -88
- package/esm/CamScripterAPI.js +48 -38
- package/esm/CamStreamerAPI.js +81 -38
- package/esm/CamSwitcherAPI.js +137 -119
- package/esm/CamSwitcherEvents.js +5 -61
- package/esm/PlaneTrackerAPI.js +206 -0
- package/esm/VapixAPI.js +315 -225
- package/esm/{CreatePackage.js → bin/CreatePackage.js} +3 -3
- package/esm/errors/errors.js +66 -0
- package/esm/index.js +12 -3
- package/esm/internal/ProxyClient.js +28 -32
- package/esm/internal/WsEvents.js +68 -0
- package/esm/internal/utils.js +17 -1
- package/esm/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +2 -2
- package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
- package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +2 -13
- package/esm/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +7 -5
- package/esm/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +2 -2
- package/esm/node/DefaultClient.js +10 -12
- package/esm/{internal → node}/Digest.js +1 -1
- package/esm/node/HttpRequestSender.js +14 -4
- package/esm/node/HttpServer.js +5 -5
- package/esm/{VapixEvents.js → node/VapixEvents.js} +1 -1
- package/esm/node/WsClient.js +3 -3
- package/esm/{events → node/events}/AxisCameraStationEvents.js +18 -13
- package/esm/node/events/GenetecAgent.js +119 -0
- package/esm/node/index.js +17 -2
- package/esm/types/CamOverlayAPI/CamOverlayAPI.js +76 -0
- package/esm/types/CamOverlayAPI/accuweatherSchema.js +44 -0
- package/esm/types/CamOverlayAPI/customGraphicsSchema.js +69 -0
- package/esm/types/CamOverlayAPI/imagesSchema.js +6 -0
- package/esm/types/CamOverlayAPI/index.js +11 -0
- package/esm/types/CamOverlayAPI/infotickerSchema.js +23 -0
- package/esm/types/CamOverlayAPI/pipSchema.js +36 -0
- package/esm/types/CamOverlayAPI/ptzCompassSchema.js +22 -0
- package/esm/types/CamOverlayAPI/ptzSchema.js +9 -0
- package/esm/types/CamOverlayAPI/scoreBoardSchema.js +129 -0
- package/esm/types/CamOverlayAPI/screenSharingSchema.js +5 -0
- package/esm/types/CamOverlayAPI/serviceCommonTypes.js +88 -0
- package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +5 -0
- package/esm/types/CamOverlayPainter.js +11 -0
- package/esm/types/CamScripterAPI.js +21 -6
- package/esm/types/CamScripterAPICameraEventsGenerator.js +1 -0
- package/esm/types/CamStreamerAPI.js +33 -2
- package/esm/types/CamSwitcherAPI.js +38 -1
- package/esm/types/CamSwitcherEvents.js +8 -0
- package/esm/types/GenetecAgent.js +28 -0
- package/esm/types/PlaneTrackerAPI.js +283 -0
- package/esm/types/VapixAPI.js +70 -12
- package/esm/types/VapixEvents.js +1 -0
- package/esm/web/DefaultClient.js +22 -10
- package/esm/web/WsClient.js +3 -3
- package/package.json +30 -12
- package/types/CamOverlayAPI.d.ts +865 -0
- package/types/CamScripterAPI.d.ts +47 -0
- package/types/CamStreamerAPI.d.ts +64 -0
- package/types/CamSwitcherAPI.d.ts +167 -0
- package/types/CamSwitcherEvents.d.ts +8 -0
- package/types/PlaneTrackerAPI.d.ts +230 -0
- package/types/VapixAPI.d.ts +118 -0
- package/types/bin/CreatePackage.d.ts +1 -0
- package/types/errors/errors.d.ts +68 -0
- package/types/index.d.ts +20 -0
- package/types/internal/ProxyClient.d.ts +10 -0
- package/types/internal/WsEvents.d.ts +41 -0
- package/types/internal/types.d.ts +45 -0
- package/{cjs → types}/internal/utils.d.ts +4 -1
- package/{cjs → types}/internal/versionCompare.d.ts +2 -2
- package/types/node/CamOverlayDrawingAPI.d.ts +41 -0
- package/{esm → types/node}/CamOverlayPainter/Frame.d.ts +8 -37
- package/{cjs → types/node}/CamOverlayPainter/Painter.d.ts +5 -21
- package/types/node/CamOverlayPainter/ResourceManager.d.ts +15 -0
- package/types/node/CamScripterAPICameraEventsGenerator.d.ts +31 -0
- package/types/node/DefaultClient.d.ts +16 -0
- package/{esm → types}/node/HttpRequestSender.d.ts +1 -0
- package/{cjs → types}/node/HttpServer.d.ts +2 -2
- package/types/node/VapixEvents.d.ts +16 -0
- package/{cjs → types}/node/WsClient.d.ts +3 -2
- package/types/node/events/AxisCameraStationEvents.d.ts +12 -0
- package/types/node/events/GenetecAgent.d.ts +16 -0
- package/types/node/index.d.ts +17 -0
- package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +4321 -0
- package/types/types/CamOverlayAPI/accuweatherSchema.d.ts +84 -0
- package/types/types/CamOverlayAPI/customGraphicsSchema.d.ts +700 -0
- package/types/types/CamOverlayAPI/imagesSchema.d.ts +95 -0
- package/types/types/CamOverlayAPI/index.d.ts +11 -0
- package/types/types/CamOverlayAPI/infotickerSchema.d.ts +96 -0
- package/types/types/CamOverlayAPI/pipSchema.d.ts +125 -0
- package/types/types/CamOverlayAPI/ptzCompassSchema.d.ts +93 -0
- package/types/types/CamOverlayAPI/ptzSchema.d.ts +118 -0
- package/types/types/CamOverlayAPI/scoreBoardSchema.d.ts +357 -0
- package/types/types/CamOverlayAPI/screenSharingSchema.d.ts +58 -0
- package/types/types/CamOverlayAPI/serviceCommonTypes.d.ts +145 -0
- package/types/types/CamOverlayAPI/webCameraSharingSchema.d.ts +58 -0
- package/types/types/CamOverlayDrawingAPI.d.ts +48 -0
- package/types/types/CamOverlayPainter.d.ts +76 -0
- package/types/types/CamScripterAPI.d.ts +130 -0
- package/types/types/CamScripterAPICameraEventsGenerator.d.ts +45 -0
- package/types/types/CamStreamerAPI.d.ts +272 -0
- package/{esm → types}/types/CamSwitcherAPI.d.ts +115 -36
- package/{cjs → types}/types/CamSwitcherEvents.d.ts +77 -0
- package/{esm/events → types/types}/GenetecAgent.d.ts +47 -47
- package/types/types/PlaneTrackerAPI.d.ts +890 -0
- package/{cjs → types}/types/VapixAPI.d.ts +647 -465
- package/types/types/VapixEvents.d.ts +15 -0
- package/{esm → types}/types/common.d.ts +15 -5
- package/types/web/DefaultClient.d.ts +6 -0
- package/cjs/CamOverlayAPI.d.ts +0 -31
- package/cjs/CamOverlayDrawingAPI.d.ts +0 -86
- package/cjs/CamOverlayPainter/Frame.d.ts +0 -96
- package/cjs/CamOverlayPainter/ResourceManager.d.ts +0 -14
- package/cjs/CamOverlayPainter/ResourceManager.js +0 -46
- package/cjs/CamScripterAPI.d.ts +0 -19
- package/cjs/CamScripterAPICameraEventsGenerator.d.ts +0 -74
- package/cjs/CamStreamerAPI.d.ts +0 -16
- package/cjs/CamSwitcherAPI.d.ts +0 -48
- package/cjs/CamSwitcherEvents.d.ts +0 -18
- package/cjs/VapixAPI.d.ts +0 -66
- package/cjs/VapixEvents.d.ts +0 -43
- package/cjs/errors/errors.d.ts +0 -34
- package/cjs/events/AxisCameraStationEvents.d.ts +0 -9
- package/cjs/events/AxisCameraStationEvents.js +0 -48
- package/cjs/events/GenetecAgent.d.ts +0 -174
- package/cjs/events/GenetecAgent.js +0 -123
- package/cjs/index.d.ts +0 -11
- package/cjs/internal/ProxyClient.d.ts +0 -11
- package/cjs/internal/common.d.ts +0 -39
- package/cjs/internal/common.js +0 -27
- package/cjs/node/DefaultClient.d.ts +0 -15
- package/cjs/node/HttpRequestSender.d.ts +0 -28
- package/cjs/node/WsEventClient.d.ts +0 -13
- package/cjs/node/WsEventClient.js +0 -22
- package/cjs/types/CamOverlayAPI.d.ts +0 -188
- package/cjs/types/CamOverlayAPI.js +0 -47
- package/cjs/types/CamScripterAPI.d.ts +0 -67
- package/cjs/types/CamStreamerAPI.d.ts +0 -139
- package/cjs/types/CamSwitcherAPI.d.ts +0 -814
- package/cjs/types/common.d.ts +0 -37
- package/cjs/web/DefaultClient.d.ts +0 -6
- package/cjs/web/index.d.ts +0 -2
- package/esm/CamOverlayAPI.d.ts +0 -31
- package/esm/CamOverlayDrawingAPI.d.ts +0 -86
- package/esm/CamOverlayPainter/Painter.d.ts +0 -48
- package/esm/CamOverlayPainter/ResourceManager.d.ts +0 -14
- package/esm/CamScripterAPI.d.ts +0 -19
- package/esm/CamScripterAPICameraEventsGenerator.d.ts +0 -74
- package/esm/CamStreamerAPI.d.ts +0 -16
- package/esm/CamSwitcherAPI.d.ts +0 -48
- package/esm/CamSwitcherEvents.d.ts +0 -18
- package/esm/VapixAPI.d.ts +0 -66
- package/esm/VapixEvents.d.ts +0 -43
- package/esm/errors/errors.d.ts +0 -34
- package/esm/events/AxisCameraStationEvents.d.ts +0 -9
- package/esm/events/GenetecAgent.js +0 -119
- package/esm/index.d.ts +0 -11
- package/esm/internal/Digest.d.ts +0 -4
- package/esm/internal/ProxyClient.d.ts +0 -11
- package/esm/internal/common.d.ts +0 -39
- package/esm/internal/common.js +0 -20
- package/esm/internal/constants.d.ts +0 -1
- package/esm/internal/transformers.d.ts +0 -5
- package/esm/internal/utils.d.ts +0 -11
- package/esm/internal/versionCompare.d.ts +0 -6
- package/esm/node/DefaultClient.d.ts +0 -15
- package/esm/node/HttpServer.d.ts +0 -21
- package/esm/node/WsClient.d.ts +0 -39
- package/esm/node/WsEventClient.d.ts +0 -13
- package/esm/node/WsEventClient.js +0 -18
- package/esm/node/index.d.ts +0 -2
- package/esm/types/CamOverlayAPI.d.ts +0 -188
- package/esm/types/CamOverlayAPI.js +0 -44
- package/esm/types/CamScripterAPI.d.ts +0 -67
- package/esm/types/CamStreamerAPI.d.ts +0 -139
- package/esm/types/CamSwitcherEvents.d.ts +0 -491
- package/esm/types/VapixAPI.d.ts +0 -1683
- package/esm/web/DefaultClient.d.ts +0 -6
- package/esm/web/WsClient.d.ts +0 -13
- package/esm/web/index.d.ts +0 -2
- /package/{cjs/CreatePackage.d.ts → esm/internal/types.js} +0 -0
- /package/esm/{CreatePackage.d.ts → types/CamOverlayDrawingAPI.js} +0 -0
- /package/{cjs → types}/internal/constants.d.ts +0 -0
- /package/{cjs → types}/internal/transformers.d.ts +0 -0
- /package/{cjs/internal → types/node}/Digest.d.ts +0 -0
- /package/{cjs → types}/web/WsClient.d.ts +0 -0
- /package/{cjs/node → types/web}/index.d.ts +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export const nodeStateSchema = z.object({
|
|
3
|
+
node_state: z.union([z.literal('OK'), z.literal('NOT_INSTALLED'), z.literal('NOT_FOUND')]),
|
|
4
|
+
});
|
|
2
5
|
export const packageInfoListSchema = z.array(z.object({
|
|
3
6
|
storage: z.union([z.literal('SD_CARD'), z.literal('INTERNAL')]),
|
|
4
7
|
manifest: z.object({
|
|
@@ -6,12 +9,24 @@ export const packageInfoListSchema = z.array(z.object({
|
|
|
6
9
|
package_menu_name: z.string(),
|
|
7
10
|
package_version: z.string(),
|
|
8
11
|
vendor: z.string(),
|
|
9
|
-
required_camscripter_version: z.string(),
|
|
10
|
-
required_camscripter_rbi_version: z.string(),
|
|
12
|
+
required_camscripter_version: z.string().optional(),
|
|
13
|
+
required_camscripter_rbi_version: z.string().optional(),
|
|
11
14
|
ui_link: z.string(),
|
|
12
15
|
}),
|
|
13
16
|
}));
|
|
14
|
-
export const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})
|
|
17
|
+
export const packageConfigSchema = z.record(z.string(), z.object({ enabled: z.boolean() }));
|
|
18
|
+
export const cameraStorageSchema = z.union([
|
|
19
|
+
z.tuple([
|
|
20
|
+
z.object({ type: z.literal('INTERNAL'), capacity_mb: z.number() }),
|
|
21
|
+
z.object({ type: z.literal('SD_CARD'), capacity_mb: z.number() }),
|
|
22
|
+
]),
|
|
23
|
+
z.tuple([z.object({ type: z.literal('INTERNAL'), capacity_mb: z.number() })]),
|
|
24
|
+
]);
|
|
25
|
+
export const camscripterApiResponseSchema = z.object({
|
|
26
|
+
status: z.number(),
|
|
27
|
+
message: z.string(),
|
|
28
|
+
});
|
|
29
|
+
export const cameraTimeResponseSchema = z.object({
|
|
30
|
+
state: z.boolean(),
|
|
31
|
+
code: z.number(),
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const
|
|
2
|
+
export const cameraStreamSchema = z.object({
|
|
3
3
|
enabled: z.string(),
|
|
4
4
|
active: z.string(),
|
|
5
5
|
audioSource: z.string(),
|
|
@@ -22,4 +22,35 @@ export const streamAttributesSchema = z.object({
|
|
|
22
22
|
startTime: z.string(),
|
|
23
23
|
stopTime: z.string(),
|
|
24
24
|
});
|
|
25
|
-
export const
|
|
25
|
+
export const streamSchema = z.object({
|
|
26
|
+
enabled: z.union([z.literal(0), z.literal(1)]),
|
|
27
|
+
active: z.union([z.literal(0), z.literal(1)]),
|
|
28
|
+
audioSource: z.string(),
|
|
29
|
+
avSyncMsec: z.number().int(),
|
|
30
|
+
internalVapixParameters: z.string(),
|
|
31
|
+
userVapixParameters: z.string(),
|
|
32
|
+
outputParameters: z.string(),
|
|
33
|
+
outputType: z.union([z.literal('video'), z.literal('images'), z.literal('none')]),
|
|
34
|
+
mediaServerUrl: z.string(),
|
|
35
|
+
inputType: z.union([z.literal('CSw'), z.literal('CRS'), z.literal('RTSP_URL')]),
|
|
36
|
+
inputUrl: z.string(),
|
|
37
|
+
forceStereo: z.union([z.literal(0), z.literal(1)]),
|
|
38
|
+
streamDelay: z.number().nullable(),
|
|
39
|
+
statusLed: z.number(),
|
|
40
|
+
statusPort: z.string(),
|
|
41
|
+
callApi: z.number().int(),
|
|
42
|
+
trigger: z.string(),
|
|
43
|
+
schedule: z.string(),
|
|
44
|
+
prepareAhead: z.number().int(),
|
|
45
|
+
startTime: z.number().nullable(),
|
|
46
|
+
stopTime: z.number().nullable(),
|
|
47
|
+
});
|
|
48
|
+
export const cameraStreamResponseSchema = z.object({
|
|
49
|
+
data: cameraStreamSchema,
|
|
50
|
+
code: z.number(),
|
|
51
|
+
message: z.string(),
|
|
52
|
+
});
|
|
53
|
+
export const camstreamerServerResponseSchema = z.object({
|
|
54
|
+
code: z.number(),
|
|
55
|
+
message: z.string(),
|
|
56
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { toCamelCase, toCamelCaseDeep } from '../internal/transformers';
|
|
3
|
-
import { storageTypeSchema, keyboardShortcutsSchema, h264ProfileSchema, audioChannelCountSchema, } from './common';
|
|
3
|
+
import { storageTypeSchema, keyboardShortcutsSchema, h264ProfileSchema, audioChannelCountSchema, keyboardShortcutSchema, } from './common';
|
|
4
4
|
const channelTypeSchema = z.union([z.literal('audio'), z.literal('video'), z.literal('av')]);
|
|
5
5
|
const playlistPlayTypeSchema = z.union([
|
|
6
6
|
z.literal('PLAY_ALL'),
|
|
@@ -132,3 +132,40 @@ export const clipListSchema = z.object({
|
|
|
132
132
|
])),
|
|
133
133
|
})),
|
|
134
134
|
});
|
|
135
|
+
export const bitrateModeSchema = z.union([z.literal('VBR'), z.literal('MBR'), z.literal('ABR')]);
|
|
136
|
+
export const bitrateVapixParamsSchema = z.object({
|
|
137
|
+
bitrateMode: bitrateModeSchema,
|
|
138
|
+
maximumBitRate: z.number(),
|
|
139
|
+
retentionTime: z.number(),
|
|
140
|
+
bitRateLimit: z.number(),
|
|
141
|
+
});
|
|
142
|
+
export const cameraOptionsSchema = bitrateVapixParamsSchema
|
|
143
|
+
.extend({
|
|
144
|
+
resolution: z.string(),
|
|
145
|
+
h264Profile: h264ProfileSchema,
|
|
146
|
+
fps: z.number(),
|
|
147
|
+
compression: z.number().min(0).max(100),
|
|
148
|
+
govLength: z.number(),
|
|
149
|
+
bitrateVapixParams: z.string().nullable(),
|
|
150
|
+
audioSampleRate: z.number(),
|
|
151
|
+
audioChannelCount: audioChannelCountSchema,
|
|
152
|
+
keyboard: z.object({
|
|
153
|
+
fromSource: keyboardShortcutSchema,
|
|
154
|
+
none: keyboardShortcutSchema,
|
|
155
|
+
}),
|
|
156
|
+
})
|
|
157
|
+
.partial();
|
|
158
|
+
export const globalAudioSettingsTypeSchema = z.union([z.literal('fromSource'), z.literal('source')]);
|
|
159
|
+
export const globalAudioSettingsSchema = z.object({
|
|
160
|
+
type: globalAudioSettingsTypeSchema,
|
|
161
|
+
source: z.string(),
|
|
162
|
+
storage: z.string().optional(),
|
|
163
|
+
});
|
|
164
|
+
export const secondaryAudioSettingsSchema = z.object({
|
|
165
|
+
type: z.union([z.literal('CLIP'), z.literal('STREAM'), z.literal('NONE')]),
|
|
166
|
+
streamName: z.string().optional(),
|
|
167
|
+
clipName: z.string().optional(),
|
|
168
|
+
storage: storageTypeSchema,
|
|
169
|
+
secondaryAudioLevel: z.number(),
|
|
170
|
+
masterAudioLevel: z.number(),
|
|
171
|
+
});
|
|
@@ -16,6 +16,14 @@ const cswEventsDataSchema = z.discriminatedUnion('type', [
|
|
|
16
16
|
clip_name: z.string().optional(),
|
|
17
17
|
master_audio: z.boolean(),
|
|
18
18
|
}),
|
|
19
|
+
z.object({
|
|
20
|
+
type: z.literal('StreamSwitchVideoError'),
|
|
21
|
+
playlist_name: z.string(),
|
|
22
|
+
playlist_active_stream: z.number(),
|
|
23
|
+
stream_name: z.string().optional(),
|
|
24
|
+
clip_name: z.string().optional(),
|
|
25
|
+
info: z.string(),
|
|
26
|
+
}),
|
|
19
27
|
z.object({
|
|
20
28
|
type: z.literal('StreamSwitchAudioError'),
|
|
21
29
|
stream_name: z.string().optional(),
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const successResponseSchema = z.object({
|
|
3
|
+
Rsp: z.object({
|
|
4
|
+
Status: z.literal('Ok'),
|
|
5
|
+
}),
|
|
6
|
+
});
|
|
7
|
+
export const cameraGuidsResponseSchema = z.object({
|
|
8
|
+
Rsp: z.object({
|
|
9
|
+
Status: z.literal('Ok'),
|
|
10
|
+
Result: z.array(z.object({ Guid: z.string() })),
|
|
11
|
+
}),
|
|
12
|
+
});
|
|
13
|
+
export const cameraDetailSchema = z.object({
|
|
14
|
+
Guid: z.string().optional(),
|
|
15
|
+
Name: z.string().optional(),
|
|
16
|
+
EntityType: z.string().optional(),
|
|
17
|
+
});
|
|
18
|
+
export const cameraDetailsResponseSchema = z.object({
|
|
19
|
+
Rsp: z.object({
|
|
20
|
+
Status: z.literal('Ok'),
|
|
21
|
+
Result: z.union([z.array(cameraDetailSchema), cameraDetailSchema]),
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
export const cameraListSchema = z.array(z.object({
|
|
25
|
+
index: z.number(),
|
|
26
|
+
value: z.string(),
|
|
27
|
+
label: z.string(),
|
|
28
|
+
}));
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const wsAliasResponseSchema = z.object({
|
|
3
|
+
alias: z.string(),
|
|
4
|
+
ws: z.string(),
|
|
5
|
+
ws_initial_message: z.string(),
|
|
6
|
+
});
|
|
7
|
+
export const connectionSchema = z.object({
|
|
8
|
+
protocol: z.union([z.literal('http'), z.literal('https'), z.literal('https_insecure')]),
|
|
9
|
+
ip: z.union([z.string().ip(), z.literal('')]),
|
|
10
|
+
port: z.number().positive().lt(65535),
|
|
11
|
+
user: z.string(),
|
|
12
|
+
pass: z.string(),
|
|
13
|
+
});
|
|
14
|
+
export const widgetSchema = z.object({
|
|
15
|
+
enabled: z.boolean().default(true),
|
|
16
|
+
coord: z.union([
|
|
17
|
+
z.literal('top_left'),
|
|
18
|
+
z.literal('top_right'),
|
|
19
|
+
z.literal('bottom_left'),
|
|
20
|
+
z.literal('bottom_right'),
|
|
21
|
+
]),
|
|
22
|
+
posX: z.number().nonnegative(),
|
|
23
|
+
posY: z.number().nonnegative(),
|
|
24
|
+
scale: z.number().positive(),
|
|
25
|
+
});
|
|
26
|
+
const labelOptionsSchema = z.union([
|
|
27
|
+
z.literal('blank'),
|
|
28
|
+
z.literal('registration'),
|
|
29
|
+
z.literal('call_sign'),
|
|
30
|
+
z.literal('flight_number'),
|
|
31
|
+
z.literal('icao'),
|
|
32
|
+
]);
|
|
33
|
+
const identificationLabelSchema = z.object({
|
|
34
|
+
firstRow: labelOptionsSchema,
|
|
35
|
+
secondRow: labelOptionsSchema,
|
|
36
|
+
thirdRow: labelOptionsSchema,
|
|
37
|
+
fourthRow: labelOptionsSchema,
|
|
38
|
+
opacity: z.number().positive(),
|
|
39
|
+
});
|
|
40
|
+
export const cameraSettingsSchema = z.object({
|
|
41
|
+
units: z.union([z.literal('metric'), z.literal('imperial')]).default('imperial'),
|
|
42
|
+
adsbSource: z
|
|
43
|
+
.object({
|
|
44
|
+
ip: z.union([z.string().ip(), z.literal('')]),
|
|
45
|
+
port: z.number().positive().lt(65535),
|
|
46
|
+
})
|
|
47
|
+
.default({ ip: '', port: 30334 }),
|
|
48
|
+
camera: connectionSchema.default({
|
|
49
|
+
protocol: 'http',
|
|
50
|
+
ip: '127.0.0.1',
|
|
51
|
+
port: 80,
|
|
52
|
+
user: 'root',
|
|
53
|
+
pass: '',
|
|
54
|
+
}),
|
|
55
|
+
cameraCalibrationProcessConfig: z
|
|
56
|
+
.object({
|
|
57
|
+
nightSkyCalibrationEnabled: z.boolean(),
|
|
58
|
+
scheduleNightSkyCalibrationTimestamp: z.number(),
|
|
59
|
+
})
|
|
60
|
+
.default({ nightSkyCalibrationEnabled: false, scheduleNightSkyCalibrationTimestamp: 0 }),
|
|
61
|
+
cameraConfig: z
|
|
62
|
+
.object({
|
|
63
|
+
maxZoomLevel: z.number().optional(),
|
|
64
|
+
defaultCaptureSizeMeters: z.number().positive().default(120),
|
|
65
|
+
captureSizeExtensionMeters: z.number().positive().default(80),
|
|
66
|
+
})
|
|
67
|
+
.default({
|
|
68
|
+
maxZoomLevel: 30,
|
|
69
|
+
defaultCaptureSizeMeters: 120,
|
|
70
|
+
captureSizeExtensionMeters: 80,
|
|
71
|
+
}),
|
|
72
|
+
stream: z
|
|
73
|
+
.object({
|
|
74
|
+
width: z.number().positive(),
|
|
75
|
+
height: z.number().positive(),
|
|
76
|
+
})
|
|
77
|
+
.default({ width: 1920, height: 1080 }),
|
|
78
|
+
imageConfig: z
|
|
79
|
+
.object({
|
|
80
|
+
dayAperture: z.number().nonnegative().min(0).max(100),
|
|
81
|
+
nightAperture: z.number().nonnegative().min(0).max(100),
|
|
82
|
+
})
|
|
83
|
+
.default({ dayAperture: 50, nightAperture: 0 }),
|
|
84
|
+
airportConfig: z
|
|
85
|
+
.object({
|
|
86
|
+
icao: z.string().default(''),
|
|
87
|
+
centerLat: z.number(),
|
|
88
|
+
centerLon: z.number(),
|
|
89
|
+
radius: z.number().nonnegative().default(10000),
|
|
90
|
+
})
|
|
91
|
+
.default({
|
|
92
|
+
icao: '',
|
|
93
|
+
centerLat: 0,
|
|
94
|
+
centerLon: 0,
|
|
95
|
+
radius: 10000,
|
|
96
|
+
}),
|
|
97
|
+
trackingConfig: z
|
|
98
|
+
.object({
|
|
99
|
+
prioritizeEmergency: z.boolean(),
|
|
100
|
+
guardTourEnabled: z.boolean().default(false),
|
|
101
|
+
guardTourId: z.number().int().nonnegative().default(0),
|
|
102
|
+
})
|
|
103
|
+
.default({ prioritizeEmergency: true, guardTourEnabled: false, guardTourId: 0 }),
|
|
104
|
+
overlayText: z
|
|
105
|
+
.object({
|
|
106
|
+
displayIcao: z.boolean().optional(),
|
|
107
|
+
displayRegistration: z.boolean().optional(),
|
|
108
|
+
displayFlightNumber: z.boolean().optional(),
|
|
109
|
+
displayAltitude: z.boolean().optional(),
|
|
110
|
+
displayVelocity: z.boolean().optional(),
|
|
111
|
+
displayDistance: z.boolean().optional(),
|
|
112
|
+
displayFOV: z.boolean().optional(),
|
|
113
|
+
displayPTError: z.boolean().optional(),
|
|
114
|
+
displayPTZSpeed: z.boolean().optional(),
|
|
115
|
+
displayVelocityData: z.boolean().optional(),
|
|
116
|
+
displaySignalQuality: z.boolean().optional(),
|
|
117
|
+
displayAutoTrackingInfo: z.boolean().optional(),
|
|
118
|
+
displayGPSCoords: z.boolean().optional(),
|
|
119
|
+
displayVapixQuery: z.boolean().optional(),
|
|
120
|
+
displayFocus: z.boolean().optional(),
|
|
121
|
+
displayAperture: z.boolean().optional(),
|
|
122
|
+
displaySunDistance: z.boolean().optional(),
|
|
123
|
+
displayTickTime: z.boolean().optional(),
|
|
124
|
+
displayAircraftInfo: z.boolean().optional(),
|
|
125
|
+
})
|
|
126
|
+
.optional(),
|
|
127
|
+
widget: widgetSchema.default({
|
|
128
|
+
enabled: true,
|
|
129
|
+
coord: 'top_right',
|
|
130
|
+
posX: 10,
|
|
131
|
+
posY: 10,
|
|
132
|
+
scale: 100,
|
|
133
|
+
}),
|
|
134
|
+
airportWidget: widgetSchema.default({
|
|
135
|
+
enabled: true,
|
|
136
|
+
coord: 'top_left',
|
|
137
|
+
posX: 10,
|
|
138
|
+
posY: 10,
|
|
139
|
+
scale: 100,
|
|
140
|
+
}),
|
|
141
|
+
fr24FlightInfoSource: z
|
|
142
|
+
.object({
|
|
143
|
+
enabled: z.boolean().default(false),
|
|
144
|
+
priority: z.number().int().positive().default(1),
|
|
145
|
+
apiToken: z.string().default(''),
|
|
146
|
+
validateFlights: z.boolean().default(true),
|
|
147
|
+
})
|
|
148
|
+
.default({
|
|
149
|
+
enabled: false,
|
|
150
|
+
priority: 1,
|
|
151
|
+
apiToken: '',
|
|
152
|
+
validateFlights: true,
|
|
153
|
+
}),
|
|
154
|
+
radarcapeFlightInfoSource: z
|
|
155
|
+
.object({
|
|
156
|
+
enabled: z.boolean().default(false),
|
|
157
|
+
priority: z.number().int().positive().default(2),
|
|
158
|
+
ip: z.union([z.string().ip(), z.literal('')]).default(''),
|
|
159
|
+
port: z.number().positive().lt(65535).default(80),
|
|
160
|
+
})
|
|
161
|
+
.default({
|
|
162
|
+
enabled: false,
|
|
163
|
+
priority: 2,
|
|
164
|
+
ip: '',
|
|
165
|
+
port: 80,
|
|
166
|
+
}),
|
|
167
|
+
identificationLabel: identificationLabelSchema.default({
|
|
168
|
+
firstRow: 'registration',
|
|
169
|
+
secondRow: 'blank',
|
|
170
|
+
thirdRow: 'blank',
|
|
171
|
+
fourthRow: 'blank',
|
|
172
|
+
opacity: 30,
|
|
173
|
+
}),
|
|
174
|
+
acs: connectionSchema
|
|
175
|
+
.extend({
|
|
176
|
+
enabled: z.boolean(),
|
|
177
|
+
sourceKey: z.string(),
|
|
178
|
+
})
|
|
179
|
+
.default({
|
|
180
|
+
enabled: false,
|
|
181
|
+
protocol: 'https_insecure',
|
|
182
|
+
ip: '',
|
|
183
|
+
port: 29204,
|
|
184
|
+
user: '',
|
|
185
|
+
pass: '',
|
|
186
|
+
sourceKey: '',
|
|
187
|
+
}),
|
|
188
|
+
genetec: connectionSchema
|
|
189
|
+
.extend({
|
|
190
|
+
enabled: z.boolean(),
|
|
191
|
+
baseUri: z.string().default(''),
|
|
192
|
+
appId: z.string().default(''),
|
|
193
|
+
cameraList: z.string().array().default([]),
|
|
194
|
+
})
|
|
195
|
+
.default({
|
|
196
|
+
enabled: false,
|
|
197
|
+
protocol: 'http',
|
|
198
|
+
ip: '',
|
|
199
|
+
port: 4590,
|
|
200
|
+
user: '',
|
|
201
|
+
pass: '',
|
|
202
|
+
baseUri: 'WebSdk',
|
|
203
|
+
appId: '',
|
|
204
|
+
cameraList: [],
|
|
205
|
+
}),
|
|
206
|
+
});
|
|
207
|
+
export const serverSettingsSchema = z.object({
|
|
208
|
+
cameraCalibration: z.object({
|
|
209
|
+
posLat: z.number(),
|
|
210
|
+
posLon: z.number(),
|
|
211
|
+
geoidHN: z.number(),
|
|
212
|
+
altitudeAmsl: z.number(),
|
|
213
|
+
rotationEast: z.number(),
|
|
214
|
+
rotationNorth: z.number(),
|
|
215
|
+
rotationUp: z.number(),
|
|
216
|
+
tiltTransformationCoefA: z.number(),
|
|
217
|
+
tiltCameraKnownPoint: z.number(),
|
|
218
|
+
tiltRealKnownPoint: z.number(),
|
|
219
|
+
}),
|
|
220
|
+
});
|
|
221
|
+
export const trackingModeSchema = z.object({
|
|
222
|
+
mode: z.union([z.literal('MANUAL'), z.literal('AUTOMATIC')]),
|
|
223
|
+
});
|
|
224
|
+
export const flightInfoSchema = z.object({
|
|
225
|
+
callsign: z.string().optional(),
|
|
226
|
+
flightNumber: z.string().optional(),
|
|
227
|
+
registration: z.string().optional(),
|
|
228
|
+
aircraftType: z.string().optional(),
|
|
229
|
+
airlines: z.string().optional(),
|
|
230
|
+
originAirport: z
|
|
231
|
+
.object({
|
|
232
|
+
icao: z.string().optional(),
|
|
233
|
+
iata: z.string().optional(),
|
|
234
|
+
city: z.string().optional(),
|
|
235
|
+
})
|
|
236
|
+
.optional(),
|
|
237
|
+
destinationAirport: z.object({
|
|
238
|
+
icao: z.string().optional(),
|
|
239
|
+
iata: z.string().optional(),
|
|
240
|
+
city: z.string().optional(),
|
|
241
|
+
}),
|
|
242
|
+
flightImages: z
|
|
243
|
+
.array(z.object({
|
|
244
|
+
src: z.string().optional(),
|
|
245
|
+
photographer: z.string().optional(),
|
|
246
|
+
}))
|
|
247
|
+
.optional(),
|
|
248
|
+
});
|
|
249
|
+
export const priorityListSchema = z.object({
|
|
250
|
+
priorityList: z.array(z.string()).default([]),
|
|
251
|
+
});
|
|
252
|
+
export const whiteListSchema = z.object({
|
|
253
|
+
whiteList: z.array(z.string()).default([]),
|
|
254
|
+
});
|
|
255
|
+
export const blackListSchema = z.object({
|
|
256
|
+
blackList: z.array(z.string()).default([]),
|
|
257
|
+
});
|
|
258
|
+
export const mapTypeSchema = z.enum(['roadmap', 'satellite']);
|
|
259
|
+
export const mapInfoSchema = z.object({
|
|
260
|
+
minZoom: z.number().nonnegative(),
|
|
261
|
+
maxZoom: z.number().nonnegative(),
|
|
262
|
+
mapTypes: z.array(mapTypeSchema),
|
|
263
|
+
tileSize: z.number().nonnegative(),
|
|
264
|
+
});
|
|
265
|
+
export const zonesSchema = z.object({
|
|
266
|
+
zones: z
|
|
267
|
+
.array(z.object({
|
|
268
|
+
enabled: z.boolean().default(true),
|
|
269
|
+
name: z.string().optional(),
|
|
270
|
+
area: z
|
|
271
|
+
.array(z.object({
|
|
272
|
+
lat: z.number(),
|
|
273
|
+
lon: z.number(),
|
|
274
|
+
}))
|
|
275
|
+
.nonempty(),
|
|
276
|
+
minAltitudeAmsl: z.number().optional(),
|
|
277
|
+
maxAltitudeAmsl: z.number().optional(),
|
|
278
|
+
minSpeedKmph: z.number().optional(),
|
|
279
|
+
maxSpeedKmph: z.number().optional(),
|
|
280
|
+
weight: z.number(),
|
|
281
|
+
}))
|
|
282
|
+
.default([]),
|
|
283
|
+
});
|
package/esm/types/VapixAPI.js
CHANGED
|
@@ -12,6 +12,19 @@ export const applicationSchema = z.object({
|
|
|
12
12
|
VendorHomePage: z.string().optional(),
|
|
13
13
|
LicenseName: z.string().optional(),
|
|
14
14
|
});
|
|
15
|
+
export const applicationListSchema = z.array(applicationSchema.extend({
|
|
16
|
+
appId: z
|
|
17
|
+
.union([
|
|
18
|
+
z.literal('CamStreamer'),
|
|
19
|
+
z.literal('CamSwitcher'),
|
|
20
|
+
z.literal('CamOverlay'),
|
|
21
|
+
z.literal('CamScripter'),
|
|
22
|
+
z.literal('PlaneTracker'),
|
|
23
|
+
z.literal('Ndihxplugin'),
|
|
24
|
+
z.literal('SportTracker'),
|
|
25
|
+
])
|
|
26
|
+
.nullable(),
|
|
27
|
+
}));
|
|
15
28
|
export const APP_IDS = [
|
|
16
29
|
'CamStreamer',
|
|
17
30
|
'CamSwitcher',
|
|
@@ -19,15 +32,8 @@ export const APP_IDS = [
|
|
|
19
32
|
'CamScripter',
|
|
20
33
|
'PlaneTracker',
|
|
21
34
|
'Ndihxplugin',
|
|
35
|
+
'SportTracker',
|
|
22
36
|
];
|
|
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
37
|
export const guardTourSchema = z.object({
|
|
32
38
|
id: z.string(),
|
|
33
39
|
camNbr: z.unknown(),
|
|
@@ -49,7 +55,12 @@ const audioSampleRatesSchema = z.object({
|
|
|
49
55
|
});
|
|
50
56
|
const audioSampleRatesOutSchema = audioSampleRatesSchema.transform(toCamelCaseDeep);
|
|
51
57
|
export const sdCardWatchedStatuses = ['OK', 'connected', 'disconnected'];
|
|
52
|
-
export const
|
|
58
|
+
export const sdCardInfoSchema = z.object({
|
|
59
|
+
status: z.enum(sdCardWatchedStatuses),
|
|
60
|
+
totalSize: z.number(),
|
|
61
|
+
freeSize: z.number(),
|
|
62
|
+
});
|
|
63
|
+
export const ptzOverviewSchema = z.record(z.number(), z.array(z.object({ id: z.number(), name: z.string() })));
|
|
53
64
|
export const cameraPTZItemDataSchema = z.object({
|
|
54
65
|
pan: z.number().optional(),
|
|
55
66
|
tilt: z.number().optional(),
|
|
@@ -67,7 +78,7 @@ export const audioDeviceSignalingChannelTypeSchema = z.object({
|
|
|
67
78
|
});
|
|
68
79
|
export const audioDeviceSignalingTypeSchema = z.object({
|
|
69
80
|
id: z.string(),
|
|
70
|
-
powerType: z.string(),
|
|
81
|
+
powerType: z.string().optional(),
|
|
71
82
|
channels: z.array(audioDeviceSignalingChannelTypeSchema),
|
|
72
83
|
});
|
|
73
84
|
export const audioDeviceConnectionTypeSchema = z.object({
|
|
@@ -94,7 +105,9 @@ const audioDeviceFromRequestSchema = z.object({
|
|
|
94
105
|
inputs: z.array(audioDeviceInputOutputSchema).optional(),
|
|
95
106
|
outputs: z.array(audioDeviceInputOutputSchema).optional(),
|
|
96
107
|
});
|
|
97
|
-
export const audioDeviceRequestSchema = z.object({
|
|
108
|
+
export const audioDeviceRequestSchema = z.object({
|
|
109
|
+
data: z.object({ devices: z.array(audioDeviceFromRequestSchema) }),
|
|
110
|
+
});
|
|
98
111
|
export const maxFpsResponseSchema = z.object({
|
|
99
112
|
data: z
|
|
100
113
|
.array(z.object({
|
|
@@ -112,9 +125,23 @@ export const dateTimeinfoSchema = z.object({
|
|
|
112
125
|
dstEnabled: z.boolean(),
|
|
113
126
|
localDateTime: z.string(),
|
|
114
127
|
posixTimeZone: z.string(),
|
|
115
|
-
timeZone: z.string(),
|
|
128
|
+
timeZone: z.string().optional(),
|
|
116
129
|
}),
|
|
117
130
|
});
|
|
131
|
+
export const timeZoneSchema = z.discriminatedUnion('status', [
|
|
132
|
+
z.object({
|
|
133
|
+
status: z.literal('success'),
|
|
134
|
+
data: z.object({
|
|
135
|
+
activeTimeZone: z.string(),
|
|
136
|
+
}),
|
|
137
|
+
}),
|
|
138
|
+
z.object({
|
|
139
|
+
status: z.literal('error'),
|
|
140
|
+
error: z.object({
|
|
141
|
+
message: z.string(),
|
|
142
|
+
}),
|
|
143
|
+
}),
|
|
144
|
+
]);
|
|
118
145
|
export const audioSampleRatesResponseSchema = z.object({
|
|
119
146
|
data: z.object({
|
|
120
147
|
encoders: z
|
|
@@ -125,3 +152,34 @@ export const audioSampleRatesResponseSchema = z.object({
|
|
|
125
152
|
.partial(),
|
|
126
153
|
}),
|
|
127
154
|
});
|
|
155
|
+
export const portStatusSchema = z.object({
|
|
156
|
+
port: z.string(),
|
|
157
|
+
state: z.enum(['open', 'closed']),
|
|
158
|
+
configurable: z.boolean(),
|
|
159
|
+
readonly: z.boolean().optional(),
|
|
160
|
+
usage: z.string(),
|
|
161
|
+
direction: z.enum(['input', 'output']),
|
|
162
|
+
name: z.string(),
|
|
163
|
+
normalState: z.enum(['open', 'closed']),
|
|
164
|
+
});
|
|
165
|
+
export const getPortsResponseSchema = z.object({
|
|
166
|
+
apiVersion: z.string(),
|
|
167
|
+
context: z.string(),
|
|
168
|
+
method: z.literal('getPorts'),
|
|
169
|
+
data: z.object({
|
|
170
|
+
numberOfPorts: z.number(),
|
|
171
|
+
items: z.array(portStatusSchema),
|
|
172
|
+
}),
|
|
173
|
+
});
|
|
174
|
+
export const portSetSchema = z.object({
|
|
175
|
+
port: z.string(),
|
|
176
|
+
state: z.enum(['open', 'closed']),
|
|
177
|
+
usage: z.string().optional(),
|
|
178
|
+
direction: z.enum(['input', 'output']).optional(),
|
|
179
|
+
name: z.string().optional(),
|
|
180
|
+
normalState: z.enum(['open', 'closed']).optional(),
|
|
181
|
+
});
|
|
182
|
+
export const portSequenceStateSchema = z.object({
|
|
183
|
+
state: z.enum(['open', 'closed']),
|
|
184
|
+
time: z.number().min(0).max(65535),
|
|
185
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/web/DefaultClient.js
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import { addParametersToPath } from '../internal/utils';
|
|
2
2
|
export class DefaultClient {
|
|
3
|
-
get
|
|
4
|
-
return
|
|
3
|
+
get = (params) => {
|
|
4
|
+
return this.fetchWithTimeout(addParametersToPath(params.path, params.parameters), {
|
|
5
5
|
method: 'GET',
|
|
6
|
-
headers: headers,
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
post
|
|
10
|
-
return
|
|
6
|
+
headers: params.headers,
|
|
7
|
+
}, params.timeout);
|
|
8
|
+
};
|
|
9
|
+
post = (params) => {
|
|
10
|
+
return this.fetchWithTimeout(addParametersToPath(params.path, params.parameters), {
|
|
11
11
|
method: 'POST',
|
|
12
|
-
body: data,
|
|
13
|
-
headers: headers,
|
|
14
|
-
});
|
|
12
|
+
body: params.data,
|
|
13
|
+
headers: params.headers,
|
|
14
|
+
}, params.timeout);
|
|
15
|
+
};
|
|
16
|
+
async fetchWithTimeout(url, options, timeout) {
|
|
17
|
+
const controller = new AbortController();
|
|
18
|
+
const timeoutId = timeout !== undefined ? setTimeout(() => controller.abort(), timeout) : null;
|
|
19
|
+
try {
|
|
20
|
+
return await fetch(url, { ...options, signal: controller.signal });
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
if (timeoutId) {
|
|
24
|
+
clearTimeout(timeoutId);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
15
27
|
}
|
|
16
28
|
}
|
package/esm/web/WsClient.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const REFRESH_TIMEOUT =
|
|
1
|
+
const REFRESH_TIMEOUT = 5000;
|
|
2
2
|
export class WsClient {
|
|
3
3
|
getUrl;
|
|
4
4
|
getAuthToken;
|
|
@@ -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
|
}
|