camstreamerlib 4.0.0-beta.32 → 4.0.0-beta.34

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 (155) hide show
  1. package/cjs/CamOverlayAPI.js +2 -2
  2. package/cjs/CamStreamerAPI.js +54 -11
  3. package/cjs/CamSwitcherAPI.js +7 -7
  4. package/cjs/CamSwitcherEvents.js +4 -60
  5. package/cjs/PlaneTrackerAPI.js +52 -52
  6. package/cjs/VapixAPI.js +10 -7
  7. package/cjs/index.js +2 -11
  8. package/cjs/internal/ProxyClient.js +6 -6
  9. package/cjs/internal/WsEvents.js +72 -0
  10. package/cjs/node/DefaultClient.js +4 -4
  11. package/cjs/node/HttpRequestSender.js +1 -1
  12. package/cjs/node/WsClient.js +1 -1
  13. package/cjs/{events → node/events}/AxisCameraStationEvents.js +4 -4
  14. package/cjs/{events → node/events}/GenetecAgent.js +43 -32
  15. package/cjs/node/index.js +5 -8
  16. package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +14 -1
  17. package/cjs/types/CamOverlayAPI/scoreBoardSchema.js +127 -0
  18. package/cjs/types/CamStreamerAPI.js +30 -3
  19. package/esm/CamOverlayAPI.js +2 -2
  20. package/esm/CamStreamerAPI.js +53 -11
  21. package/esm/CamSwitcherAPI.js +7 -7
  22. package/esm/CamSwitcherEvents.js +5 -61
  23. package/esm/PlaneTrackerAPI.js +52 -52
  24. package/esm/VapixAPI.js +10 -7
  25. package/esm/index.js +1 -6
  26. package/esm/internal/ProxyClient.js +6 -6
  27. package/esm/internal/WsEvents.js +68 -0
  28. package/esm/node/DefaultClient.js +4 -4
  29. package/esm/node/HttpRequestSender.js +1 -1
  30. package/esm/node/WsClient.js +1 -1
  31. package/esm/{events → node/events}/AxisCameraStationEvents.js +3 -3
  32. package/esm/{events → node/events}/GenetecAgent.js +41 -30
  33. package/esm/node/index.js +5 -4
  34. package/esm/types/CamOverlayAPI/CamOverlayAPI.js +9 -0
  35. package/esm/types/CamOverlayAPI/scoreBoardSchema.js +124 -0
  36. package/esm/types/CamStreamerAPI.js +29 -2
  37. package/package.json +22 -2
  38. package/{cjs → types}/CamOverlayAPI.d.ts +3 -5
  39. package/{esm → types}/CamScripterAPI.d.ts +4 -4
  40. package/types/CamStreamerAPI.d.ts +48 -0
  41. package/{esm → types}/CamSwitcherAPI.d.ts +8 -8
  42. package/types/CamSwitcherEvents.d.ts +8 -0
  43. package/types/PlaneTrackerAPI.d.ts +43 -0
  44. package/{cjs → types}/VapixAPI.d.ts +11 -7
  45. package/{cjs → types}/index.d.ts +1 -6
  46. package/{esm → types}/internal/ProxyClient.d.ts +4 -4
  47. package/types/internal/WsEvents.d.ts +41 -0
  48. package/{esm → types}/internal/types.d.ts +12 -9
  49. package/{cjs → types}/node/DefaultClient.d.ts +6 -4
  50. package/{esm → types/node}/events/AxisCameraStationEvents.d.ts +4 -4
  51. package/{esm → types/node}/events/GenetecAgent.d.ts +14 -32
  52. package/types/node/index.d.ts +5 -0
  53. package/{cjs → types}/types/CamOverlayAPI/CamOverlayAPI.d.ts +1071 -7
  54. package/{esm → types}/types/CamOverlayAPI/infotickerSchema.d.ts +2 -2
  55. package/types/types/CamOverlayAPI/scoreBoardSchema.d.ts +357 -0
  56. package/types/types/CamStreamerAPI.d.ts +274 -0
  57. package/types/web/DefaultClient.d.ts +6 -0
  58. package/cjs/CamScripterAPI.d.ts +0 -37
  59. package/cjs/CamStreamerAPI.d.ts +0 -19
  60. package/cjs/CamSwitcherAPI.d.ts +0 -54
  61. package/cjs/CamSwitcherEvents.d.ts +0 -18
  62. package/cjs/PlaneTrackerAPI.d.ts +0 -43
  63. package/cjs/events/AxisCameraStationEvents.d.ts +0 -12
  64. package/cjs/events/GenetecAgent.d.ts +0 -177
  65. package/cjs/internal/ProxyClient.d.ts +0 -10
  66. package/cjs/internal/types.d.ts +0 -42
  67. package/cjs/node/index.d.ts +0 -4
  68. package/cjs/types/CamOverlayAPI/infotickerSchema.d.ts +0 -96
  69. package/cjs/types/CamStreamerAPI.d.ts +0 -150
  70. package/cjs/web/DefaultClient.d.ts +0 -6
  71. package/esm/CamOverlayAPI.d.ts +0 -41
  72. package/esm/CamOverlayDrawingAPI.d.ts +0 -41
  73. package/esm/CamOverlayPainter/Frame.d.ts +0 -67
  74. package/esm/CamOverlayPainter/Painter.d.ts +0 -43
  75. package/esm/CamOverlayPainter/ResourceManager.d.ts +0 -15
  76. package/esm/CamScripterAPICameraEventsGenerator.d.ts +0 -74
  77. package/esm/CamStreamerAPI.d.ts +0 -19
  78. package/esm/CamSwitcherEvents.d.ts +0 -18
  79. package/esm/CreatePackage.d.ts +0 -1
  80. package/esm/PlaneTrackerAPI.d.ts +0 -43
  81. package/esm/VapixAPI.d.ts +0 -80
  82. package/esm/VapixEvents.d.ts +0 -43
  83. package/esm/errors/errors.d.ts +0 -37
  84. package/esm/index.d.ts +0 -23
  85. package/esm/internal/Digest.d.ts +0 -4
  86. package/esm/internal/constants.d.ts +0 -1
  87. package/esm/internal/transformers.d.ts +0 -5
  88. package/esm/internal/utils.d.ts +0 -14
  89. package/esm/internal/versionCompare.d.ts +0 -6
  90. package/esm/node/DefaultClient.d.ts +0 -14
  91. package/esm/node/HttpRequestSender.d.ts +0 -29
  92. package/esm/node/HttpServer.d.ts +0 -21
  93. package/esm/node/WsClient.d.ts +0 -40
  94. package/esm/node/index.d.ts +0 -4
  95. package/esm/types/CamOverlayAPI/CamOverlayAPI.d.ts +0 -3260
  96. package/esm/types/CamOverlayAPI/accuweatherSchema.d.ts +0 -84
  97. package/esm/types/CamOverlayAPI/customGraphicsSchema.d.ts +0 -700
  98. package/esm/types/CamOverlayAPI/imagesSchema.d.ts +0 -95
  99. package/esm/types/CamOverlayAPI/index.d.ts +0 -11
  100. package/esm/types/CamOverlayAPI/pipSchema.d.ts +0 -125
  101. package/esm/types/CamOverlayAPI/ptzCompassSchema.d.ts +0 -93
  102. package/esm/types/CamOverlayAPI/ptzSchema.d.ts +0 -118
  103. package/esm/types/CamOverlayAPI/screenSharingSchema.d.ts +0 -58
  104. package/esm/types/CamOverlayAPI/webCameraSharingSchema.d.ts +0 -58
  105. package/esm/types/CamOverlayAPI/widgetCommonTypes.d.ts +0 -141
  106. package/esm/types/CamOverlayDrawingAPI.d.ts +0 -58
  107. package/esm/types/CamOverlayPainter.d.ts +0 -74
  108. package/esm/types/CamScripterAPI.d.ts +0 -132
  109. package/esm/types/CamStreamerAPI.d.ts +0 -150
  110. package/esm/types/CamSwitcherAPI.d.ts +0 -812
  111. package/esm/types/CamSwitcherEvents.d.ts +0 -568
  112. package/esm/types/PlaneTrackerAPI.d.ts +0 -8
  113. package/esm/types/VapixAPI.d.ts +0 -1819
  114. package/esm/types/common.d.ts +0 -46
  115. package/esm/web/DefaultClient.d.ts +0 -6
  116. package/esm/web/WsClient.d.ts +0 -13
  117. package/esm/web/index.d.ts +0 -2
  118. /package/cjs/{internal → node}/Digest.js +0 -0
  119. /package/esm/{internal → node}/Digest.js +0 -0
  120. /package/{cjs → types}/CamOverlayDrawingAPI.d.ts +0 -0
  121. /package/{cjs → types}/CamOverlayPainter/Frame.d.ts +0 -0
  122. /package/{cjs → types}/CamOverlayPainter/Painter.d.ts +0 -0
  123. /package/{cjs → types}/CamOverlayPainter/ResourceManager.d.ts +0 -0
  124. /package/{cjs → types}/CamScripterAPICameraEventsGenerator.d.ts +0 -0
  125. /package/{cjs → types}/CreatePackage.d.ts +0 -0
  126. /package/{cjs → types}/VapixEvents.d.ts +0 -0
  127. /package/{cjs → types}/errors/errors.d.ts +0 -0
  128. /package/{cjs → types}/internal/constants.d.ts +0 -0
  129. /package/{cjs → types}/internal/transformers.d.ts +0 -0
  130. /package/{cjs → types}/internal/utils.d.ts +0 -0
  131. /package/{cjs → types}/internal/versionCompare.d.ts +0 -0
  132. /package/{cjs/internal → types/node}/Digest.d.ts +0 -0
  133. /package/{cjs → types}/node/HttpRequestSender.d.ts +0 -0
  134. /package/{cjs → types}/node/HttpServer.d.ts +0 -0
  135. /package/{cjs → types}/node/WsClient.d.ts +0 -0
  136. /package/{cjs → types}/types/CamOverlayAPI/accuweatherSchema.d.ts +0 -0
  137. /package/{cjs → types}/types/CamOverlayAPI/customGraphicsSchema.d.ts +0 -0
  138. /package/{cjs → types}/types/CamOverlayAPI/imagesSchema.d.ts +0 -0
  139. /package/{cjs → types}/types/CamOverlayAPI/index.d.ts +0 -0
  140. /package/{cjs → types}/types/CamOverlayAPI/pipSchema.d.ts +0 -0
  141. /package/{cjs → types}/types/CamOverlayAPI/ptzCompassSchema.d.ts +0 -0
  142. /package/{cjs → types}/types/CamOverlayAPI/ptzSchema.d.ts +0 -0
  143. /package/{cjs → types}/types/CamOverlayAPI/screenSharingSchema.d.ts +0 -0
  144. /package/{cjs → types}/types/CamOverlayAPI/webCameraSharingSchema.d.ts +0 -0
  145. /package/{cjs → types}/types/CamOverlayAPI/widgetCommonTypes.d.ts +0 -0
  146. /package/{cjs → types}/types/CamOverlayDrawingAPI.d.ts +0 -0
  147. /package/{cjs → types}/types/CamOverlayPainter.d.ts +0 -0
  148. /package/{cjs → types}/types/CamScripterAPI.d.ts +0 -0
  149. /package/{cjs → types}/types/CamSwitcherAPI.d.ts +0 -0
  150. /package/{cjs → types}/types/CamSwitcherEvents.d.ts +0 -0
  151. /package/{cjs → types}/types/PlaneTrackerAPI.d.ts +0 -0
  152. /package/{cjs → types}/types/VapixAPI.d.ts +0 -0
  153. /package/{cjs → types}/types/common.d.ts +0 -0
  154. /package/{cjs → types}/web/WsClient.d.ts +0 -0
  155. /package/{cjs → types}/web/index.d.ts +0 -0
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AxisCameraStationEvents = void 0;
4
- const utils_1 = require("../internal/utils");
5
- const ProxyClient_1 = require("../internal/ProxyClient");
6
- const node_1 = require("../node");
4
+ const utils_1 = require("../../internal/utils");
5
+ const ProxyClient_1 = require("../../internal/ProxyClient");
6
+ const DefaultClient_1 = require("../DefaultClient");
7
7
  class AxisCameraStationEvents {
8
8
  sourceKey;
9
9
  client;
10
10
  constructor(clientOptions, sourceKey) {
11
11
  this.sourceKey = sourceKey;
12
- this.client = new node_1.DefaultClient(clientOptions);
12
+ this.client = new DefaultClient_1.DefaultClient(clientOptions);
13
13
  }
14
14
  getClient(proxyParams) {
15
15
  return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
@@ -1,31 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GenetecAgent = exports.cameraDetailsResponseSchema = exports.cameraDetailSchema = void 0;
3
+ exports.GenetecAgent = void 0;
4
4
  const zod_1 = require("zod");
5
- const utils_1 = require("../internal/utils");
6
- const ACTION = 'AddCameraBookmark';
7
- const GET_CAMERAS_URL = 'report/EntityConfiguration?q=EntityTypes@Camera';
8
- const GET_CAMERAS_DETAILS_URL = '/entity?q=';
9
- const cameraGuidsResponseSchema = zod_1.z.object({
5
+ const utils_1 = require("../../internal/utils");
6
+ const successResponseSchema = zod_1.z.object({
10
7
  Rsp: zod_1.z.object({
11
- Status: zod_1.z.string(),
12
- Result: zod_1.z.array(zod_1.z.object({ Guid: zod_1.z.string() })),
8
+ Status: zod_1.z.literal('Ok'),
13
9
  }),
14
10
  });
15
- const connectionResponseSchema = zod_1.z.object({
11
+ const cameraGuidsResponseSchema = zod_1.z.object({
16
12
  Rsp: zod_1.z.object({
17
- Status: zod_1.z.string(),
13
+ Status: zod_1.z.literal('Ok'),
14
+ Result: zod_1.z.array(zod_1.z.object({ Guid: zod_1.z.string() })),
18
15
  }),
19
16
  });
20
- exports.cameraDetailSchema = zod_1.z.object({
17
+ const cameraDetailSchema = zod_1.z.object({
21
18
  Guid: zod_1.z.string().optional(),
22
19
  Name: zod_1.z.string().optional(),
23
20
  EntityType: zod_1.z.string().optional(),
24
21
  });
25
- exports.cameraDetailsResponseSchema = zod_1.z.object({
22
+ const cameraDetailsResponseSchema = zod_1.z.object({
26
23
  Rsp: zod_1.z.object({
27
- Status: zod_1.z.string(),
28
- Result: zod_1.z.union([zod_1.z.array(exports.cameraDetailSchema), exports.cameraDetailSchema]),
24
+ Status: zod_1.z.literal('Ok'),
25
+ Result: zod_1.z.union([zod_1.z.array(cameraDetailSchema), cameraDetailSchema]),
29
26
  }),
30
27
  });
31
28
  class GenetecAgent {
@@ -48,56 +45,70 @@ class GenetecAgent {
48
45
  }
49
46
  async checkConnection() {
50
47
  const requestOptions = this.getRequestOptions('GET');
51
- const res = await this.fetchWithTimeout(`${this.baseUrl}/`, requestOptions);
48
+ const res = await this.fetchWithTimeout(new URL(this.baseUrl), requestOptions);
52
49
  if (!res.ok) {
53
50
  throw new Error(await (0, utils_1.responseStringify)(res));
54
51
  }
55
- return connectionResponseSchema.parse(await res.json());
52
+ const responseBody = await res.text();
53
+ const result = await successResponseSchema.safeParseAsync(JSON.parse(responseBody));
54
+ if (!result.success) {
55
+ throw new Error('Genetec connection test failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
56
+ }
56
57
  }
57
58
  async getAllCameraGuids() {
58
59
  const requestOptions = this.getRequestOptions('GET');
59
- const res = await this.fetchWithTimeout(`${this.baseUrl}/${GET_CAMERAS_URL}`, requestOptions);
60
+ const url = new URL(`${this.baseUrl}/report/EntityConfiguration`);
61
+ url.searchParams.set('q', 'EntityTypes@Camera');
62
+ const res = await this.fetchWithTimeout(url, requestOptions);
60
63
  if (!res.ok) {
61
64
  throw new Error(await (0, utils_1.responseStringify)(res));
62
65
  }
63
- return cameraGuidsResponseSchema.parse(await res.json());
66
+ const responseBody = await res.text();
67
+ const result = await cameraGuidsResponseSchema.safeParseAsync(JSON.parse(responseBody));
68
+ if (!result.success) {
69
+ throw new Error('Genetec get camera guids failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
70
+ }
71
+ return result.data;
64
72
  }
65
73
  async getCameraDetails(guids, parameters) {
66
74
  const params = parameters.join(',');
67
- let camerasGuids = [];
68
75
  const requestOptions = this.getRequestOptions('GET');
69
76
  const allCameras = [];
70
77
  const chunkSize = 10;
71
78
  while (guids.length > 0) {
72
79
  const chunk = guids.slice(0, chunkSize);
73
80
  guids.splice(0, chunkSize);
74
- camerasGuids = chunk.map((item) => item.Guid);
75
- const camerasDetailsUrl = [];
76
- for (const guid of camerasGuids) {
77
- camerasDetailsUrl.push(`entity=${guid},${params}`);
78
- }
79
- const res = await this.fetchWithTimeout(`${this.baseUrl}/${GET_CAMERAS_DETAILS_URL}${camerasDetailsUrl.join(',')}`, requestOptions);
81
+ const url = new URL(`${this.baseUrl}/entity`);
82
+ url.searchParams.set('q', chunk.map((item) => `entity=${item.Guid},${params}`).join(','));
83
+ const res = await this.fetchWithTimeout(url, requestOptions);
80
84
  if (!res.ok) {
81
85
  throw new Error(await (0, utils_1.responseStringify)(res));
82
86
  }
83
- const data = exports.cameraDetailsResponseSchema.parse(await res.json());
87
+ const responseBody = await res.text();
88
+ const result = await cameraDetailsResponseSchema.safeParseAsync(JSON.parse(responseBody));
89
+ if (!result.success) {
90
+ throw new Error('Genetec get camera details failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
91
+ }
92
+ const data = result.data;
84
93
  const resultArray = Array.isArray(data.Rsp.Result) ? data.Rsp.Result : [data.Rsp.Result];
85
94
  allCameras.push(...resultArray);
86
95
  }
87
96
  return allCameras;
88
97
  }
89
98
  async sendBookmark(guids, bookmarkText) {
90
- const cameraEntitiesUrl = [];
91
99
  const timeStamp = this.getTimeStamp();
92
100
  const requestOptions = this.getRequestOptions('POST');
93
- for (const guid of guids) {
94
- cameraEntitiesUrl.push(`${ACTION}(${guid},${timeStamp},${bookmarkText})`);
95
- }
96
- const res = await this.fetchWithTimeout(`${this.baseUrl}/action?q=${cameraEntitiesUrl.join(',')}`, requestOptions);
101
+ const url = new URL(`${this.baseUrl}/action`);
102
+ url.searchParams.set('q', guids.map((guid) => `AddCameraBookmark(${guid},${timeStamp},${bookmarkText})`).join(','));
103
+ const res = await this.fetchWithTimeout(url, requestOptions);
97
104
  if (!res.ok) {
98
105
  throw new Error(await (0, utils_1.responseStringify)(res));
99
106
  }
100
- return res;
107
+ const responseBody = await res.text();
108
+ const result = await successResponseSchema.safeParseAsync(JSON.parse(responseBody));
109
+ if (!result.success) {
110
+ throw new Error('Genetec send bookmark failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
111
+ }
101
112
  }
102
113
  getRequestOptions(method) {
103
114
  return {
package/cjs/node/index.js CHANGED
@@ -14,11 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.AxisCameraStationEvents = exports.WsClient = exports.DefaultClient = void 0;
18
- var DefaultClient_1 = require("./DefaultClient");
19
- Object.defineProperty(exports, "DefaultClient", { enumerable: true, get: function () { return DefaultClient_1.DefaultClient; } });
20
- var WsClient_1 = require("./WsClient");
21
- Object.defineProperty(exports, "WsClient", { enumerable: true, get: function () { return WsClient_1.WsClient; } });
22
- var AxisCameraStationEvents_1 = require("../events/AxisCameraStationEvents");
23
- Object.defineProperty(exports, "AxisCameraStationEvents", { enumerable: true, get: function () { return AxisCameraStationEvents_1.AxisCameraStationEvents; } });
24
- __exportStar(require("../events/GenetecAgent"), exports);
17
+ __exportStar(require("./DefaultClient"), exports);
18
+ __exportStar(require("./WsClient"), exports);
19
+ __exportStar(require("./HttpServer"), exports);
20
+ __exportStar(require("./events/AxisCameraStationEvents"), exports);
21
+ __exportStar(require("./events/GenetecAgent"), exports);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fileDataSchema = exports.fileListSchema = exports.fileSchema = exports.storageResponseSchema = exports.storageDataListSchema = exports.storageSchema = exports.ImageType = exports.isWebCameraSharing = exports.isScreenSharing = exports.isPtz = exports.isPtzCompass = exports.isPip = exports.isInfoticker = exports.isImages = exports.isCustomGraphics = exports.isAccuweather = exports.widgetListSchema = exports.widgetsSchema = exports.WSResponseSchema = void 0;
3
+ exports.fileDataSchema = exports.fileListSchema = exports.fileSchema = exports.storageResponseSchema = exports.storageDataListSchema = exports.storageSchema = exports.ImageType = exports.isScoreOverview = exports.isBaseballScoreBoardAutomatic = exports.isBaseballScoreBoard = exports.isScoreBoard = exports.isWebCameraSharing = exports.isScreenSharing = exports.isPtz = exports.isPtzCompass = exports.isPip = exports.isInfoticker = exports.isImages = exports.isCustomGraphics = exports.isAccuweather = exports.widgetListSchema = exports.widgetsSchema = exports.WSResponseSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const infotickerSchema_1 = require("./infotickerSchema");
6
6
  const accuweatherSchema_1 = require("./accuweatherSchema");
@@ -11,6 +11,7 @@ const pipSchema_1 = require("./pipSchema");
11
11
  const customGraphicsSchema_1 = require("./customGraphicsSchema");
12
12
  const screenSharingSchema_1 = require("./screenSharingSchema");
13
13
  const webCameraSharingSchema_1 = require("./webCameraSharingSchema");
14
+ const scoreBoardSchema_1 = require("./scoreBoardSchema");
14
15
  exports.WSResponseSchema = zod_1.z.object({
15
16
  status: zod_1.z.number(),
16
17
  message: zod_1.z.string(),
@@ -26,6 +27,10 @@ exports.widgetsSchema = zod_1.z.discriminatedUnion('name', [
26
27
  customGraphicsSchema_1.customGraphicsSchema,
27
28
  screenSharingSchema_1.screenSharingSchema,
28
29
  webCameraSharingSchema_1.webCameraSharingSchema,
30
+ scoreBoardSchema_1.scoreBoardSchema,
31
+ scoreBoardSchema_1.baseballScoreBoardSchema,
32
+ scoreBoardSchema_1.baseballScoreBoardAutomaticSchema,
33
+ scoreBoardSchema_1.scoreOverviewSchema,
29
34
  ]);
30
35
  exports.widgetListSchema = zod_1.z.object({
31
36
  services: zod_1.z.array(exports.widgetsSchema),
@@ -48,6 +53,14 @@ const isScreenSharing = (widget) => widget.name === 'screenSharing';
48
53
  exports.isScreenSharing = isScreenSharing;
49
54
  const isWebCameraSharing = (widget) => widget.name === 'web_camera';
50
55
  exports.isWebCameraSharing = isWebCameraSharing;
56
+ const isScoreBoard = (widget) => widget.name === 'scoreBoard';
57
+ exports.isScoreBoard = isScoreBoard;
58
+ const isBaseballScoreBoard = (widget) => widget.name === 'baseballScoreBoard';
59
+ exports.isBaseballScoreBoard = isBaseballScoreBoard;
60
+ const isBaseballScoreBoardAutomatic = (widget) => widget.name === 'myBallBaseballWidgets';
61
+ exports.isBaseballScoreBoardAutomatic = isBaseballScoreBoardAutomatic;
62
+ const isScoreOverview = (widget) => widget.name === 'scoreOverview';
63
+ exports.isScoreOverview = isScoreOverview;
51
64
  var ImageType;
52
65
  (function (ImageType) {
53
66
  ImageType[ImageType["PNG"] = 0] = "PNG";
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scoreOverviewSchema = exports.baseballScoreBoardAutomaticSchema = exports.baseballScoreBoardSchema = exports.scoreBoardSchema = exports.sportFontSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const widgetCommonTypes_1 = require("./widgetCommonTypes");
6
+ exports.sportFontSchema = zod_1.z.union([zod_1.z.literal('classic'), zod_1.z.intersection(zod_1.z.string(), zod_1.z.object({}))]);
7
+ exports.scoreBoardSchema = zod_1.z.object({
8
+ id: zod_1.z.number().nonnegative(),
9
+ enabled: zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1)]),
10
+ schedule: zod_1.z.string().optional(),
11
+ cameraList: zod_1.z.array(zod_1.z.number()),
12
+ zIndex: zod_1.z.number().nonnegative(),
13
+ name: zod_1.z.literal('scoreBoard'),
14
+ pos_x: zod_1.z.number(),
15
+ pos_y: zod_1.z.number(),
16
+ coordSystem: widgetCommonTypes_1.coordinateSystemSchema,
17
+ width: zod_1.z.number(),
18
+ height: zod_1.z.number(),
19
+ scale: zod_1.z.number(),
20
+ teamHomeShortname: zod_1.z.string(),
21
+ teamGuestShortname: zod_1.z.string(),
22
+ teamHomeBackgroundColor: zod_1.z.string(),
23
+ teamGuestBackgroundColor: zod_1.z.string(),
24
+ teamHomeTextColor: zod_1.z.string(),
25
+ teamGuestTextColor: zod_1.z.string(),
26
+ teamHomeImgPath: zod_1.z.string(),
27
+ teamGuestImgPath: zod_1.z.string(),
28
+ teamHomeCurrentScore: zod_1.z.number(),
29
+ teamGuestCurrentScore: zod_1.z.number(),
30
+ baseTimeTimestamp: zod_1.z.number(),
31
+ baseTimePlaytime: zod_1.z.number(),
32
+ currentPeriodPlaytime: zod_1.z.number(),
33
+ timeIsRunning: zod_1.z.boolean(),
34
+ currentPeriodLength: zod_1.z.number(),
35
+ currentPeriod: zod_1.z.number(),
36
+ font: exports.sportFontSchema.default('classic'),
37
+ });
38
+ exports.baseballScoreBoardSchema = zod_1.z.object({
39
+ id: zod_1.z.number().nonnegative(),
40
+ enabled: zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1)]),
41
+ schedule: zod_1.z.string().optional(),
42
+ cameraList: zod_1.z.array(zod_1.z.number()),
43
+ zIndex: zod_1.z.number().nonnegative(),
44
+ name: zod_1.z.literal('baseballScoreBoard'),
45
+ pos_x: zod_1.z.number(),
46
+ pos_y: zod_1.z.number(),
47
+ coordSystem: widgetCommonTypes_1.coordinateSystemSchema,
48
+ width: zod_1.z.number(),
49
+ height: zod_1.z.number(),
50
+ scale: zod_1.z.number(),
51
+ matchFinished: zod_1.z.boolean(),
52
+ bases: zod_1.z.tuple([zod_1.z.boolean(), zod_1.z.boolean(), zod_1.z.boolean()]),
53
+ homeInning: zod_1.z.boolean(),
54
+ inning: zod_1.z.number().nonnegative(),
55
+ outs: zod_1.z.number().nonnegative(),
56
+ balls: zod_1.z.number().nonnegative(),
57
+ strikes: zod_1.z.number().nonnegative(),
58
+ baseTimeTimestamp: zod_1.z.number(),
59
+ baseTimePlaytime: zod_1.z.number(),
60
+ timeIsRunning: zod_1.z.boolean(),
61
+ teamHomeShortname: zod_1.z.string(),
62
+ teamGuestShortname: zod_1.z.string(),
63
+ teamHomeBackgroundColor: zod_1.z.string(),
64
+ teamGuestBackgroundColor: zod_1.z.string(),
65
+ teamHomeTextColor: zod_1.z.string(),
66
+ teamGuestTextColor: zod_1.z.string(),
67
+ teamHomeCurrentScore: zod_1.z.number(),
68
+ teamGuestCurrentScore: zod_1.z.number(),
69
+ footerImgPath: zod_1.z.string().optional(),
70
+ footerText: zod_1.z.string().optional(),
71
+ footerBackgroundColor: zod_1.z.string().optional(),
72
+ footerTextColor: zod_1.z.string().optional(),
73
+ font: exports.sportFontSchema.default('classic'),
74
+ });
75
+ exports.baseballScoreBoardAutomaticSchema = zod_1.z.object({
76
+ id: zod_1.z.number().nonnegative(),
77
+ enabled: zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1)]),
78
+ schedule: zod_1.z.string().optional(),
79
+ cameraList: zod_1.z.array(zod_1.z.number()),
80
+ zIndex: zod_1.z.number().nonnegative(),
81
+ name: zod_1.z.literal('myBallBaseballWidgets'),
82
+ width: zod_1.z.number(),
83
+ height: zod_1.z.number(),
84
+ scale: zod_1.z.number(),
85
+ matchDetailLink: zod_1.z.string(),
86
+ matchListLink: zod_1.z.string(),
87
+ mirrored: zod_1.z.boolean(),
88
+ pregameWidgetText: zod_1.z.string(),
89
+ teamHomeBackgroundColor: zod_1.z.string(),
90
+ teamGuestBackgroundColor: zod_1.z.string(),
91
+ teamHomeTextColor: zod_1.z.string(),
92
+ teamGuestTextColor: zod_1.z.string(),
93
+ homeLogoPath: zod_1.z.string(),
94
+ guestLogoPath: zod_1.z.string(),
95
+ footerImgPath: zod_1.z.string().optional(),
96
+ footerText: zod_1.z.string().optional(),
97
+ footerBackgroundColor: zod_1.z.string().optional(),
98
+ footerTextColor: zod_1.z.string().optional(),
99
+ font: exports.sportFontSchema.default('classic'),
100
+ });
101
+ exports.scoreOverviewSchema = zod_1.z.object({
102
+ id: zod_1.z.number().nonnegative(),
103
+ enabled: zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1)]),
104
+ cameraList: zod_1.z.array(zod_1.z.number()),
105
+ zIndex: zod_1.z.number().nonnegative(),
106
+ name: zod_1.z.literal('scoreOverview'),
107
+ pos_x: zod_1.z.number(),
108
+ pos_y: zod_1.z.number(),
109
+ coordSystem: widgetCommonTypes_1.coordinateSystemSchema,
110
+ width: zod_1.z.number(),
111
+ height: zod_1.z.number(),
112
+ scale: zod_1.z.number(),
113
+ teamHomeName: zod_1.z.string(),
114
+ teamGuestName: zod_1.z.string(),
115
+ teamHomeBackgroundColor: zod_1.z.string(),
116
+ teamGuestBackgroundColor: zod_1.z.string(),
117
+ teamHomeTextColor: zod_1.z.string(),
118
+ teamGuestTextColor: zod_1.z.string(),
119
+ teamHomeImgPath: zod_1.z.string(),
120
+ teamGuestImgPath: zod_1.z.string(),
121
+ teamHomeCurrentScore: zod_1.z.number(),
122
+ teamGuestCurrentScore: zod_1.z.number(),
123
+ scoreVisible: zod_1.z.boolean(),
124
+ description: zod_1.z.string(),
125
+ textFont: exports.sportFontSchema.default('classic'),
126
+ scoreFont: zod_1.z.literal('classic'),
127
+ });
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.camstreamerServerResponseSchema = exports.streamListSchema = exports.streamAttributesSchema = void 0;
3
+ exports.camstreamerServerResponseSchema = exports.cameraStreamResponseSchema = exports.streamSchema = exports.cameraStreamSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- exports.streamAttributesSchema = zod_1.z.object({
5
+ exports.cameraStreamSchema = zod_1.z.object({
6
6
  enabled: zod_1.z.string(),
7
7
  active: zod_1.z.string(),
8
8
  audioSource: zod_1.z.string(),
@@ -25,7 +25,34 @@ exports.streamAttributesSchema = zod_1.z.object({
25
25
  startTime: zod_1.z.string(),
26
26
  stopTime: zod_1.z.string(),
27
27
  });
28
- exports.streamListSchema = zod_1.z.record(zod_1.z.string(), exports.streamAttributesSchema);
28
+ exports.streamSchema = zod_1.z.object({
29
+ enabled: zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1)]),
30
+ active: zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1)]),
31
+ audioSource: zod_1.z.string(),
32
+ avSyncMsec: zod_1.z.number().int(),
33
+ internalVapixParameters: zod_1.z.string(),
34
+ userVapixParameters: zod_1.z.string(),
35
+ outputParameters: zod_1.z.string(),
36
+ outputType: zod_1.z.union([zod_1.z.literal('video'), zod_1.z.literal('images'), zod_1.z.literal('none')]),
37
+ mediaServerUrl: zod_1.z.string(),
38
+ inputType: zod_1.z.union([zod_1.z.literal('CSw'), zod_1.z.literal('CRS'), zod_1.z.literal('RTSP_URL')]),
39
+ inputUrl: zod_1.z.string(),
40
+ forceStereo: zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1)]),
41
+ streamDelay: zod_1.z.number().nullable(),
42
+ statusLed: zod_1.z.number(),
43
+ statusPort: zod_1.z.string(),
44
+ callApi: zod_1.z.number().int(),
45
+ trigger: zod_1.z.string(),
46
+ schedule: zod_1.z.string(),
47
+ prepareAhead: zod_1.z.number().int(),
48
+ startTime: zod_1.z.number().nullable(),
49
+ stopTime: zod_1.z.number().nullable(),
50
+ });
51
+ exports.cameraStreamResponseSchema = zod_1.z.object({
52
+ data: exports.cameraStreamSchema,
53
+ code: zod_1.z.number(),
54
+ message: zod_1.z.string(),
55
+ });
29
56
  exports.camstreamerServerResponseSchema = zod_1.z.object({
30
57
  code: zod_1.z.number(),
31
58
  message: zod_1.z.string(),
@@ -198,7 +198,7 @@ export class CamOverlayAPI {
198
198
  const agent = this.getClient(options?.proxyParams);
199
199
  const res = await agent.get({ ...params, timeout: options?.timeout });
200
200
  if (res.ok) {
201
- return (await res.json());
201
+ return await res.json();
202
202
  }
203
203
  else {
204
204
  throw new Error(await responseStringify(res));
@@ -208,7 +208,7 @@ export class CamOverlayAPI {
208
208
  const agent = this.getClient(options?.proxyParams);
209
209
  const res = await agent.post({ ...params, timeout: options?.timeout });
210
210
  if (res.ok) {
211
- return (await res.json());
211
+ return await res.json();
212
212
  }
213
213
  else {
214
214
  throw new Error(await responseStringify(res));
@@ -1,6 +1,7 @@
1
+ import z from 'zod';
1
2
  import { ProxyClient } from './internal/ProxyClient';
2
3
  import { responseStringify } from './internal/utils';
3
- import { streamAttributesSchema, streamListSchema } from './types/CamStreamerAPI';
4
+ import { cameraStreamSchema } from './types/CamStreamerAPI';
4
5
  const BASE_PATH = '/local/camstreamer';
5
6
  export class CamStreamerAPI {
6
7
  client;
@@ -12,11 +13,18 @@ export class CamStreamerAPI {
12
13
  }
13
14
  async getStreamList(options) {
14
15
  const streamListRes = await this.get(`${BASE_PATH}/stream/list.cgi`, undefined, options);
15
- return streamListSchema.parse(streamListRes.data);
16
+ const list = z.record(z.string(), cameraStreamSchema).parse(streamListRes.data);
17
+ const res = {};
18
+ for (const [key, data] of Object.entries(list)) {
19
+ const streamId = parseInt(key);
20
+ res[streamId] = parseCameraStreamResponse(data);
21
+ }
22
+ return res;
16
23
  }
17
24
  async getStream(streamId, options) {
18
25
  const stream = await this.get(`${BASE_PATH}/stream/get.cgi?stream_id=${streamId}`, undefined, options);
19
- return streamAttributesSchema.parse(stream.data);
26
+ const cameraData = cameraStreamSchema.parse(stream.data);
27
+ return parseCameraStreamResponse(cameraData);
20
28
  }
21
29
  async getStreamParameter(streamId, paramName, options) {
22
30
  const stream = await this.get(`${BASE_PATH}/stream/get.cgi?stream_id=${streamId}`, undefined, options);
@@ -24,29 +32,38 @@ export class CamStreamerAPI {
24
32
  }
25
33
  async setStream(streamId, params, options) {
26
34
  const { streamDelay, startTime, stopTime, ...rest } = params;
27
- await this.get(`${BASE_PATH}/stream/set.cgi`, {
35
+ return await this.get(`${BASE_PATH}/stream/set.cgi`, {
28
36
  stream_id: streamId,
29
37
  streamDelay: streamDelay ?? '',
30
- startTime: startTime ?? 'null',
31
- stopTime: stopTime ?? 'null',
38
+ startTime: startTime ?? null,
39
+ stopTime: stopTime ?? null,
32
40
  ...rest,
33
41
  }, options);
34
42
  }
35
43
  async setStreamParameter(streamId, paramName, value, options) {
36
- await this.get(`${BASE_PATH}/stream/set.cgi?stream_id=${streamId}&${paramName}=${value}`, undefined, options);
44
+ return await this.get(`${BASE_PATH}/stream/set.cgi?stream_id=${streamId}&${paramName}=${value}`, undefined, options);
37
45
  }
38
46
  async isStreaming(streamId, options) {
39
47
  const response = await this.get(`${BASE_PATH}/get_streamstat.cgi?stream_id=${streamId}`, undefined, options);
40
48
  return response.data.is_streaming === 1;
41
49
  }
42
50
  async deleteStream(streamId, options) {
43
- await this.get(`${BASE_PATH}/stream/remove.cgi`, { stream_id: streamId }, options);
51
+ const res = await this.get(`${BASE_PATH}/stream/remove.cgi`, { stream_id: streamId }, options);
52
+ return res.data.status === 200;
44
53
  }
45
- wsAuthorization(options) {
46
- return this.get(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
54
+ async getWsAuthorization(options) {
55
+ const res = await this.get(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
56
+ if (res.status !== 200) {
57
+ throw new Error(`Server error on ws authorization: ${res.message}`);
58
+ }
59
+ return res.data;
47
60
  }
48
61
  async getUtcTime(options) {
49
- return await this.get(`${BASE_PATH}/get_utc_time.cgi`, undefined, options);
62
+ const res = await this.get(`${BASE_PATH}/get_utc_time.cgi`, undefined, options);
63
+ if (res.status !== 200) {
64
+ throw new Error(`Server error on get UTC time: ${res.message}`);
65
+ }
66
+ return res.data;
50
67
  }
51
68
  async get(path, parameters, options) {
52
69
  const agent = this.getClient(options?.proxyParams);
@@ -59,3 +76,28 @@ export class CamStreamerAPI {
59
76
  }
60
77
  }
61
78
  }
79
+ export const parseCameraStreamResponse = (cameraStreamData) => {
80
+ return {
81
+ enabled: parseInt(cameraStreamData.enabled),
82
+ active: parseInt(cameraStreamData.active),
83
+ audioSource: cameraStreamData.audioSource,
84
+ avSyncMsec: parseInt(cameraStreamData.avSyncMsec),
85
+ internalVapixParameters: cameraStreamData.internalVapixParameters,
86
+ userVapixParameters: cameraStreamData.userVapixParameters,
87
+ outputParameters: cameraStreamData.outputParameters,
88
+ outputType: cameraStreamData.outputType,
89
+ mediaServerUrl: cameraStreamData.mediaServerUrl,
90
+ inputType: cameraStreamData.inputType,
91
+ inputUrl: cameraStreamData.inputUrl,
92
+ forceStereo: parseInt(cameraStreamData.forceStereo),
93
+ streamDelay: isNaN(parseInt(cameraStreamData.streamDelay)) ? null : parseInt(cameraStreamData.streamDelay),
94
+ statusLed: parseInt(cameraStreamData.statusLed),
95
+ statusPort: cameraStreamData.statusPort,
96
+ callApi: parseInt(cameraStreamData.callApi),
97
+ trigger: cameraStreamData.trigger,
98
+ schedule: cameraStreamData.schedule,
99
+ prepareAhead: parseInt(cameraStreamData.prepareAhead),
100
+ startTime: isNaN(parseInt(cameraStreamData.startTime)) ? null : parseInt(cameraStreamData.startTime),
101
+ stopTime: isNaN(parseInt(cameraStreamData.stopTime)) ? null : parseInt(cameraStreamData.stopTime),
102
+ };
103
+ };
@@ -108,10 +108,10 @@ export class CamSwitcherAPI {
108
108
  async playlistQueuePlayNext(options) {
109
109
  await this.get(`${BASE_PATH}/playlist_queue_play_next.cgi`, undefined, options);
110
110
  }
111
- async addNewClip(file, clipType, storage, id, fileName, options) {
111
+ async addNewClip(file, clipType, storage, clipId, fileName, options) {
112
112
  const path = `${BASE_PATH}/clip_upload.cgi?storage=${storage}`;
113
113
  const formData = new this.CustomFormData();
114
- formData.append('clip_name', id);
114
+ formData.append('clip_name', clipId);
115
115
  formData.append('clip_type', clipType);
116
116
  formData.append('file', file, fileName);
117
117
  const agent = this.getClient(options?.proxyParams);
@@ -121,8 +121,8 @@ export class CamSwitcherAPI {
121
121
  throw new AddNewClipError(output.message);
122
122
  }
123
123
  }
124
- removeClip(id, storage, options) {
125
- return this.get(`${BASE_PATH}/clip_remove.cgi`, { clip_name: id, storage }, options);
124
+ removeClip(clipId, storage, options) {
125
+ return this.get(`${BASE_PATH}/clip_remove.cgi`, { clip_name: clipId, storage }, options);
126
126
  }
127
127
  async getClipList(options) {
128
128
  const data = await this.get(`${BASE_PATH}/clip_list.cgi`, undefined, options);
@@ -177,8 +177,8 @@ export class CamSwitcherAPI {
177
177
  };
178
178
  return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SECONDARY_AUDIO, data, options);
179
179
  }
180
- setDefaultPlaylist(id, options) {
181
- const value = JSON.stringify({ default_playlist_id: id });
180
+ setDefaultPlaylist(playlistId, options) {
181
+ const value = JSON.stringify({ default_playlist_id: playlistId });
182
182
  return this.vapixAgent.setParameter({
183
183
  [CSW_PARAM_NAMES.DEFAULT_PLAYLIST]: value,
184
184
  }, options);
@@ -250,7 +250,7 @@ export class CamSwitcherAPI {
250
250
  const agent = this.getClient(options?.proxyParams);
251
251
  const res = await agent.get({ path, parameters, timeout: options?.timeout });
252
252
  if (res.ok) {
253
- const d = (await res.json());
253
+ const d = await res.json();
254
254
  return d.data;
255
255
  }
256
256
  else {
@@ -1,63 +1,7 @@
1
- import { cswEventsSchema, } from './types/CamSwitcherEvents';
2
- export class CamSwitcherEvents {
3
- isDestroyed = false;
4
- ws = null;
5
- listeners = {};
6
- setWebsocket(ws) {
7
- if (this.ws) {
8
- this.ws.destroy();
9
- }
10
- this.ws = ws;
11
- this.ws.onmessage = (e) => this.onMessage(e);
12
- }
13
- resendInitData() {
14
- const request = {
15
- command: 'sendInitData',
16
- };
17
- this.ws?.send(JSON.stringify(request));
18
- }
19
- addListener(type, listener, id) {
20
- const typeList = this.listeners[type];
21
- if (typeList === undefined) {
22
- this.listeners[type] = { [id]: listener };
23
- return;
24
- }
25
- typeList[id] = listener;
26
- }
27
- removeListener(type, id) {
28
- const typeList = this.listeners[type];
29
- if (typeList) {
30
- delete typeList[id];
31
- }
32
- }
33
- onMessage(evt) {
34
- if (this.isDestroyed) {
35
- return;
36
- }
37
- try {
38
- const eventData = JSON.parse(evt.data);
39
- const data = cswEventsSchema.parse(eventData);
40
- if (data.type === 'init') {
41
- this.processMessage(data.data, true);
42
- return;
43
- }
44
- this.processMessage(data, false);
45
- }
46
- catch (error) {
47
- console.error('Error parsing event data:', evt.data, error);
48
- }
49
- }
50
- processMessage(event, isInit) {
51
- const listeners = this.listeners[event.type];
52
- const list = Object.values(listeners ?? {});
53
- list.forEach((listener) => listener(event, isInit));
54
- }
55
- destroy() {
56
- this.isDestroyed = true;
57
- if (this.ws) {
58
- this.ws.destroy();
59
- this.ws = null;
60
- }
61
- this.listeners = {};
1
+ import { WsEvents } from './internal/WsEvents';
2
+ import { cswEventsSchema } from './types/CamSwitcherEvents';
3
+ export class CamSwitcherEvents extends WsEvents {
4
+ constructor(ws) {
5
+ super(cswEventsSchema, ws);
62
6
  }
63
7
  }