camstreamerlib 4.0.0-beta.13 → 4.0.0-beta.130

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.
Files changed (354) hide show
  1. package/README.md +143 -38
  2. package/cjs/CamOverlayAPI.d.ts +560 -336
  3. package/cjs/CamOverlayAPI.js +99 -184
  4. package/cjs/CamScripterAPI.d.ts +41 -17
  5. package/cjs/CamScripterAPI.js +50 -56
  6. package/cjs/CamStreamerAPI.d.ts +3139 -14
  7. package/cjs/CamStreamerAPI.js +151 -52
  8. package/cjs/CamSwitcherAPI.d.ts +155 -42
  9. package/cjs/CamSwitcherAPI.js +134 -189
  10. package/cjs/PlaneTrackerAPI.d.ts +236 -0
  11. package/cjs/PlaneTrackerAPI.js +194 -0
  12. package/cjs/VapixAPI.d.ts +84 -43
  13. package/cjs/VapixAPI.js +312 -216
  14. package/cjs/{CreatePackage.js → bin/CreatePackage.js} +44 -18
  15. package/cjs/errors/errors.d.ts +70 -4
  16. package/cjs/errors/errors.js +140 -7
  17. package/cjs/index.d.ts +20 -8
  18. package/cjs/index.js +28 -12
  19. package/cjs/internal/BasicAPI.d.ts +15 -0
  20. package/cjs/internal/BasicAPI.js +93 -0
  21. package/cjs/internal/ProxyClient.d.ts +8 -9
  22. package/cjs/internal/ProxyClient.js +28 -34
  23. package/cjs/internal/WsEvents.d.ts +38 -0
  24. package/cjs/{CamSwitcherEvents.js → internal/WsEvents.js} +33 -22
  25. package/cjs/internal/constants.d.ts +1 -0
  26. package/cjs/internal/constants.js +2 -1
  27. package/cjs/internal/convertors.d.ts +6 -0
  28. package/cjs/internal/convertors.js +115 -0
  29. package/cjs/internal/types.d.ts +32 -20
  30. package/cjs/internal/utils.d.ts +1 -3
  31. package/cjs/internal/utils.js +1 -12
  32. package/cjs/internal/versionCompare.d.ts +2 -2
  33. package/cjs/node/CamOverlayDrawingAPI.d.ts +41 -0
  34. package/cjs/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +28 -20
  35. package/{esm → cjs/node}/CamOverlayPainter/Frame.d.ts +8 -37
  36. package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
  37. package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Painter.d.ts +5 -21
  38. package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +5 -17
  39. package/cjs/node/CamOverlayPainter/ResourceManager.d.ts +15 -0
  40. package/cjs/node/CamOverlayPainter/ResourceManager.js +72 -0
  41. package/cjs/node/CamScripterAPICameraEventsGenerator.d.ts +31 -0
  42. package/cjs/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +13 -13
  43. package/cjs/node/DefaultClient.d.ts +6 -6
  44. package/cjs/node/DefaultClient.js +12 -16
  45. package/cjs/{internal → node}/Digest.js +24 -1
  46. package/cjs/node/Digest.test.js +13 -0
  47. package/cjs/node/HttpRequestSender.d.ts +1 -0
  48. package/cjs/node/HttpRequestSender.js +14 -4
  49. package/cjs/node/HttpServer.d.ts +1 -1
  50. package/cjs/node/HttpServer.js +29 -6
  51. package/cjs/node/TimeZoneDaemon.d.ts +6 -0
  52. package/cjs/node/TimeZoneDaemon.js +29 -0
  53. package/cjs/node/VapixEvents.d.ts +16 -0
  54. package/cjs/{VapixEvents.js → node/VapixEvents.js} +10 -10
  55. package/cjs/node/WsClient.d.ts +9 -18
  56. package/cjs/node/WsClient.js +27 -20
  57. package/cjs/node/events/AxisCameraStationEvents.d.ts +12 -0
  58. package/cjs/{events → node/events}/AxisCameraStationEvents.js +18 -13
  59. package/cjs/node/events/GenetecAgent.d.ts +16 -0
  60. package/cjs/node/events/GenetecAgent.js +124 -0
  61. package/cjs/node/index.d.ts +18 -2
  62. package/cjs/node/index.js +39 -5
  63. package/cjs/{models/CamOverlayAPI/widgetsSchema.d.ts → types/CamOverlayAPI/CamOverlayAPI.d.ts} +2534 -746
  64. package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +131 -0
  65. package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.d.ts +15 -15
  66. package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.js +7 -8
  67. package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.d.ts +106 -105
  68. package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.js +5 -6
  69. package/{esm/models → cjs/types}/CamOverlayAPI/imagesSchema.d.ts +17 -17
  70. package/cjs/types/CamOverlayAPI/imagesSchema.js +9 -0
  71. package/cjs/{models → types}/CamOverlayAPI/index.d.ts +2 -4
  72. package/cjs/{models → types}/CamOverlayAPI/index.js +2 -4
  73. package/cjs/{models → types}/CamOverlayAPI/infotickerSchema.d.ts +25 -25
  74. package/cjs/{models → types}/CamOverlayAPI/infotickerSchema.js +6 -7
  75. package/{esm/models → cjs/types}/CamOverlayAPI/pipSchema.d.ts +19 -19
  76. package/cjs/{models → types}/CamOverlayAPI/pipSchema.js +5 -6
  77. package/{esm/models → cjs/types}/CamOverlayAPI/ptzCompassSchema.d.ts +16 -13
  78. package/cjs/{models → types}/CamOverlayAPI/ptzCompassSchema.js +5 -5
  79. package/{esm/models → cjs/types}/CamOverlayAPI/ptzSchema.d.ts +26 -26
  80. package/cjs/types/CamOverlayAPI/ptzSchema.js +12 -0
  81. package/cjs/types/CamOverlayAPI/scoreBoardSchema.d.ts +357 -0
  82. package/cjs/types/CamOverlayAPI/scoreBoardSchema.js +132 -0
  83. package/cjs/{models → types}/CamOverlayAPI/screenSharingSchema.d.ts +13 -13
  84. package/cjs/types/CamOverlayAPI/screenSharingSchema.js +8 -0
  85. package/{esm/models/CamOverlayAPI/widgetCommonSchema.d.ts → cjs/types/CamOverlayAPI/serviceCommonTypes.d.ts} +75 -56
  86. package/cjs/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/serviceCommonTypes.js} +33 -18
  87. package/{esm/models → cjs/types}/CamOverlayAPI/webCameraSharingSchema.d.ts +13 -13
  88. package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +8 -0
  89. package/cjs/types/CamOverlayDrawingAPI.d.ts +48 -0
  90. package/cjs/types/CamOverlayDrawingAPI.js +2 -0
  91. package/cjs/types/CamOverlayPainter.d.ts +76 -0
  92. package/cjs/types/CamOverlayPainter.js +14 -0
  93. package/cjs/types/CamScripterAPI.d.ts +86 -23
  94. package/cjs/types/CamScripterAPI.js +24 -8
  95. package/cjs/types/CamScripterAPICameraEventsGenerator.d.ts +45 -0
  96. package/cjs/types/CamScripterAPICameraEventsGenerator.js +2 -0
  97. package/cjs/types/CamStreamerAPI/CamStreamerAPI.d.ts +22299 -0
  98. package/cjs/types/CamStreamerAPI/CamStreamerAPI.js +165 -0
  99. package/cjs/types/CamStreamerAPI/facebookSchema.d.ts +501 -0
  100. package/cjs/types/CamStreamerAPI/facebookSchema.js +23 -0
  101. package/cjs/types/CamStreamerAPI/index.d.ts +6 -0
  102. package/cjs/types/CamStreamerAPI/index.js +22 -0
  103. package/cjs/types/{CamStreamerAPI.d.ts → CamStreamerAPI/oldStreamSchema.d.ts} +104 -35
  104. package/cjs/types/CamStreamerAPI/oldStreamSchema.js +53 -0
  105. package/cjs/types/CamStreamerAPI/streamCommonTypes.d.ts +500 -0
  106. package/cjs/types/CamStreamerAPI/streamCommonTypes.js +119 -0
  107. package/cjs/types/CamStreamerAPI/streamsSchema.d.ts +7379 -0
  108. package/cjs/types/CamStreamerAPI/streamsSchema.js +59 -0
  109. package/cjs/types/CamStreamerAPI/windySchema.d.ts +435 -0
  110. package/cjs/types/CamStreamerAPI/windySchema.js +11 -0
  111. package/cjs/types/CamStreamerAPI/youtubeSchema.d.ts +468 -0
  112. package/cjs/types/CamStreamerAPI/youtubeSchema.js +22 -0
  113. package/cjs/types/CamSwitcherAPI.d.ts +181 -121
  114. package/cjs/types/CamSwitcherAPI.js +31 -1
  115. package/cjs/{events → types}/GenetecAgent.d.ts +47 -47
  116. package/cjs/types/GenetecAgent.js +31 -0
  117. package/cjs/types/PlaneTrackerAPI.d.ts +980 -0
  118. package/cjs/types/PlaneTrackerAPI.js +333 -0
  119. package/cjs/types/VapixAPI.d.ts +255 -15
  120. package/cjs/types/VapixAPI.js +66 -3
  121. package/cjs/types/VapixEvents.d.ts +15 -0
  122. package/cjs/types/VapixEvents.js +2 -0
  123. package/cjs/types/common.d.ts +43 -3
  124. package/cjs/types/common.js +17 -2
  125. package/cjs/types/ws/CamOverlayEvents.d.ts +88 -0
  126. package/cjs/types/ws/CamOverlayEvents.js +19 -0
  127. package/cjs/types/ws/CamStreamerEvents.d.ts +282 -0
  128. package/cjs/types/ws/CamStreamerEvents.js +36 -0
  129. package/cjs/types/ws/PlaneTrackerEvents.d.ts +1703 -0
  130. package/cjs/types/ws/PlaneTrackerEvents.js +207 -0
  131. package/cjs/web/DefaultClient.d.ts +7 -5
  132. package/cjs/web/DefaultClient.js +25 -11
  133. package/cjs/web/WsClient.d.ts +9 -5
  134. package/cjs/web/WsClient.js +16 -18
  135. package/cjs/ws/CamOverlayEvents.d.ts +8 -0
  136. package/cjs/ws/CamOverlayEvents.js +24 -0
  137. package/cjs/ws/CamStreamerEvents.d.ts +8 -0
  138. package/cjs/ws/CamStreamerEvents.js +24 -0
  139. package/cjs/ws/CamSwitcherEvents.d.ts +8 -0
  140. package/cjs/ws/CamSwitcherEvents.js +24 -0
  141. package/cjs/ws/PlaneTrackerEvents.d.ts +9 -0
  142. package/cjs/ws/PlaneTrackerEvents.js +30 -0
  143. package/esm/CamOverlayAPI.js +99 -184
  144. package/esm/CamScripterAPI.js +51 -57
  145. package/esm/CamStreamerAPI.js +149 -51
  146. package/esm/CamSwitcherAPI.js +137 -192
  147. package/esm/PlaneTrackerAPI.js +190 -0
  148. package/esm/VapixAPI.js +314 -218
  149. package/esm/{CreatePackage.js → bin/CreatePackage.js} +16 -16
  150. package/esm/errors/errors.js +122 -6
  151. package/esm/index.js +20 -8
  152. package/esm/internal/BasicAPI.js +89 -0
  153. package/esm/internal/ProxyClient.js +28 -34
  154. package/esm/{CamSwitcherEvents.js → internal/WsEvents.js} +31 -20
  155. package/esm/internal/constants.js +1 -0
  156. package/esm/internal/convertors.js +108 -0
  157. package/esm/internal/utils.js +0 -9
  158. package/esm/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +26 -18
  159. package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
  160. package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +2 -13
  161. package/esm/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +7 -5
  162. package/esm/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +11 -11
  163. package/esm/node/DefaultClient.js +12 -16
  164. package/esm/node/Digest.test.js +11 -0
  165. package/esm/node/HttpRequestSender.js +14 -4
  166. package/esm/node/HttpServer.js +1 -1
  167. package/esm/node/TimeZoneDaemon.js +25 -0
  168. package/esm/{VapixEvents.js → node/VapixEvents.js} +10 -10
  169. package/esm/node/WsClient.js +22 -15
  170. package/esm/{events → node/events}/AxisCameraStationEvents.js +18 -13
  171. package/esm/node/events/GenetecAgent.js +120 -0
  172. package/esm/node/index.js +18 -2
  173. package/esm/types/CamOverlayAPI/CamOverlayAPI.js +110 -0
  174. package/esm/{models → types}/CamOverlayAPI/accuweatherSchema.js +3 -4
  175. package/esm/{models → types}/CamOverlayAPI/customGraphicsSchema.js +3 -4
  176. package/esm/types/CamOverlayAPI/imagesSchema.js +6 -0
  177. package/esm/{models → types}/CamOverlayAPI/index.js +2 -4
  178. package/esm/{models → types}/CamOverlayAPI/infotickerSchema.js +3 -4
  179. package/esm/{models → types}/CamOverlayAPI/pipSchema.js +4 -5
  180. package/esm/{models → types}/CamOverlayAPI/ptzCompassSchema.js +4 -4
  181. package/esm/types/CamOverlayAPI/ptzSchema.js +9 -0
  182. package/esm/types/CamOverlayAPI/scoreBoardSchema.js +129 -0
  183. package/esm/types/CamOverlayAPI/screenSharingSchema.js +5 -0
  184. package/esm/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/serviceCommonTypes.js} +32 -17
  185. package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +5 -0
  186. package/esm/types/CamOverlayDrawingAPI.js +1 -0
  187. package/esm/types/CamOverlayPainter.js +11 -0
  188. package/esm/types/CamScripterAPI.js +23 -7
  189. package/esm/types/CamScripterAPICameraEventsGenerator.js +1 -0
  190. package/esm/types/CamStreamerAPI/CamStreamerAPI.js +142 -0
  191. package/esm/types/CamStreamerAPI/facebookSchema.js +17 -0
  192. package/esm/types/CamStreamerAPI/index.js +6 -0
  193. package/esm/types/CamStreamerAPI/oldStreamSchema.js +50 -0
  194. package/esm/types/CamStreamerAPI/streamCommonTypes.js +116 -0
  195. package/esm/types/CamStreamerAPI/streamsSchema.js +53 -0
  196. package/esm/types/CamStreamerAPI/windySchema.js +5 -0
  197. package/esm/types/CamStreamerAPI/youtubeSchema.js +16 -0
  198. package/esm/types/CamSwitcherAPI.js +31 -1
  199. package/esm/types/GenetecAgent.js +28 -0
  200. package/esm/types/PlaneTrackerAPI.js +330 -0
  201. package/esm/types/VapixAPI.js +65 -2
  202. package/esm/types/VapixEvents.js +1 -0
  203. package/esm/types/common.js +16 -1
  204. package/esm/types/ws/CamOverlayEvents.js +16 -0
  205. package/esm/types/ws/CamStreamerEvents.js +33 -0
  206. package/esm/types/ws/PlaneTrackerEvents.js +204 -0
  207. package/esm/web/DefaultClient.js +25 -11
  208. package/esm/web/WsClient.js +16 -18
  209. package/esm/ws/CamOverlayEvents.js +20 -0
  210. package/esm/ws/CamStreamerEvents.js +20 -0
  211. package/esm/ws/CamSwitcherEvents.js +20 -0
  212. package/esm/ws/PlaneTrackerEvents.js +26 -0
  213. package/package.json +43 -9
  214. package/{esm → types}/CamOverlayAPI.d.ts +560 -336
  215. package/types/CamScripterAPI.d.ts +43 -0
  216. package/types/CamStreamerAPI.d.ts +3141 -0
  217. package/types/CamSwitcherAPI.d.ts +165 -0
  218. package/types/PlaneTrackerAPI.d.ts +236 -0
  219. package/types/VapixAPI.d.ts +119 -0
  220. package/types/bin/CreatePackage.d.ts +1 -0
  221. package/types/errors/errors.d.ts +103 -0
  222. package/types/index.d.ts +28 -0
  223. package/types/internal/BasicAPI.d.ts +15 -0
  224. package/types/internal/ProxyClient.d.ts +10 -0
  225. package/types/internal/WsEvents.d.ts +38 -0
  226. package/{esm → types}/internal/constants.d.ts +1 -0
  227. package/types/internal/convertors.d.ts +6 -0
  228. package/types/internal/types.d.ts +47 -0
  229. package/{esm → types}/internal/utils.d.ts +1 -3
  230. package/{esm → types}/internal/versionCompare.d.ts +2 -2
  231. package/types/node/CamOverlayDrawingAPI.d.ts +41 -0
  232. package/{cjs → types/node}/CamOverlayPainter/Frame.d.ts +8 -37
  233. package/{esm → types/node}/CamOverlayPainter/Painter.d.ts +5 -21
  234. package/types/node/CamOverlayPainter/ResourceManager.d.ts +15 -0
  235. package/types/node/CamScripterAPICameraEventsGenerator.d.ts +31 -0
  236. package/types/node/DefaultClient.d.ts +16 -0
  237. package/types/node/Digest.test.d.ts +1 -0
  238. package/{esm → types}/node/HttpRequestSender.d.ts +1 -0
  239. package/{esm → types}/node/HttpServer.d.ts +1 -1
  240. package/types/node/TimeZoneDaemon.d.ts +6 -0
  241. package/types/node/VapixEvents.d.ts +16 -0
  242. package/types/node/WsClient.d.ts +30 -0
  243. package/types/node/events/AxisCameraStationEvents.d.ts +12 -0
  244. package/types/node/events/GenetecAgent.d.ts +16 -0
  245. package/types/node/index.d.ts +18 -0
  246. package/{esm/models/CamOverlayAPI/widgetsSchema.d.ts → types/types/CamOverlayAPI/CamOverlayAPI.d.ts} +2534 -746
  247. package/{esm/models → types/types}/CamOverlayAPI/accuweatherSchema.d.ts +15 -15
  248. package/{esm/models → types/types}/CamOverlayAPI/customGraphicsSchema.d.ts +106 -105
  249. package/{cjs/models → types/types}/CamOverlayAPI/imagesSchema.d.ts +17 -17
  250. package/{esm/models → types/types}/CamOverlayAPI/index.d.ts +2 -4
  251. package/{esm/models → types/types}/CamOverlayAPI/infotickerSchema.d.ts +25 -25
  252. package/{cjs/models → types/types}/CamOverlayAPI/pipSchema.d.ts +19 -19
  253. package/{cjs/models → types/types}/CamOverlayAPI/ptzCompassSchema.d.ts +16 -13
  254. package/{cjs/models → types/types}/CamOverlayAPI/ptzSchema.d.ts +26 -26
  255. package/types/types/CamOverlayAPI/scoreBoardSchema.d.ts +357 -0
  256. package/{esm/models → types/types}/CamOverlayAPI/screenSharingSchema.d.ts +13 -13
  257. package/{cjs/models/CamOverlayAPI/widgetCommonSchema.d.ts → types/types/CamOverlayAPI/serviceCommonTypes.d.ts} +75 -56
  258. package/{cjs/models → types/types}/CamOverlayAPI/webCameraSharingSchema.d.ts +13 -13
  259. package/types/types/CamOverlayDrawingAPI.d.ts +48 -0
  260. package/types/types/CamOverlayPainter.d.ts +76 -0
  261. package/types/types/CamScripterAPI.d.ts +130 -0
  262. package/types/types/CamScripterAPICameraEventsGenerator.d.ts +45 -0
  263. package/types/types/CamStreamerAPI/CamStreamerAPI.d.ts +22299 -0
  264. package/types/types/CamStreamerAPI/facebookSchema.d.ts +501 -0
  265. package/types/types/CamStreamerAPI/index.d.ts +6 -0
  266. package/{esm/types/CamStreamerAPI.d.ts → types/types/CamStreamerAPI/oldStreamSchema.d.ts} +104 -35
  267. package/types/types/CamStreamerAPI/streamCommonTypes.d.ts +500 -0
  268. package/types/types/CamStreamerAPI/streamsSchema.d.ts +7379 -0
  269. package/types/types/CamStreamerAPI/windySchema.d.ts +435 -0
  270. package/types/types/CamStreamerAPI/youtubeSchema.d.ts +468 -0
  271. package/{esm → types}/types/CamSwitcherAPI.d.ts +181 -121
  272. package/{esm/events → types/types}/GenetecAgent.d.ts +47 -47
  273. package/types/types/PlaneTrackerAPI.d.ts +980 -0
  274. package/{esm → types}/types/VapixAPI.d.ts +255 -15
  275. package/types/types/VapixEvents.d.ts +15 -0
  276. package/types/types/common.d.ts +77 -0
  277. package/types/types/ws/CamOverlayEvents.d.ts +88 -0
  278. package/types/types/ws/CamStreamerEvents.d.ts +282 -0
  279. package/types/types/ws/PlaneTrackerEvents.d.ts +1703 -0
  280. package/types/web/DefaultClient.d.ts +8 -0
  281. package/types/web/WsClient.d.ts +17 -0
  282. package/types/ws/CamOverlayEvents.d.ts +8 -0
  283. package/types/ws/CamStreamerEvents.d.ts +8 -0
  284. package/types/ws/CamSwitcherEvents.d.ts +8 -0
  285. package/types/ws/PlaneTrackerEvents.d.ts +9 -0
  286. package/cjs/CamOverlayDrawingAPI.d.ts +0 -86
  287. package/cjs/CamOverlayPainter/ResourceManager.d.ts +0 -14
  288. package/cjs/CamOverlayPainter/ResourceManager.js +0 -46
  289. package/cjs/CamScripterAPICameraEventsGenerator.d.ts +0 -74
  290. package/cjs/CamSwitcherEvents.d.ts +0 -18
  291. package/cjs/VapixEvents.d.ts +0 -43
  292. package/cjs/events/AxisCameraStationEvents.d.ts +0 -10
  293. package/cjs/events/GenetecAgent.js +0 -123
  294. package/cjs/models/CamOverlayAPI/constants.d.ts +0 -11
  295. package/cjs/models/CamOverlayAPI/constants.js +0 -14
  296. package/cjs/models/CamOverlayAPI/fileSchema.d.ts +0 -28
  297. package/cjs/models/CamOverlayAPI/fileSchema.js +0 -17
  298. package/cjs/models/CamOverlayAPI/imagesSchema.js +0 -10
  299. package/cjs/models/CamOverlayAPI/ptzSchema.js +0 -13
  300. package/cjs/models/CamOverlayAPI/screenSharingSchema.js +0 -9
  301. package/cjs/models/CamOverlayAPI/webCameraSharingSchema.js +0 -9
  302. package/cjs/models/CamOverlayAPI/widgetsSchema.js +0 -27
  303. package/cjs/node/WsEventClient.d.ts +0 -13
  304. package/cjs/node/WsEventClient.js +0 -22
  305. package/cjs/types/CamOverlayAPI.d.ts +0 -328
  306. package/cjs/types/CamOverlayAPI.js +0 -26
  307. package/cjs/types/CamStreamerAPI.js +0 -28
  308. package/esm/CamOverlayDrawingAPI.d.ts +0 -86
  309. package/esm/CamOverlayPainter/ResourceManager.d.ts +0 -14
  310. package/esm/CamScripterAPI.d.ts +0 -19
  311. package/esm/CamScripterAPICameraEventsGenerator.d.ts +0 -74
  312. package/esm/CamStreamerAPI.d.ts +0 -16
  313. package/esm/CamSwitcherAPI.d.ts +0 -52
  314. package/esm/CamSwitcherEvents.d.ts +0 -18
  315. package/esm/VapixAPI.d.ts +0 -78
  316. package/esm/VapixEvents.d.ts +0 -43
  317. package/esm/errors/errors.d.ts +0 -37
  318. package/esm/events/AxisCameraStationEvents.d.ts +0 -10
  319. package/esm/events/GenetecAgent.js +0 -119
  320. package/esm/index.d.ts +0 -16
  321. package/esm/internal/ProxyClient.d.ts +0 -11
  322. package/esm/internal/types.d.ts +0 -35
  323. package/esm/models/CamOverlayAPI/constants.d.ts +0 -11
  324. package/esm/models/CamOverlayAPI/constants.js +0 -11
  325. package/esm/models/CamOverlayAPI/fileSchema.d.ts +0 -28
  326. package/esm/models/CamOverlayAPI/fileSchema.js +0 -14
  327. package/esm/models/CamOverlayAPI/imagesSchema.js +0 -7
  328. package/esm/models/CamOverlayAPI/ptzSchema.js +0 -10
  329. package/esm/models/CamOverlayAPI/screenSharingSchema.js +0 -6
  330. package/esm/models/CamOverlayAPI/webCameraSharingSchema.js +0 -6
  331. package/esm/models/CamOverlayAPI/widgetsSchema.js +0 -24
  332. package/esm/node/DefaultClient.d.ts +0 -16
  333. package/esm/node/WsClient.d.ts +0 -39
  334. package/esm/node/WsEventClient.d.ts +0 -13
  335. package/esm/node/WsEventClient.js +0 -18
  336. package/esm/types/CamOverlayAPI.d.ts +0 -328
  337. package/esm/types/CamOverlayAPI.js +0 -14
  338. package/esm/types/CamScripterAPI.d.ts +0 -67
  339. package/esm/types/CamStreamerAPI.js +0 -25
  340. package/esm/types/common.d.ts +0 -37
  341. package/esm/web/DefaultClient.d.ts +0 -6
  342. package/esm/web/WsClient.d.ts +0 -13
  343. package/esm/web/index.d.ts +0 -2
  344. package/cjs/{CreatePackage.d.ts → bin/CreatePackage.d.ts} +0 -0
  345. package/cjs/{internal → node}/Digest.d.ts +0 -0
  346. package/{esm/CreatePackage.d.ts → cjs/node/Digest.test.d.ts} +0 -0
  347. package/{esm/types → cjs/types/ws}/CamSwitcherEvents.d.ts +8 -8
  348. package/cjs/types/{CamSwitcherEvents.js → ws/CamSwitcherEvents.js} +0 -0
  349. package/esm/{internal → node}/Digest.js +0 -0
  350. package/esm/types/{CamSwitcherEvents.js → ws/CamSwitcherEvents.js} +0 -0
  351. package/{esm → types}/internal/transformers.d.ts +0 -0
  352. package/{esm/internal → types/node}/Digest.d.ts +0 -0
  353. package/{cjs/types → types/types/ws}/CamSwitcherEvents.d.ts +8 -8
  354. /package/{esm/node → types/web}/index.d.ts +0 -0
@@ -4,43 +4,37 @@ exports.ProxyClient = void 0;
4
4
  const utils_1 = require("./utils");
5
5
  class ProxyClient {
6
6
  client;
7
- getProxyUrl;
8
- constructor(client, getProxyUrl) {
7
+ proxyParams;
8
+ constructor(client, proxyParams) {
9
9
  this.client = client;
10
- this.getProxyUrl = getProxyUrl;
10
+ this.proxyParams = proxyParams;
11
11
  }
12
- get = (proxy, ...args) => {
13
- const [path, parameters, headers] = args;
14
- const url = (0, utils_1.addParametersToPath)(path, parameters);
15
- const { realUrl, realHeaders } = this.getReal(proxy, url, headers);
16
- return this.client.get(realUrl, {}, realHeaders);
17
- };
18
- post = (proxy, ...args) => {
19
- const [path, data, parameters, headers] = args;
20
- const url = (0, utils_1.addParametersToPath)(path, parameters);
21
- const { realUrl, realHeaders } = this.getReal(proxy, url, headers);
22
- return this.client.post(realUrl, data, {}, realHeaders);
23
- };
24
- getReal = (proxy, url, headers) => {
25
- if (proxy !== null) {
26
- return {
27
- realUrl: this.getProxyUrl(),
28
- realHeaders: {
29
- ...(headers ?? {}),
30
- 'x-target-camera-protocol': proxy.port === 443 ? 'https' : 'http',
31
- 'x-target-camera-path': url,
32
- 'x-target-camera-ip': proxy.ip,
33
- 'x-target-camera-mdns': proxy.mdnsName,
34
- 'x-target-camera-port': String(proxy.port),
35
- 'x-target-camera-pass': encodeURIComponent(proxy.pass),
36
- 'x-target-camera-user': encodeURIComponent(proxy.user),
37
- },
38
- };
39
- }
12
+ get(params) {
13
+ const { path, parameters, headers, timeout } = params;
14
+ const targetPath = (0, utils_1.addParametersToPath)(path, parameters);
15
+ const { realPath, realHeaders } = this.getReal(targetPath, headers);
16
+ return this.client.get({ path: realPath, headers: realHeaders, timeout });
17
+ }
18
+ post(params) {
19
+ const { path, data, parameters, headers, timeout } = params;
20
+ const targetPath = (0, utils_1.addParametersToPath)(path, parameters);
21
+ const { realPath, realHeaders } = this.getReal(targetPath, headers);
22
+ return this.client.post({ path: realPath, data, headers: realHeaders, timeout });
23
+ }
24
+ getReal(targetPath, headers) {
40
25
  return {
41
- realUrl: url,
42
- realHeaders: headers,
26
+ realPath: this.proxyParams.path,
27
+ realHeaders: {
28
+ ...(headers ?? {}),
29
+ 'x-target-camera-protocol': this.proxyParams.target.port === 443 ? 'https' : 'http',
30
+ 'x-target-camera-path': targetPath,
31
+ 'x-target-camera-ip': this.proxyParams.target.ip,
32
+ 'x-target-camera-mdns': this.proxyParams.target.mdnsName,
33
+ 'x-target-camera-port': String(this.proxyParams.target.port),
34
+ 'x-target-camera-pass': this.proxyParams.target.pass,
35
+ 'x-target-camera-user': this.proxyParams.target.user,
36
+ },
43
37
  };
44
- };
38
+ }
45
39
  }
46
40
  exports.ProxyClient = ProxyClient;
@@ -0,0 +1,38 @@
1
+ import { IWsClient } from './types';
2
+ type TEventType<T extends {
3
+ type: string;
4
+ }> = T extends {
5
+ type: infer Type;
6
+ } ? Type : never;
7
+ type TEvent<T extends {
8
+ type: string;
9
+ }, Type extends TEventType<T>> = T extends {
10
+ type: Type;
11
+ } ? T : never;
12
+ type TValidate<T extends {
13
+ type: string;
14
+ }> = (data: string) => {
15
+ type: 'init';
16
+ data: TEvent<T, TEventType<T>>;
17
+ } | TEvent<T, TEventType<T>>;
18
+ type TListenerFunction<T extends {
19
+ type: string;
20
+ }, Type extends TEventType<T>> = (data: TEvent<T, Type>, isInit: boolean) => void;
21
+ export declare class WsEvents<T extends {
22
+ type: string;
23
+ }> {
24
+ private validate;
25
+ ws: IWsClient;
26
+ private _isDestroyed;
27
+ private listeners;
28
+ constructor(validate: TValidate<T>, ws: IWsClient);
29
+ get isDestroyed(): boolean;
30
+ resendInitData(): void;
31
+ addListener<Type extends TEventType<T>>(type: Type, listener: TListenerFunction<T, Type>, id: string): void;
32
+ removeListener<Type extends TEventType<T>>(type: Type, id: string): void;
33
+ removeAllListenersForId(id: string): void;
34
+ private onMessage;
35
+ private processMessage;
36
+ destroy(): void;
37
+ }
38
+ export {};
@@ -1,23 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CamSwitcherEvents = void 0;
4
- const CamSwitcherEvents_1 = require("./types/CamSwitcherEvents");
5
- class CamSwitcherEvents {
6
- isDestroyed = false;
7
- ws = null;
3
+ exports.WsEvents = void 0;
4
+ class WsEvents {
5
+ validate;
6
+ ws;
7
+ _isDestroyed = false;
8
8
  listeners = {};
9
- setWebsocket(ws) {
10
- if (this.ws) {
11
- this.ws.destroy();
12
- }
9
+ constructor(validate, ws) {
10
+ this.validate = validate;
13
11
  this.ws = ws;
14
- this.ws.onmessage = (e) => this.onMessage(e);
12
+ this.ws.onMessage = (e) => this.onMessage(e);
13
+ }
14
+ get isDestroyed() {
15
+ return this._isDestroyed;
15
16
  }
16
17
  resendInitData() {
17
18
  const request = {
18
19
  command: 'sendInitData',
19
20
  };
20
- this.ws?.send(JSON.stringify(request));
21
+ this.ws.send(JSON.stringify(request));
21
22
  }
22
23
  addListener(type, listener, id) {
23
24
  const typeList = this.listeners[type];
@@ -31,23 +32,31 @@ class CamSwitcherEvents {
31
32
  const typeList = this.listeners[type];
32
33
  if (typeList) {
33
34
  delete typeList[id];
35
+ if (Object.keys(typeList).length === 0) {
36
+ delete this.listeners[type];
37
+ }
34
38
  }
35
39
  }
36
- onMessage(evt) {
40
+ removeAllListenersForId(id) {
41
+ for (const type in this.listeners) {
42
+ this.removeListener(type, id);
43
+ }
44
+ }
45
+ onMessage(incomeData) {
37
46
  if (this.isDestroyed) {
38
47
  return;
39
48
  }
40
49
  try {
41
- const eventData = JSON.parse(evt.data);
42
- const data = CamSwitcherEvents_1.cswEventsSchema.parse(eventData);
43
- if (data.type === 'init') {
50
+ const eventData = JSON.parse(incomeData.toString());
51
+ const data = this.validate(eventData);
52
+ if (isInitEvent(data)) {
44
53
  this.processMessage(data.data, true);
45
54
  return;
46
55
  }
47
56
  this.processMessage(data, false);
48
57
  }
49
58
  catch (error) {
50
- console.error('Error parsing event data:', evt.data, error);
59
+ console.error('Error parsing event data:', incomeData.toString(), error);
51
60
  }
52
61
  }
53
62
  processMessage(event, isInit) {
@@ -56,12 +65,14 @@ class CamSwitcherEvents {
56
65
  list.forEach((listener) => listener(event, isInit));
57
66
  }
58
67
  destroy() {
59
- this.isDestroyed = true;
60
- if (this.ws) {
61
- this.ws.destroy();
62
- this.ws = null;
63
- }
68
+ this._isDestroyed = true;
69
+ this.ws.onMessage = () => { };
70
+ this.ws.onOpen = () => Promise.reject(new Error('Websocket is destroyed'));
71
+ this.ws.destroy();
64
72
  this.listeners = {};
65
73
  }
66
74
  }
67
- exports.CamSwitcherEvents = CamSwitcherEvents;
75
+ exports.WsEvents = WsEvents;
76
+ const isInitEvent = (event) => {
77
+ return event.type === 'init';
78
+ };
@@ -1 +1,2 @@
1
1
  export declare const FIRMWARE_WITH_BITRATE_MODES_SUPPORT = "11.11.73";
2
+ export declare const FIRMWARE_WITH_OVERLAYS_SUPPORT = "10.7.0";
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FIRMWARE_WITH_BITRATE_MODES_SUPPORT = void 0;
3
+ exports.FIRMWARE_WITH_OVERLAYS_SUPPORT = exports.FIRMWARE_WITH_BITRATE_MODES_SUPPORT = void 0;
4
4
  exports.FIRMWARE_WITH_BITRATE_MODES_SUPPORT = '11.11.73';
5
+ exports.FIRMWARE_WITH_OVERLAYS_SUPPORT = '10.7.0';
@@ -0,0 +1,6 @@
1
+ import { TInternalVapixParameters } from '../types/CamStreamerAPI';
2
+ import { TBitrateMode, TBitrateVapixParams } from '../types/common';
3
+ export declare const parseBitrateOptionsToVapixParams: (firmWareVersion: string, bitrateMode: TBitrateMode | undefined, cameraOptions: Partial<TBitrateVapixParams>) => string;
4
+ export declare const parseVapixParamsToBitrateOptions: (bitrateVapixParams: string) => TBitrateVapixParams;
5
+ export declare const parseVideoOptionsToVapixParams: (firmWareVersion: string, video: TInternalVapixParameters) => string;
6
+ export declare const parseVapixParamsToVideoOptions: (internalVapixParams: string) => TInternalVapixParameters;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseVapixParamsToVideoOptions = exports.parseVideoOptionsToVapixParams = exports.parseVapixParamsToBitrateOptions = exports.parseBitrateOptionsToVapixParams = void 0;
4
+ const constants_1 = require("./constants");
5
+ const versionCompare_1 = require("./versionCompare");
6
+ const parseBitrateOptionsToVapixParams = (firmWareVersion, bitrateMode, cameraOptions) => {
7
+ if (!(0, versionCompare_1.isFirmwareVersionAtLeast)(firmWareVersion, constants_1.FIRMWARE_WITH_BITRATE_MODES_SUPPORT)) {
8
+ return `videomaxbitrate=${cameraOptions.maximumBitRate}`;
9
+ }
10
+ if (bitrateMode === undefined) {
11
+ return '';
12
+ }
13
+ const data = {
14
+ VBR: 'videobitratemode=vbr',
15
+ MBR: `videobitratemode=mbr&videomaxbitrate=${cameraOptions.maximumBitRate}&videobitratepriority=framerate`,
16
+ ABR: `videobitratemode=abr&videoabrtargetbitrate=${cameraOptions.maximumBitRate}&videoabrretentiontime=${cameraOptions.retentionTime}&videoabrmaxbitrate=${cameraOptions.bitRateLimit}`,
17
+ };
18
+ return data[bitrateMode];
19
+ };
20
+ exports.parseBitrateOptionsToVapixParams = parseBitrateOptionsToVapixParams;
21
+ const parseVapixParamsToBitrateOptions = (bitrateVapixParams) => {
22
+ const params = {};
23
+ const searchParams = new URLSearchParams(bitrateVapixParams);
24
+ searchParams.forEach((value, key) => {
25
+ params[key] = value;
26
+ });
27
+ const bitrateMode = params['videobitratemode'] !== undefined ? params['videobitratemode'].toUpperCase() : undefined;
28
+ const hasLowerFw = bitrateMode === undefined && params['videomaxbitrate'] !== undefined;
29
+ if (hasLowerFw) {
30
+ const maximumBitRate = parseInt(params['videomaxbitrate'] ?? '0', 10);
31
+ return {
32
+ bitrateMode: 'MBR',
33
+ maximumBitRate: maximumBitRate,
34
+ retentionTime: 1,
35
+ bitRateLimit: Math.floor(maximumBitRate * 1.1),
36
+ };
37
+ }
38
+ if (bitrateMode === 'ABR') {
39
+ const maximumBitRate = parseInt(params['videoabrtargetbitrate'] ?? '0', 10);
40
+ const retentionTime = parseInt(params['videoabrretentiontime'] ?? '0', 10);
41
+ const bitRateLimit = parseInt(params['videoabrmaxbitrate'] ?? '0', 10);
42
+ return {
43
+ bitrateMode,
44
+ maximumBitRate,
45
+ retentionTime,
46
+ bitRateLimit,
47
+ };
48
+ }
49
+ else if (bitrateMode === 'MBR') {
50
+ const maximumBitRate = params['videomaxbitrate'] !== undefined ? parseInt(params['videomaxbitrate'], 10) : null;
51
+ const oldMaximumBitrateParamValue = parseInt(params['videombrmaxbitrate'] ?? '0', 10);
52
+ return {
53
+ bitrateMode: bitrateMode,
54
+ maximumBitRate: maximumBitRate ?? oldMaximumBitrateParamValue,
55
+ retentionTime: 1,
56
+ bitRateLimit: Math.floor(maximumBitRate ?? oldMaximumBitrateParamValue * 1.1),
57
+ };
58
+ }
59
+ return {
60
+ bitrateMode: bitrateMode,
61
+ retentionTime: 1,
62
+ maximumBitRate: 0,
63
+ bitRateLimit: 0,
64
+ };
65
+ };
66
+ exports.parseVapixParamsToBitrateOptions = parseVapixParamsToBitrateOptions;
67
+ const parseVideoOptionsToVapixParams = (firmWareVersion, video) => {
68
+ const bitrateParams = (0, exports.parseBitrateOptionsToVapixParams)(firmWareVersion, video.bitrateMode, {
69
+ maximumBitRate: video.maximumBitRate,
70
+ retentionTime: video.retentionTime,
71
+ bitRateLimit: video.bitRateLimit,
72
+ });
73
+ let overlaysParams = '';
74
+ if ((0, versionCompare_1.isFirmwareVersionAtLeast)(firmWareVersion, constants_1.FIRMWARE_WITH_OVERLAYS_SUPPORT)) {
75
+ overlaysParams = `&overlays=${video.overlays}`;
76
+ }
77
+ const nbrOfChannels = video.audio === 1 ? `&nbrOfChannels=${video.nbrOfChannels}` : '';
78
+ const audioParams = `audio=${video.audio}${nbrOfChannels}`;
79
+ const videoCodecParams = video.videoCodec === 'h264'
80
+ ? `videoCodec=${video.videoCodec}&h264Profile=${video.h264Profile}`
81
+ : `videoCodec=${video.videoCodec}`;
82
+ const videoParams = `camera=${video.camera}&resolution=${video.resolution}&fps=${video.fps}&compression=${video.compression}&videokeyframeinterval=${video.govLength}&${videoCodecParams}${overlaysParams}`;
83
+ return [videoParams, bitrateParams, audioParams].join('&');
84
+ };
85
+ exports.parseVideoOptionsToVapixParams = parseVideoOptionsToVapixParams;
86
+ const parseVapixParamsToVideoOptions = (internalVapixParams) => {
87
+ const bitrateOptions = (0, exports.parseVapixParamsToBitrateOptions)(internalVapixParams);
88
+ const params = {};
89
+ const searchParams = new URLSearchParams(internalVapixParams);
90
+ searchParams.forEach((value, key) => {
91
+ params[key] = value;
92
+ });
93
+ let h264Profile = undefined;
94
+ if (params['videoCodec'] === 'h264') {
95
+ h264Profile = (params['h264Profile'] ?? 'high');
96
+ }
97
+ let nbrOfChannels = undefined;
98
+ if (params['audio'] === '1') {
99
+ nbrOfChannels = parseInt(params['nbrOfChannels'] ?? '1');
100
+ }
101
+ return {
102
+ ...bitrateOptions,
103
+ camera: params['camera'] ?? '1',
104
+ resolution: params['resolution'] ?? '',
105
+ fps: parseInt(params['fps'] ?? '0', 10),
106
+ compression: parseInt(params['compression'] ?? '0', 10),
107
+ govLength: parseInt(params['videokeyframeinterval'] ?? '0', 10),
108
+ videoCodec: (params['videoCodec'] ?? 'h264'),
109
+ h264Profile,
110
+ audio: parseInt(params['audio'] ?? '0'),
111
+ nbrOfChannels,
112
+ overlays: params['overlays'],
113
+ };
114
+ };
115
+ exports.parseVapixParamsToVideoOptions = parseVapixParamsToVideoOptions;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- import { Response as UndiciResponse } from 'undici';
3
1
  export type Options = {
4
2
  ip?: string;
5
3
  port?: number;
@@ -11,25 +9,39 @@ export type Options = {
11
9
  export type HttpOptions = Options & {
12
10
  keepAlive?: boolean;
13
11
  };
14
- export type WsOptions = Options;
15
12
  export type TParameters = Record<string, string | number | boolean | null | undefined>;
16
- export type TResponse = Response | UndiciResponse;
17
- export type TGetParams = [url: string, parameters?: TParameters, headers?: Record<string, string>];
18
- export type TPostParams = [
19
- url: string,
20
- data: string | Buffer | FormData,
21
- parameters?: TParameters,
22
- headers?: Record<string, string>
23
- ];
24
- export interface IClient<TRes extends TResponse> {
25
- get: (...params: TGetParams) => Promise<TRes>;
26
- post: (...params: TPostParams) => Promise<TRes>;
13
+ export type TResponse = {
14
+ json: () => Promise<any>;
15
+ text: () => Promise<string>;
16
+ blob: () => Promise<unknown>;
17
+ status: number;
18
+ ok: boolean;
19
+ statusText: string;
20
+ };
21
+ export type TGetParams = {
22
+ path: string;
23
+ parameters?: TParameters;
24
+ headers?: Record<string, string>;
25
+ timeout?: number;
26
+ };
27
+ export type TPostParams<Data> = {
28
+ path: string;
29
+ data: string | Data;
30
+ parameters?: TParameters;
31
+ headers?: Record<string, string>;
32
+ timeout?: number;
33
+ };
34
+ export interface IClient<TRes extends TResponse, Data> {
35
+ get: (params: TGetParams) => Promise<TRes>;
36
+ post: (params: TPostParams<Data>) => Promise<TRes>;
27
37
  }
28
- export type TBlobResponse<Client extends IClient<TResponse>> = Awaited<ReturnType<Awaited<ReturnType<Client['get']>>['blob']>>;
29
- export interface IWebsocket<Event extends {
30
- readonly data: string;
31
- }> {
38
+ export type TBlobResponse<Client extends IClient<TResponse, any>> = Awaited<ReturnType<Awaited<ReturnType<Client['get']>>['blob']>>;
39
+ export interface IWsClient {
40
+ onMessage: null | ((data: ArrayBuffer | string) => void);
41
+ onOpen: () => void;
42
+ onClose: () => void;
43
+ onError: (error: Error) => void;
44
+ send: (data: ArrayBuffer | string) => void;
45
+ reconnect: () => void;
32
46
  destroy: () => void;
33
- onmessage: null | ((event: Event) => void);
34
- send: (data: string) => void;
35
47
  }
@@ -1,5 +1,5 @@
1
1
  import { TPlaylistPlayType } from '../types/CamSwitcherAPI';
2
- import { IClient, Options, TParameters, TResponse } from './types';
2
+ import { TParameters } from './types';
3
3
  export declare const addParametersToPath: (path: string, params?: TParameters) => string;
4
4
  export declare const paramToUrl: (params?: TParameters) => string;
5
5
  export declare const arrayToUrl: (arr: string | string[]) => string;
@@ -9,7 +9,5 @@ export declare const isClip: (id?: string) => boolean;
9
9
  export declare const isTracker: (id?: string) => boolean;
10
10
  export declare const isPlaylist: (id?: string) => boolean;
11
11
  export declare const isLoopPlayType: (playType: TPlaylistPlayType) => boolean;
12
- export declare function isClient(arg?: Options | IClient<TResponse>): arg is IClient<TResponse>;
13
- export declare function responseStringify(res: TResponse): Promise<string>;
14
12
  export declare function pad(num: number, size: number): string;
15
13
  export declare function isNullish<T>(value: T | undefined | null): value is undefined | null;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNullish = exports.pad = exports.responseStringify = exports.isClient = exports.isLoopPlayType = exports.isPlaylist = exports.isTracker = exports.isClip = exports.isStream = exports.isCamera = exports.arrayToUrl = exports.paramToUrl = exports.addParametersToPath = void 0;
3
+ exports.isNullish = exports.pad = exports.isLoopPlayType = exports.isPlaylist = exports.isTracker = exports.isClip = exports.isStream = exports.isCamera = exports.arrayToUrl = exports.paramToUrl = exports.addParametersToPath = void 0;
4
4
  const addParametersToPath = (path, params) => {
5
5
  if (params === undefined || Object.keys(params).length === 0) {
6
6
  return path;
@@ -43,17 +43,6 @@ const isPlaylist = (id) => id?.charAt(0) === 'p';
43
43
  exports.isPlaylist = isPlaylist;
44
44
  const isLoopPlayType = (playType) => playType.includes('LOOP');
45
45
  exports.isLoopPlayType = isLoopPlayType;
46
- function isClient(arg = {}) {
47
- return 'get' in arg && 'post' in arg;
48
- }
49
- exports.isClient = isClient;
50
- async function responseStringify(res) {
51
- return JSON.stringify({
52
- status: res.status,
53
- body: await res.text(),
54
- });
55
- }
56
- exports.responseStringify = responseStringify;
57
46
  function pad(num, size) {
58
47
  const sign = Math.sign(num) === -1 ? '-' : '';
59
48
  return (sign +
@@ -1,6 +1,6 @@
1
1
  export declare const assertVersionString: (s: string, msg?: string) => void;
2
2
  export declare const isFirmwareVersionAtLeast: (version: string, compareVersion: string) => boolean;
3
3
  export declare const isVersionAtLeast: (version: string, compareVersion: string) => boolean;
4
- export declare const firmwareVersionCompare: (a: string, b: string) => 0 | 1 | -1;
5
- export declare const versionCompare: (a: string, b: string) => 0 | 1 | -1;
4
+ export declare const firmwareVersionCompare: (a: string, b: string) => 1 | 0 | -1;
5
+ export declare const versionCompare: (a: string, b: string) => 1 | 0 | -1;
6
6
  export declare const fixVersionToDots: (version: string) => string;
@@ -0,0 +1,41 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { EventEmitter } from 'events';
5
+ import { CamOverlayDrawingOptions, TCairoCreateResponse, TCairoResponse, TUploadImageResponse, TWriteTextParams } from '../types/CamOverlayDrawingAPI';
6
+ export declare class CamOverlayDrawingAPI extends EventEmitter {
7
+ private tls;
8
+ private tlsInsecure;
9
+ private ip;
10
+ private port;
11
+ private user;
12
+ private pass;
13
+ private cameraList;
14
+ private zIndex;
15
+ private callId;
16
+ private sendMessages;
17
+ private timeoutCheckTimer;
18
+ private wsConnected;
19
+ private ws;
20
+ constructor(options?: CamOverlayDrawingOptions);
21
+ connect(): void;
22
+ disconnect(): void;
23
+ isConnected(): boolean;
24
+ cairo(command: string, ...params: unknown[]): Promise<TCairoResponse | TCairoCreateResponse>;
25
+ writeText(...params: TWriteTextParams): Promise<TCairoResponse>;
26
+ uploadImageData(imgBuffer: Buffer): Promise<TUploadImageResponse>;
27
+ uploadFontData(fontBuffer: Buffer): Promise<TCairoCreateResponse>;
28
+ showCairoImage(cairoImage: string, posX: number, posY: number): Promise<TCairoResponse>;
29
+ showCairoImageAbsolute(cairoImage: string, posX: number, posY: number, width: number, height: number): Promise<TCairoResponse>;
30
+ removeImage(): Promise<TCairoResponse>;
31
+ private createWsClient;
32
+ private incomingWsMessageHandler;
33
+ private sendMessage;
34
+ private sendBinaryMessage;
35
+ private startMsgsTimeoutCheck;
36
+ private stopMsgsTimeoutCheck;
37
+ private reconnectWithError;
38
+ private reportMessage;
39
+ private reportError;
40
+ private reportClose;
41
+ }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CamOverlayDrawingAPI = void 0;
4
- const EventEmitter = require("events");
5
- const WsClient_1 = require("./node/WsClient");
6
- class CamOverlayDrawingAPI extends EventEmitter {
4
+ const events_1 = require("events");
5
+ const WsClient_1 = require("./WsClient");
6
+ class CamOverlayDrawingAPI extends events_1.EventEmitter {
7
7
  tls;
8
8
  tlsInsecure;
9
9
  ip;
@@ -37,14 +37,14 @@ class CamOverlayDrawingAPI extends EventEmitter {
37
37
  this.sendMessages = {};
38
38
  this.wsConnected = false;
39
39
  this.createWsClient();
40
- EventEmitter.call(this);
40
+ events_1.EventEmitter.call(this);
41
41
  }
42
42
  connect() {
43
43
  this.ws.open();
44
44
  this.startMsgsTimeoutCheck();
45
45
  }
46
46
  disconnect() {
47
- this.ws.close();
47
+ this.ws.destroy();
48
48
  this.stopMsgsTimeoutCheck();
49
49
  }
50
50
  isConnected() {
@@ -101,23 +101,23 @@ class CamOverlayDrawingAPI extends EventEmitter {
101
101
  tlsInsecure: this.tlsInsecure,
102
102
  };
103
103
  this.ws = new WsClient_1.WsClient(options);
104
- this.ws.on('open', () => {
104
+ this.ws.onOpen = () => {
105
105
  console.log('CamOverlay connection opened');
106
106
  this.wsConnected = true;
107
107
  this.emit('open');
108
- });
109
- this.ws.on('message', (msgData) => this.incomingWsMessageHandler(msgData));
110
- this.ws.on('error', (error) => {
108
+ };
109
+ this.ws.onMessage = (data) => this.incomingWsMessageHandler(data.toString());
110
+ this.ws.onError = (error) => {
111
111
  this.reportError(error);
112
- });
113
- this.ws.on('close', () => {
112
+ };
113
+ this.ws.onClose = () => {
114
114
  console.log('CamOverlay connection closed');
115
115
  this.wsConnected = false;
116
116
  this.reportClose();
117
- });
117
+ };
118
118
  }
119
119
  incomingWsMessageHandler(msgData) {
120
- const dataJSON = JSON.parse(msgData.toString());
120
+ const dataJSON = JSON.parse(msgData);
121
121
  let errorResponse;
122
122
  if ('error' in dataJSON) {
123
123
  errorResponse = dataJSON;
@@ -168,13 +168,21 @@ class CamOverlayDrawingAPI extends EventEmitter {
168
168
  throw new Error('No CamOverlay connection');
169
169
  }
170
170
  msgJson.call_id = ++this.callId;
171
- const jsonBuffer = Buffer.from(JSON.stringify(msgJson));
172
- const header = new ArrayBuffer(5);
173
- const headerView = new DataView(header);
174
- headerView.setInt8(0, 1);
175
- headerView.setInt32(1, jsonBuffer.byteLength);
176
- const msgBuffer = Buffer.concat([Buffer.from(header), jsonBuffer, data]);
177
- this.ws.send(msgBuffer);
171
+ const jsonString = JSON.stringify(msgJson);
172
+ const jsonByteLength = Buffer.byteLength(jsonString);
173
+ const headerLength = 5;
174
+ const totalLength = headerLength + jsonByteLength + data.byteLength;
175
+ const arrayBuffer = new ArrayBuffer(totalLength);
176
+ const view = new DataView(arrayBuffer);
177
+ view.setInt8(0, 1);
178
+ view.setInt32(1, jsonByteLength);
179
+ const jsonBuffer = new Uint8Array(arrayBuffer, 5, jsonByteLength);
180
+ for (let i = 0; i < jsonString.length; i++) {
181
+ jsonBuffer[i] = jsonString.charCodeAt(i);
182
+ }
183
+ const dataBuffer = new Uint8Array(arrayBuffer, 5 + jsonByteLength, data.byteLength);
184
+ data.copy(dataBuffer);
185
+ this.ws.send(arrayBuffer);
178
186
  this.sendMessages[this.callId] = { resolve, reject, sentTimestamp: Date.now() };
179
187
  }
180
188
  catch (err) {
@@ -1,42 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from 'events';
3
- import { CamOverlayDrawingAPI, TAlign, TCairoCreateResponse, TUploadImageResponse } from '../CamOverlayDrawingAPI';
4
- import ResourceManager from './ResourceManager';
5
- export type TRgb = [number, number, number];
6
- export type TRgba = [number, number, number, number];
7
- export type TTmf = 'TFM_OVERFLOW' | 'TFM_SCALE' | 'TFM_TRUNCATE';
8
- export type TObjectFitType = 'fill' | 'fit' | 'none';
9
- export type TFrameOptions = {
10
- enabled?: boolean;
11
- x: number;
12
- y: number;
13
- width: number;
14
- height: number;
15
- text?: string;
16
- fontColor?: TRgb;
17
- font?: string;
18
- bgColor?: TRgba;
19
- bgImage?: string;
20
- bgType?: TObjectFitType;
21
- borderRadius?: number;
22
- borderWidth?: number;
23
- borderColor?: TRgba;
24
- customDraw?: TDrawingCallback;
25
- layer?: number;
26
- };
27
- export type TFrameInfo = {
28
- width: number;
29
- height: number;
30
- };
31
- export type TDrawingCallback = (cod: CamOverlayDrawingAPI, cairo: string, info: TFrameInfo) => Promise<void>;
32
- export interface Frame {
33
- on(event: 'open', listener: () => void): this;
34
- on(event: 'close', listener: () => void): this;
35
- on(event: 'layoutChanged', listener: () => void): this;
36
- emit(event: 'open'): boolean;
37
- emit(event: 'close'): boolean;
38
- emit(event: 'layoutChanged'): boolean;
39
- }
3
+ import { CamOverlayDrawingAPI } from '../CamOverlayDrawingAPI';
4
+ import { TAlign, TCairoCreateResponse, TUploadImageResponse } from '../../types/CamOverlayDrawingAPI';
5
+ import { ResourceManager } from './ResourceManager';
6
+ import { TBg, TBorder, TDrawingCallback, TFrame, TFrameOptions, TObjectFitType, TRgb, TRgba, TText, TTmf } from '../../types/CamOverlayPainter';
40
7
  export declare class Frame extends EventEmitter {
41
8
  protected enabled: boolean;
42
9
  protected posX: number;
@@ -64,17 +31,21 @@ export declare class Frame extends EventEmitter {
64
31
  disable(): void;
65
32
  setFramePosition(x: number, y: number): void;
66
33
  setFrameSize(width: number, height: number): void;
34
+ getFrameInfo(): TFrame;
67
35
  setText(text: string, align: TAlign, textType?: TTmf, fontColor?: TRgb): void;
68
36
  setFontColor(fontColor: TRgb): void;
69
37
  setFont(fontName: string): void;
70
38
  setFontData(fontData: TCairoCreateResponse): void;
39
+ getTextInfo(): TText;
71
40
  setBgColor(color: TRgba): void;
72
41
  setBgImage(imageName: string, type?: TObjectFitType): void;
73
42
  setBgImageData(imageData: TUploadImageResponse, type?: TObjectFitType): void;
74
43
  setBgType(type: TObjectFitType): void;
44
+ getBgInfo(): TBg;
75
45
  setBorderRadius(radius: number): void;
76
46
  setBorderWidth(width: number): void;
77
47
  setBorderColor(color: TRgba): void;
48
+ getBorderInfo(): TBorder;
78
49
  setCustomDraw(customDraw: TDrawingCallback): void;
79
50
  resetFont(): void;
80
51
  resetBgColor(): void;