camstreamerlib 4.0.0-beta.29 → 4.0.0-beta.30

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 (161) hide show
  1. package/README.md +6 -2
  2. package/cjs/CamOverlayAPI.d.ts +38 -615
  3. package/cjs/CamOverlayAPI.js +128 -104
  4. package/cjs/CamOverlayDrawingAPI.d.ts +2 -47
  5. package/cjs/CamOverlayPainter/Frame.d.ts +8 -37
  6. package/cjs/CamOverlayPainter/Frame.js +33 -0
  7. package/cjs/CamOverlayPainter/Painter.d.ts +5 -10
  8. package/cjs/CamOverlayPainter/Painter.js +2 -4
  9. package/cjs/CamOverlayPainter/ResourceManager.d.ts +3 -2
  10. package/cjs/CamOverlayPainter/ResourceManager.js +2 -1
  11. package/cjs/CamScripterAPI.d.ts +12 -12
  12. package/cjs/CamScripterAPI.js +33 -27
  13. package/cjs/CamStreamerAPI.d.ts +11 -9
  14. package/cjs/CamStreamerAPI.js +28 -22
  15. package/cjs/CamSwitcherAPI.d.ts +35 -34
  16. package/cjs/CamSwitcherAPI.js +94 -82
  17. package/cjs/PlaneTrackerAPI.d.ts +30 -36
  18. package/cjs/PlaneTrackerAPI.js +132 -71
  19. package/cjs/VapixAPI.d.ts +43 -40
  20. package/cjs/VapixAPI.js +205 -183
  21. package/cjs/events/AxisCameraStationEvents.d.ts +5 -5
  22. package/cjs/events/AxisCameraStationEvents.js +17 -12
  23. package/cjs/events/GenetecAgent.d.ts +2 -0
  24. package/cjs/events/GenetecAgent.js +15 -4
  25. package/cjs/index.d.ts +7 -1
  26. package/cjs/index.js +12 -2
  27. package/cjs/internal/ProxyClient.d.ts +7 -8
  28. package/cjs/internal/ProxyClient.js +25 -31
  29. package/cjs/internal/types.d.ts +16 -9
  30. package/cjs/internal/utils.d.ts +1 -2
  31. package/cjs/internal/utils.js +1 -5
  32. package/cjs/node/DefaultClient.d.ts +3 -5
  33. package/cjs/node/DefaultClient.js +10 -14
  34. package/cjs/node/HttpRequestSender.d.ts +1 -0
  35. package/cjs/node/HttpRequestSender.js +13 -3
  36. package/cjs/node/WsClient.d.ts +1 -0
  37. package/cjs/node/index.d.ts +2 -0
  38. package/cjs/node/index.js +18 -1
  39. package/cjs/{models/CamOverlayAPI/widgetsSchema.d.ts → types/CamOverlayAPI/CamOverlayAPI.d.ts} +625 -375
  40. package/cjs/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/CamOverlayAPI.js} +65 -14
  41. package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.d.ts +40 -10
  42. package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.js +11 -9
  43. package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.d.ts +89 -5
  44. package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.js +9 -7
  45. package/{esm/models → cjs/types}/CamOverlayAPI/imagesSchema.d.ts +40 -13
  46. package/cjs/types/CamOverlayAPI/imagesSchema.js +12 -0
  47. package/cjs/{models → types}/CamOverlayAPI/index.d.ts +0 -4
  48. package/cjs/{models → types}/CamOverlayAPI/index.js +0 -4
  49. package/{esm/models → cjs/types}/CamOverlayAPI/infotickerSchema.d.ts +43 -9
  50. package/cjs/{models → types}/CamOverlayAPI/infotickerSchema.js +10 -8
  51. package/{esm/models → cjs/types}/CamOverlayAPI/pipSchema.d.ts +48 -7
  52. package/cjs/{models → types}/CamOverlayAPI/pipSchema.js +8 -6
  53. package/{esm/models → cjs/types}/CamOverlayAPI/ptzCompassSchema.d.ts +40 -7
  54. package/cjs/{models → types}/CamOverlayAPI/ptzCompassSchema.js +8 -6
  55. package/cjs/{models → types}/CamOverlayAPI/ptzSchema.d.ts +42 -14
  56. package/cjs/types/CamOverlayAPI/ptzSchema.js +15 -0
  57. package/{esm/models → cjs/types}/CamOverlayAPI/screenSharingSchema.d.ts +26 -5
  58. package/cjs/types/CamOverlayAPI/screenSharingSchema.js +11 -0
  59. package/cjs/{models → types}/CamOverlayAPI/webCameraSharingSchema.d.ts +26 -5
  60. package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +11 -0
  61. package/cjs/types/CamOverlayDrawingAPI.d.ts +58 -0
  62. package/cjs/types/CamOverlayDrawingAPI.js +2 -0
  63. package/cjs/types/CamOverlayPainter.d.ts +74 -0
  64. package/cjs/types/CamOverlayPainter.js +2 -0
  65. package/cjs/types/CamStreamerAPI.d.ts +4 -4
  66. package/cjs/types/PlaneTrackerAPI.d.ts +6 -0
  67. package/cjs/types/common.d.ts +12 -3
  68. package/cjs/web/DefaultClient.d.ts +4 -4
  69. package/cjs/web/DefaultClient.js +21 -11
  70. package/esm/CamOverlayAPI.d.ts +38 -615
  71. package/esm/CamOverlayAPI.js +127 -103
  72. package/esm/CamOverlayDrawingAPI.d.ts +2 -47
  73. package/esm/CamOverlayPainter/Frame.d.ts +8 -37
  74. package/esm/CamOverlayPainter/Frame.js +33 -0
  75. package/esm/CamOverlayPainter/Painter.d.ts +5 -10
  76. package/esm/CamOverlayPainter/Painter.js +1 -2
  77. package/esm/CamOverlayPainter/ResourceManager.d.ts +3 -2
  78. package/esm/CamOverlayPainter/ResourceManager.js +1 -1
  79. package/esm/CamScripterAPI.d.ts +12 -12
  80. package/esm/CamScripterAPI.js +32 -26
  81. package/esm/CamStreamerAPI.d.ts +11 -9
  82. package/esm/CamStreamerAPI.js +28 -22
  83. package/esm/CamSwitcherAPI.d.ts +35 -34
  84. package/esm/CamSwitcherAPI.js +95 -83
  85. package/esm/PlaneTrackerAPI.d.ts +30 -36
  86. package/esm/PlaneTrackerAPI.js +131 -70
  87. package/esm/VapixAPI.d.ts +43 -40
  88. package/esm/VapixAPI.js +204 -182
  89. package/esm/events/AxisCameraStationEvents.d.ts +5 -5
  90. package/esm/events/AxisCameraStationEvents.js +18 -13
  91. package/esm/events/GenetecAgent.d.ts +2 -0
  92. package/esm/events/GenetecAgent.js +15 -4
  93. package/esm/index.d.ts +7 -1
  94. package/esm/index.js +7 -1
  95. package/esm/internal/ProxyClient.d.ts +7 -8
  96. package/esm/internal/ProxyClient.js +25 -31
  97. package/esm/internal/types.d.ts +16 -9
  98. package/esm/internal/utils.d.ts +1 -2
  99. package/esm/internal/utils.js +0 -3
  100. package/esm/node/DefaultClient.d.ts +3 -5
  101. package/esm/node/DefaultClient.js +10 -14
  102. package/esm/node/HttpRequestSender.d.ts +1 -0
  103. package/esm/node/HttpRequestSender.js +13 -3
  104. package/esm/node/WsClient.d.ts +1 -0
  105. package/esm/node/index.d.ts +2 -0
  106. package/esm/node/index.js +2 -0
  107. package/esm/{models/CamOverlayAPI/widgetsSchema.d.ts → types/CamOverlayAPI/CamOverlayAPI.d.ts} +625 -375
  108. package/esm/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/CamOverlayAPI.js} +64 -13
  109. package/esm/{models → types}/CamOverlayAPI/accuweatherSchema.d.ts +40 -10
  110. package/esm/{models → types}/CamOverlayAPI/accuweatherSchema.js +3 -2
  111. package/esm/{models → types}/CamOverlayAPI/customGraphicsSchema.d.ts +89 -5
  112. package/esm/{models → types}/CamOverlayAPI/customGraphicsSchema.js +3 -2
  113. package/{cjs/models → esm/types}/CamOverlayAPI/imagesSchema.d.ts +40 -13
  114. package/esm/types/CamOverlayAPI/imagesSchema.js +8 -0
  115. package/esm/{models → types}/CamOverlayAPI/index.d.ts +0 -4
  116. package/esm/{models → types}/CamOverlayAPI/index.js +0 -4
  117. package/{cjs/models → esm/types}/CamOverlayAPI/infotickerSchema.d.ts +43 -9
  118. package/esm/{models → types}/CamOverlayAPI/infotickerSchema.js +3 -2
  119. package/{cjs/models → esm/types}/CamOverlayAPI/pipSchema.d.ts +48 -7
  120. package/esm/{models → types}/CamOverlayAPI/pipSchema.js +3 -2
  121. package/{cjs/models → esm/types}/CamOverlayAPI/ptzCompassSchema.d.ts +40 -7
  122. package/esm/{models → types}/CamOverlayAPI/ptzCompassSchema.js +3 -2
  123. package/esm/{models → types}/CamOverlayAPI/ptzSchema.d.ts +42 -14
  124. package/esm/{models → types}/CamOverlayAPI/ptzSchema.js +3 -2
  125. package/{cjs/models → esm/types}/CamOverlayAPI/screenSharingSchema.d.ts +26 -5
  126. package/esm/types/CamOverlayAPI/screenSharingSchema.js +7 -0
  127. package/esm/{models → types}/CamOverlayAPI/webCameraSharingSchema.d.ts +26 -5
  128. package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +7 -0
  129. package/esm/types/CamOverlayDrawingAPI.d.ts +58 -0
  130. package/esm/types/CamOverlayDrawingAPI.js +1 -0
  131. package/esm/types/CamOverlayPainter.d.ts +74 -0
  132. package/esm/types/CamOverlayPainter.js +1 -0
  133. package/esm/types/CamStreamerAPI.d.ts +4 -4
  134. package/esm/types/PlaneTrackerAPI.d.ts +6 -0
  135. package/esm/types/common.d.ts +12 -3
  136. package/esm/web/DefaultClient.d.ts +4 -4
  137. package/esm/web/DefaultClient.js +21 -11
  138. package/package.json +2 -2
  139. package/cjs/models/CamOverlayAPI/constants.d.ts +0 -11
  140. package/cjs/models/CamOverlayAPI/constants.js +0 -14
  141. package/cjs/models/CamOverlayAPI/fileSchema.d.ts +0 -28
  142. package/cjs/models/CamOverlayAPI/fileSchema.js +0 -17
  143. package/cjs/models/CamOverlayAPI/imagesSchema.js +0 -10
  144. package/cjs/models/CamOverlayAPI/ptzSchema.js +0 -13
  145. package/cjs/models/CamOverlayAPI/screenSharingSchema.js +0 -9
  146. package/cjs/models/CamOverlayAPI/webCameraSharingSchema.js +0 -9
  147. package/cjs/models/CamOverlayAPI/widgetCommonSchema.d.ts +0 -126
  148. package/cjs/models/CamOverlayAPI/widgetsSchema.js +0 -27
  149. package/cjs/types/CamOverlayAPI.d.ts +0 -328
  150. package/cjs/types/CamOverlayAPI.js +0 -26
  151. package/esm/models/CamOverlayAPI/constants.d.ts +0 -11
  152. package/esm/models/CamOverlayAPI/constants.js +0 -11
  153. package/esm/models/CamOverlayAPI/fileSchema.d.ts +0 -28
  154. package/esm/models/CamOverlayAPI/fileSchema.js +0 -14
  155. package/esm/models/CamOverlayAPI/imagesSchema.js +0 -7
  156. package/esm/models/CamOverlayAPI/screenSharingSchema.js +0 -6
  157. package/esm/models/CamOverlayAPI/webCameraSharingSchema.js +0 -6
  158. package/esm/models/CamOverlayAPI/widgetCommonSchema.d.ts +0 -126
  159. package/esm/models/CamOverlayAPI/widgetsSchema.js +0 -24
  160. package/esm/types/CamOverlayAPI.d.ts +0 -328
  161. package/esm/types/CamOverlayAPI.js +0 -14
@@ -1,97 +1,103 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CamOverlayAPI = exports.BASE_URL = void 0;
3
+ exports.CamOverlayAPI = exports.allowedWidgetNames = void 0;
4
4
  const utils_1 = require("./internal/utils");
5
- const CamOverlayAPI_1 = require("./types/CamOverlayAPI");
6
5
  const errors_1 = require("./errors/errors");
7
6
  const common_1 = require("./types/common");
8
7
  const zod_1 = require("zod");
9
- const widgetsSchema_1 = require("./models/CamOverlayAPI/widgetsSchema");
10
- const fileSchema_1 = require("./models/CamOverlayAPI/fileSchema");
11
- exports.BASE_URL = '/local/camoverlay/api';
8
+ const ProxyClient_1 = require("./internal/ProxyClient");
9
+ const CamOverlayAPI_1 = require("./types/CamOverlayAPI/CamOverlayAPI");
10
+ exports.allowedWidgetNames = {
11
+ accuweather: 'accuweather',
12
+ infoticker: 'infoticker',
13
+ customGraphics: 'customGraphics',
14
+ ptzCompass: 'ptzCompass',
15
+ images: 'images',
16
+ ptz: 'ptz',
17
+ pip: 'pip',
18
+ screenSharing: 'screenSharing',
19
+ web_camera: 'web_camera',
20
+ };
21
+ const BASE_PATH = '/local/camoverlay/api';
12
22
  class CamOverlayAPI {
13
23
  client;
14
24
  constructor(client) {
15
25
  this.client = client;
16
26
  }
17
- static getProxyUrlPath = () => `${exports.BASE_URL}/proxy.cgi`;
18
- static getFilePreviewPath = (path) => `${exports.BASE_URL}/image.cgi?path=${encodeURIComponent(path)}`;
19
- async checkCameraTime() {
20
- const response = await this._get(`${exports.BASE_URL}/camera_time.cgi`);
27
+ static getBasePath = () => BASE_PATH;
28
+ static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
29
+ static getFilePreviewPath = (path) => `${BASE_PATH}/image.cgi?path=${encodeURIComponent(path)}`;
30
+ async checkCameraTime(options) {
31
+ const response = await this._get({ path: `${BASE_PATH}/camera_time.cgi` }, options);
21
32
  return zod_1.z.boolean().parse(response.state);
22
33
  }
23
- async getNetworkCameraList() {
24
- const response = await this._get(`${exports.BASE_URL}/network_camera_list.cgi`);
34
+ async getNetworkCameraList(options) {
35
+ const response = await this._get({ path: `${BASE_PATH}/network_camera_list.cgi` }, options);
25
36
  return common_1.networkCameraListSchema.parse(response.camera_list);
26
37
  }
27
- async wsAuthorization() {
28
- const responseSchema = zod_1.z.object({
29
- status: zod_1.z.number(),
30
- message: zod_1.z.string(),
31
- data: zod_1.z.string(),
32
- });
33
- const response = await this._get(`${exports.BASE_URL}/ws_authorization.cgi`);
34
- return responseSchema.parse(response).data;
38
+ async wsAuthorization(options) {
39
+ const response = await this._get({ path: `${BASE_PATH}/ws_authorization.cgi` }, options);
40
+ return CamOverlayAPI_1.WSResponseSchema.parse(response).data;
35
41
  }
36
- async getMjpegStreamImage(mjpegUrl) {
37
- return await this._getBlob(`${exports.BASE_URL}/fetch_mjpeg_image.cgi?mjpeg_url=${encodeURIComponent(decodeURIComponent(mjpegUrl))}`);
42
+ async getMjpegStreamImage(mjpegUrl, options) {
43
+ return await this._getBlob({
44
+ path: `${BASE_PATH}/fetch_mjpeg_image.cgi?mjpeg_url=${encodeURIComponent(decodeURIComponent(mjpegUrl))}`,
45
+ }, options);
38
46
  }
39
- async listFiles(fileType) {
40
- const fileDataSchema = zod_1.z.object({
41
- code: zod_1.z.number(),
42
- list: fileSchema_1.fileListSchema,
43
- });
44
- const files = await this._get(`${exports.BASE_URL}/upload_${fileType}.cgi`, {
45
- action: 'list',
46
- });
47
- return fileSchema_1.fileListSchema.parse(files.list);
47
+ async listFiles(fileType, options) {
48
+ const files = await this._get({
49
+ path: `${BASE_PATH}/upload_${fileType}.cgi`,
50
+ parameters: {
51
+ action: 'list',
52
+ },
53
+ }, options);
54
+ return CamOverlayAPI_1.fileListSchema.parse(files.list);
48
55
  }
49
- async uploadFile(fileType, formData, storage) {
50
- const path = `${exports.BASE_URL}/upload_${fileType}.cgi`;
51
- await this._post(path, formData, {
52
- action: 'upload',
53
- storage: storage,
54
- });
56
+ async uploadFile(fileType, formData, storage, options) {
57
+ await this._post({
58
+ path: `${BASE_PATH}/upload_${fileType}.cgi`,
59
+ data: formData,
60
+ parameters: {
61
+ action: 'upload',
62
+ storage: storage,
63
+ },
64
+ }, options);
55
65
  }
56
- async removeFile(fileType, fileParams) {
57
- const path = `${exports.BASE_URL}/upload_${fileType}.cgi`;
66
+ async removeFile(fileType, fileParams, options) {
67
+ const path = `${BASE_PATH}/upload_${fileType}.cgi`;
58
68
  await this._postUrlEncoded(path, {
59
69
  action: 'remove',
60
70
  ...fileParams,
61
- });
71
+ }, undefined, options);
62
72
  }
63
- async getFileStorage(fileType) {
64
- const storageDataListSchema = zod_1.z.array(zod_1.z.object({
65
- type: fileSchema_1.storageSchema,
66
- state: zod_1.z.string(),
67
- }));
68
- const responseSchema = zod_1.z.object({
69
- code: zod_1.z.number(),
70
- list: storageDataListSchema,
71
- });
72
- const data = await this._get(`${exports.BASE_URL}/upload_${fileType}.cgi`, {
73
- action: 'get_storage',
74
- });
73
+ async getFileStorage(fileType, options) {
74
+ const data = await this._get({
75
+ path: `${BASE_PATH}/upload_${fileType}.cgi`,
76
+ parameters: {
77
+ action: 'get_storage',
78
+ },
79
+ }, options);
75
80
  if (data.code !== 200) {
76
81
  throw new Error('Error occured while fetching file storage data');
77
82
  }
78
- return storageDataListSchema.parse(data.list);
83
+ return CamOverlayAPI_1.storageDataListSchema.parse(data.list);
79
84
  }
80
- async getFilePreviewFromCamera(path) {
81
- return await this._getBlob(CamOverlayAPI.getFilePreviewPath(path));
85
+ async getFilePreviewFromCamera(path, options) {
86
+ return await this._getBlob({ path: CamOverlayAPI.getFilePreviewPath(path) }, options);
82
87
  }
83
- async updateInfoticker(serviceID, text) {
84
- await this._get(`${exports.BASE_URL}/infoticker.cgi?service_id=${serviceID}&text=${text}`);
88
+ async updateInfoticker(serviceId, text, options) {
89
+ await this._get({ path: `${BASE_PATH}/infoticker.cgi?service_id=${serviceId}&text=${text}` }, options);
85
90
  }
86
- async setEnabled(serviceID, enabled) {
87
- await this._post(`${exports.BASE_URL}/enabled.cgi?id_${serviceID}=${enabled ? 1 : 0}`, '');
91
+ async setEnabled(serviceId, enabled, options) {
92
+ await this._post({ path: `${BASE_PATH}/enabled.cgi?id_${serviceId}=${enabled ? 1 : 0}`, data: '' }, options);
88
93
  }
89
- async isEnabled(serviceID) {
90
- const res = await this.client.get(`${exports.BASE_URL}/services.cgi?action=get`);
94
+ async isEnabled(serviceId, options) {
95
+ const agent = this.getAgent(options?.proxyParams);
96
+ const res = await agent.get({ path: `${BASE_PATH}/services.cgi?action=get`, timeout: options?.timeout });
91
97
  if (res.ok) {
92
98
  const data = JSON.parse(await res.text());
93
99
  for (const service of data.services) {
94
- if (service.id === serviceID) {
100
+ if (service.id === serviceId) {
95
101
  return service.enabled === 1;
96
102
  }
97
103
  }
@@ -101,40 +107,46 @@ class CamOverlayAPI {
101
107
  throw new Error(await (0, utils_1.responseStringify)(res));
102
108
  }
103
109
  }
104
- async getSingleWidget(serviceId) {
105
- const data = await this._get(`${exports.BASE_URL}/services.cgi`, {
106
- action: 'get',
107
- service_id: serviceId.toString(),
108
- });
109
- return widgetsSchema_1.widgetsSchema.parse(data);
110
+ async getSingleWidget(serviceId, options) {
111
+ const data = await this._get({
112
+ path: `${BASE_PATH}/services.cgi`,
113
+ parameters: {
114
+ action: 'get',
115
+ service_id: serviceId.toString(),
116
+ },
117
+ }, options);
118
+ return CamOverlayAPI_1.widgetsSchema.parse(data);
110
119
  }
111
- async getWidgets() {
112
- const widgetList = await this._get(`${exports.BASE_URL}/services.cgi`, {
113
- action: 'get',
114
- });
120
+ async getWidgets(options) {
121
+ const widgetList = await this._get({
122
+ path: `${BASE_PATH}/services.cgi`,
123
+ parameters: {
124
+ action: 'get',
125
+ },
126
+ }, options);
115
127
  const widgets = widgetList.services;
116
128
  widgets.forEach((widget) => {
117
- const parsedWidget = widgetsSchema_1.widgetsSchema.safeParse(widget);
129
+ const parsedWidget = CamOverlayAPI_1.widgetsSchema.safeParse(widget);
118
130
  if (!parsedWidget.success) {
119
131
  console.warn(`[SERVICE SCHEMA MISMATCH]: Service ${widget.name} (${widget.id}) does not match the current schema, or is a hidden service.`);
120
132
  }
121
133
  });
122
134
  return widgets;
123
135
  }
124
- async updateSingleWidget(widget) {
125
- const path = `${exports.BASE_URL}/services.cgi`;
136
+ async updateSingleWidget(widget, options) {
137
+ const path = `${BASE_PATH}/services.cgi`;
126
138
  await this._postJsonEncoded(path, JSON.stringify(widget), {
127
139
  action: 'set',
128
140
  service_id: widget.id.toString(),
129
- });
141
+ }, undefined, options);
130
142
  }
131
- async updateWidgets(widgets) {
132
- const path = `${exports.BASE_URL}/services.cgi`;
143
+ async updateWidgets(widgets, options) {
144
+ const path = `${BASE_PATH}/services.cgi`;
133
145
  await this._postJsonEncoded(path, JSON.stringify({ services: widgets }), {
134
146
  action: 'set',
135
- });
147
+ }, undefined, options);
136
148
  }
137
- updateCGText(serviceID, fields) {
149
+ updateCGText(serviceId, fields, options) {
138
150
  const params = {};
139
151
  for (const field of fields) {
140
152
  const name = field.field_name;
@@ -143,51 +155,59 @@ class CamOverlayAPI {
143
155
  params[`${name}_color`] = field.color;
144
156
  }
145
157
  }
146
- return this.promiseCGUpdate(serviceID, 'update_text', params);
158
+ return this.promiseCGUpdate(serviceId, 'update_text', params, undefined, undefined, options);
147
159
  }
148
- updateCGImagePos(serviceID, coordinates = '', x = 0, y = 0) {
160
+ updateCGImagePos(serviceId, coordinates = '', x = 0, y = 0, options) {
149
161
  const params = {
150
162
  coord_system: coordinates,
151
163
  pos_x: x,
152
164
  pos_y: y,
153
165
  };
154
- return this.promiseCGUpdate(serviceID, 'update_image', params);
166
+ return this.promiseCGUpdate(serviceId, 'update_image', params, undefined, undefined, options);
155
167
  }
156
- updateCGImage(serviceID, path, coordinates = '', x = 0, y = 0) {
168
+ updateCGImage(serviceId, path, coordinates = '', x = 0, y = 0, options) {
157
169
  const params = {
158
170
  coord_system: coordinates,
159
171
  pos_x: x,
160
172
  pos_y: y,
161
173
  image: path,
162
174
  };
163
- return this.promiseCGUpdate(serviceID, 'update_image', params);
175
+ return this.promiseCGUpdate(serviceId, 'update_image', params, undefined, undefined, options);
164
176
  }
165
- updateCGImageFromData(serviceID, imageType, imageData, coordinates = '', x = 0, y = 0) {
177
+ updateCGImageFromData(serviceId, imageType, imageData, coordinates = '', x = 0, y = 0, options) {
166
178
  const contentType = imageType === CamOverlayAPI_1.ImageType.PNG ? 'image/png' : 'image/jpeg';
167
179
  const params = {
168
180
  coord_system: coordinates,
169
181
  pos_x: x,
170
182
  pos_y: y,
171
183
  };
172
- return this.promiseCGUpdate(serviceID, 'update_image', params, contentType, imageData);
184
+ return this.promiseCGUpdate(serviceId, 'update_image', params, contentType, imageData, options);
173
185
  }
174
- async promiseCGUpdate(serviceID, action, params = {}, contentType, data) {
175
- const path = `${exports.BASE_URL}/customGraphics.cgi`;
186
+ async promiseCGUpdate(serviceId, action, params = {}, contentType, data, options) {
187
+ const path = `${BASE_PATH}/customGraphics.cgi`;
176
188
  let headers = {};
177
189
  if (contentType !== undefined && data) {
178
190
  headers = { 'Content-Type': contentType };
179
191
  }
180
- const res = await this.client.post(path, data ?? '', {
181
- action: action,
182
- service_id: serviceID.toString(),
183
- ...params,
184
- }, headers);
192
+ const agent = this.getAgent(options?.proxyParams);
193
+ const res = await agent.post({
194
+ path,
195
+ data: data ?? '',
196
+ parameters: {
197
+ action: action,
198
+ service_id: serviceId.toString(),
199
+ ...params,
200
+ },
201
+ headers,
202
+ timeout: options?.timeout,
203
+ });
185
204
  if (!res.ok) {
186
205
  throw new Error(await (0, utils_1.responseStringify)(res));
187
206
  }
188
207
  }
189
- async _get(...args) {
190
- const res = await this.client.get(...args);
208
+ async _get(params, options) {
209
+ const agent = this.getAgent(options?.proxyParams);
210
+ const res = await agent.get({ ...params, timeout: options?.timeout });
191
211
  if (res.ok) {
192
212
  return (await res.json());
193
213
  }
@@ -195,8 +215,9 @@ class CamOverlayAPI {
195
215
  throw new Error(await (0, utils_1.responseStringify)(res));
196
216
  }
197
217
  }
198
- async _post(...args) {
199
- const res = await this.client.post(...args);
218
+ async _post(params, options) {
219
+ const agent = this.getAgent(options?.proxyParams);
220
+ const res = await agent.post({ ...params, timeout: options?.timeout });
200
221
  if (res.ok) {
201
222
  return (await res.json());
202
223
  }
@@ -204,8 +225,9 @@ class CamOverlayAPI {
204
225
  throw new Error(await (0, utils_1.responseStringify)(res));
205
226
  }
206
227
  }
207
- async _getBlob(...args) {
208
- const res = await this.client.get(...args);
228
+ async _getBlob(params, options) {
229
+ const agent = this.getAgent(options?.proxyParams);
230
+ const res = await agent.get({ ...params, timeout: options?.timeout });
209
231
  if (res.ok) {
210
232
  return await this.parseBlobResponse(res);
211
233
  }
@@ -221,15 +243,17 @@ class CamOverlayAPI {
221
243
  throw new errors_1.ParsingBlobError(err);
222
244
  }
223
245
  }
224
- async _postUrlEncoded(path, params, headers) {
246
+ async _postUrlEncoded(path, params, headers, options) {
225
247
  const data = (0, utils_1.paramToUrl)(params);
226
248
  const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
227
- return this._post(path, data, {}, { ...baseHeaders, ...headers });
249
+ return this._post({ path, data, headers: { ...baseHeaders, ...headers } }, options);
228
250
  }
229
- async _postJsonEncoded(...args) {
230
- const [path, data, params, headers] = args;
251
+ async _postJsonEncoded(path, data, parameters, headers, options) {
231
252
  const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
232
- return this._post(path, data, params, { ...baseHeaders, ...headers });
253
+ return this._post({ path, data, parameters, headers: { ...baseHeaders, ...headers } }, options);
254
+ }
255
+ getAgent(proxyParams) {
256
+ return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
233
257
  }
234
258
  }
235
259
  exports.CamOverlayAPI = CamOverlayAPI;
@@ -1,53 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
+ /// <reference types="node" />
3
4
  import * as EventEmitter from 'events';
4
- import { WsOptions } from './internal/types';
5
- export type CamOverlayDrawingOptions = WsOptions & {
6
- camera?: number | number[];
7
- zIndex?: number;
8
- };
9
- export type TCairoResponse = {
10
- message: string;
11
- call_id: number;
12
- };
13
- export type TCairoCreateResponse = {
14
- var: string;
15
- call_id: number;
16
- };
17
- export type TUploadImageResponse = {
18
- var: string;
19
- width: number;
20
- height: number;
21
- call_id: number;
22
- };
23
- export type TErrorResponse = {
24
- error: string;
25
- call_id?: number;
26
- };
27
- export type TService = {
28
- id: number;
29
- enabled: number;
30
- schedule: string;
31
- name: string;
32
- identifier: string;
33
- cameraList: number[];
34
- };
35
- export type TServiceList = {
36
- services: TService[];
37
- };
38
- export type TAlign = 'A_RIGHT' | 'A_LEFT' | 'A_CENTER';
39
- export type TextFit = 'TFM_SCALE' | 'TFM_TRUNCATE' | 'TFM_OVERFLOW';
40
- export type TWriteTextParams = [string, string, number, number, number, number, TAlign, TextFit?];
41
- export interface CamOverlayDrawingAPI {
42
- on(event: 'open', listener: () => void): this;
43
- on(event: 'close', listener: () => void): this;
44
- on(event: 'error', listener: (err: Error) => void): this;
45
- on(event: 'message', listener: (msg: string) => void): this;
46
- emit(event: 'open'): boolean;
47
- emit(event: 'close'): boolean;
48
- emit(event: 'error', err: Error): boolean;
49
- emit(event: 'message', msg: string): boolean;
50
- }
5
+ import { CamOverlayDrawingOptions, TCairoCreateResponse, TCairoResponse, TUploadImageResponse, TWriteTextParams } from './types/CamOverlayDrawingAPI';
51
6
  export declare class CamOverlayDrawingAPI extends EventEmitter {
52
7
  private tls;
53
8
  private tlsInsecure;
@@ -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;
@@ -57,6 +57,14 @@ class Frame extends events_1.EventEmitter {
57
57
  this.width = width;
58
58
  this.height = height;
59
59
  }
60
+ getFrameInfo() {
61
+ return {
62
+ x: this.posX,
63
+ y: this.posY,
64
+ width: this.width,
65
+ height: this.height,
66
+ };
67
+ }
60
68
  setText(text, align, textType = 'TFM_OVERFLOW', fontColor) {
61
69
  this.text = text;
62
70
  this.align = align;
@@ -76,6 +84,16 @@ class Frame extends events_1.EventEmitter {
76
84
  this.fontName = undefined;
77
85
  this.font = fontData;
78
86
  }
87
+ getTextInfo() {
88
+ return {
89
+ text: this.text,
90
+ textAlign: this.align,
91
+ textType: this.textType,
92
+ fontColor: this.fontColor,
93
+ font: this.font,
94
+ fontName: this.fontName,
95
+ };
96
+ }
79
97
  setBgColor(color) {
80
98
  this.bgColor = color;
81
99
  }
@@ -92,6 +110,14 @@ class Frame extends events_1.EventEmitter {
92
110
  setBgType(type) {
93
111
  this.bgType = type;
94
112
  }
113
+ getBgInfo() {
114
+ return {
115
+ bgColor: this.bgColor,
116
+ bgImage: this.bgImage,
117
+ bgImageName: this.bgImageName,
118
+ bgType: this.bgType,
119
+ };
120
+ }
95
121
  setBorderRadius(radius) {
96
122
  this.borderRadius = radius;
97
123
  }
@@ -101,6 +127,13 @@ class Frame extends events_1.EventEmitter {
101
127
  setBorderColor(color) {
102
128
  this.borderColor = color;
103
129
  }
130
+ getBorderInfo() {
131
+ return {
132
+ borderRadius: this.borderRadius,
133
+ borderWidth: this.borderWidth,
134
+ borderColor: this.borderColor,
135
+ };
136
+ }
104
137
  setCustomDraw(customDraw) {
105
138
  this.customDraw = customDraw;
106
139
  }
@@ -1,6 +1,8 @@
1
- import { CamOverlayDrawingAPI, CamOverlayDrawingOptions } from '../CamOverlayDrawingAPI';
2
- import ResourceManager from './ResourceManager';
3
- import { Frame, TFrameOptions } from './Frame';
1
+ import { CamOverlayDrawingAPI } from '../CamOverlayDrawingAPI';
2
+ import { CamOverlayDrawingOptions } from '../types/CamOverlayDrawingAPI';
3
+ import { ResourceManager } from './ResourceManager';
4
+ import { Frame } from './Frame';
5
+ import { TCoAlignment, TPainterOptions } from '../types/CamOverlayPainter';
4
6
  export declare const COORD: {
5
7
  readonly top_left: readonly [-1, -1];
6
8
  readonly center_left: readonly [-1, 0];
@@ -12,12 +14,6 @@ export declare const COORD: {
12
14
  readonly center_right: readonly [1, 0];
13
15
  readonly bottom_right: readonly [1, 1];
14
16
  };
15
- type TCoAlignment = keyof typeof COORD;
16
- export type TPainterOptions = TFrameOptions & {
17
- screenWidth: number;
18
- screenHeight: number;
19
- coAlignment: TCoAlignment;
20
- };
21
17
  export declare class Painter extends Frame {
22
18
  private screenWidth;
23
19
  private screenHeight;
@@ -45,4 +41,3 @@ export declare class Painter extends Frame {
45
41
  private cleanupSurface;
46
42
  private positionConvertor;
47
43
  }
48
- export { Frame, TFrameOptions as FrameOptions, ResourceManager, CamOverlayDrawingOptions };
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResourceManager = exports.Frame = exports.Painter = exports.COORD = void 0;
3
+ exports.Painter = exports.COORD = void 0;
4
4
  const CamOverlayDrawingAPI_1 = require("../CamOverlayDrawingAPI");
5
5
  const ResourceManager_1 = require("./ResourceManager");
6
- exports.ResourceManager = ResourceManager_1.default;
7
6
  const Frame_1 = require("./Frame");
8
- Object.defineProperty(exports, "Frame", { enumerable: true, get: function () { return Frame_1.Frame; } });
9
7
  exports.COORD = {
10
8
  top_left: [-1, -1],
11
9
  center_left: [-1, 0],
@@ -31,7 +29,7 @@ class Painter extends Frame_1.Frame {
31
29
  this.screenWidth = opt.screenWidth;
32
30
  this.screenHeight = opt.screenHeight;
33
31
  this.cod = new CamOverlayDrawingAPI_1.CamOverlayDrawingAPI(coopt);
34
- this.rm = new ResourceManager_1.default(this.cod);
32
+ this.rm = new ResourceManager_1.ResourceManager(this.cod);
35
33
  }
36
34
  get camOverlayDrawingAPI() {
37
35
  return this.cod;
@@ -1,5 +1,6 @@
1
- import { CamOverlayDrawingAPI, TUploadImageResponse, TCairoCreateResponse } from '../CamOverlayDrawingAPI';
2
- export default class ResourceManager {
1
+ import { CamOverlayDrawingAPI } from '../CamOverlayDrawingAPI';
2
+ import { TUploadImageResponse, TCairoCreateResponse } from '../types/CamOverlayDrawingAPI';
3
+ export declare class ResourceManager {
3
4
  private co;
4
5
  private imgFileNames;
5
6
  private fontFileNames;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResourceManager = void 0;
3
4
  const fs = require("fs/promises");
4
5
  class ResourceManager {
5
6
  co;
@@ -43,4 +44,4 @@ class ResourceManager {
43
44
  this.fonts = {};
44
45
  }
45
46
  }
46
- exports.default = ResourceManager;
47
+ exports.ResourceManager = ResourceManager;
@@ -1,36 +1,36 @@
1
1
  import { IClient, TResponse } from './internal/types';
2
2
  import { TNodeState, TPackageInfoList, TStorage, TStorageType } from './types/CamScripterAPI';
3
- import { TNetworkCamera } from './types/common';
4
- export declare const BASE_URL = "/local/camscripter";
3
+ import { THttpRequestOptions, TNetworkCamera } from './types/common';
5
4
  export declare class CamScripterAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
6
5
  client: Client;
7
6
  constructor(client: Client);
8
7
  static getProxyUrlPath: () => string;
9
- checkCameraTime(): Promise<boolean>;
10
- getNetworkCameraList(): Promise<TNetworkCamera[]>;
11
- getStorageInfo(): Promise<TStorage>;
12
- getPackageList(): Promise<TPackageInfoList>;
13
- installPackages(formData: FormData, storage: TStorageType): Promise<{
8
+ checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
9
+ getNetworkCameraList(options?: THttpRequestOptions): Promise<TNetworkCamera[]>;
10
+ getStorageInfo(options?: THttpRequestOptions): Promise<TStorage>;
11
+ getPackageList(options?: THttpRequestOptions): Promise<TPackageInfoList>;
12
+ installPackages(formData: FormData, storage: TStorageType, options?: THttpRequestOptions): Promise<{
14
13
  status: number;
15
14
  message: string;
16
15
  }>;
17
- uninstallPackage(packageId: string): Promise<{
16
+ uninstallPackage(packageId: string, options?: THttpRequestOptions): Promise<{
18
17
  status: number;
19
18
  message: string;
20
19
  }>;
21
- importSettings(packageId: string, formData: FormData): Promise<{
20
+ importSettings(packageId: string, formData: FormData, options?: THttpRequestOptions): Promise<{
22
21
  status: number;
23
22
  message: string;
24
23
  }>;
25
- exportSettings(packageId: string, formData: FormData): Promise<{
24
+ exportSettings(packageId: string, formData: FormData, options?: THttpRequestOptions): Promise<{
26
25
  status: number;
27
26
  message: string;
28
27
  }>;
29
- getNodejsStatus(): Promise<TNodeState>;
30
- installNodejs(storage: TStorageType): Promise<{
28
+ getNodejsStatus(options?: THttpRequestOptions): Promise<TNodeState>;
29
+ installNodejs(storage: TStorageType, options?: THttpRequestOptions): Promise<{
31
30
  status: number;
32
31
  message: string;
33
32
  }>;
34
33
  private get;
35
34
  private post;
35
+ private getAgent;
36
36
  }