camstreamerlib 4.0.0-beta.3 → 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 (192) hide show
  1. package/README.md +8 -2
  2. package/cjs/CamOverlayAPI.d.ts +47 -26
  3. package/cjs/CamOverlayAPI.js +171 -88
  4. package/cjs/CamOverlayDrawingAPI.d.ts +2 -47
  5. package/cjs/CamOverlayDrawingAPI.js +6 -3
  6. package/cjs/CamOverlayPainter/Frame.d.ts +8 -37
  7. package/cjs/CamOverlayPainter/Frame.js +33 -0
  8. package/cjs/CamOverlayPainter/Painter.d.ts +16 -10
  9. package/cjs/CamOverlayPainter/Painter.js +6 -5
  10. package/cjs/CamOverlayPainter/ResourceManager.d.ts +3 -2
  11. package/cjs/CamOverlayPainter/ResourceManager.js +8 -11
  12. package/cjs/CamScripterAPI.d.ts +33 -16
  13. package/cjs/CamScripterAPI.js +50 -41
  14. package/cjs/CamScripterAPICameraEventsGenerator.d.ts +1 -1
  15. package/cjs/CamScripterAPICameraEventsGenerator.js +6 -3
  16. package/cjs/CamStreamerAPI.d.ts +16 -14
  17. package/cjs/CamStreamerAPI.js +32 -32
  18. package/cjs/CamSwitcherAPI.d.ts +42 -37
  19. package/cjs/CamSwitcherAPI.js +123 -114
  20. package/cjs/CamSwitcherEvents.d.ts +1 -1
  21. package/cjs/PlaneTrackerAPI.d.ts +42 -0
  22. package/cjs/PlaneTrackerAPI.js +211 -0
  23. package/cjs/VapixAPI.d.ts +56 -43
  24. package/cjs/VapixAPI.js +305 -216
  25. package/cjs/VapixEvents.d.ts +1 -1
  26. package/cjs/VapixEvents.js +3 -3
  27. package/cjs/errors/errors.d.ts +3 -0
  28. package/cjs/errors/errors.js +8 -1
  29. package/cjs/events/AxisCameraStationEvents.d.ts +5 -4
  30. package/cjs/events/AxisCameraStationEvents.js +23 -18
  31. package/cjs/events/GenetecAgent.d.ts +6 -3
  32. package/cjs/events/GenetecAgent.js +30 -19
  33. package/cjs/index.d.ts +14 -1
  34. package/cjs/index.js +23 -2
  35. package/cjs/internal/Digest.js +6 -6
  36. package/cjs/internal/ProxyClient.d.ts +8 -9
  37. package/cjs/internal/ProxyClient.js +25 -29
  38. package/cjs/internal/types.d.ts +42 -0
  39. package/cjs/internal/types.js +2 -0
  40. package/cjs/internal/utils.d.ts +4 -1
  41. package/cjs/internal/utils.js +22 -3
  42. package/cjs/internal/versionCompare.d.ts +2 -2
  43. package/cjs/node/DefaultClient.d.ts +5 -6
  44. package/cjs/node/DefaultClient.js +12 -14
  45. package/cjs/node/HttpRequestSender.d.ts +1 -0
  46. package/cjs/node/HttpRequestSender.js +13 -3
  47. package/cjs/node/HttpServer.js +1 -1
  48. package/cjs/node/WsClient.d.ts +2 -1
  49. package/cjs/node/WsEventClient.d.ts +1 -1
  50. package/cjs/node/index.d.ts +2 -0
  51. package/cjs/node/index.js +18 -1
  52. package/cjs/types/CamOverlayAPI/CamOverlayAPI.d.ts +3073 -0
  53. package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +127 -0
  54. package/cjs/types/CamOverlayAPI/accuweatherSchema.d.ts +114 -0
  55. package/cjs/types/CamOverlayAPI/accuweatherSchema.js +50 -0
  56. package/cjs/types/CamOverlayAPI/customGraphicsSchema.d.ts +783 -0
  57. package/cjs/types/CamOverlayAPI/customGraphicsSchema.js +75 -0
  58. package/cjs/types/CamOverlayAPI/imagesSchema.d.ts +122 -0
  59. package/cjs/types/CamOverlayAPI/imagesSchema.js +12 -0
  60. package/cjs/types/CamOverlayAPI/index.d.ts +9 -0
  61. package/cjs/types/CamOverlayAPI/index.js +25 -0
  62. package/cjs/types/CamOverlayAPI/infotickerSchema.d.ts +130 -0
  63. package/cjs/types/CamOverlayAPI/infotickerSchema.js +29 -0
  64. package/cjs/types/CamOverlayAPI/pipSchema.d.ts +166 -0
  65. package/cjs/types/CamOverlayAPI/pipSchema.js +42 -0
  66. package/cjs/types/CamOverlayAPI/ptzCompassSchema.d.ts +126 -0
  67. package/cjs/types/CamOverlayAPI/ptzCompassSchema.js +28 -0
  68. package/cjs/types/CamOverlayAPI/ptzSchema.d.ts +146 -0
  69. package/cjs/types/CamOverlayAPI/ptzSchema.js +15 -0
  70. package/cjs/types/CamOverlayAPI/screenSharingSchema.d.ts +79 -0
  71. package/cjs/types/CamOverlayAPI/screenSharingSchema.js +11 -0
  72. package/cjs/types/CamOverlayAPI/webCameraSharingSchema.d.ts +79 -0
  73. package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +11 -0
  74. package/cjs/types/CamOverlayDrawingAPI.d.ts +58 -0
  75. package/cjs/types/CamOverlayDrawingAPI.js +2 -0
  76. package/cjs/types/CamOverlayPainter.d.ts +74 -0
  77. package/cjs/types/CamOverlayPainter.js +2 -0
  78. package/cjs/types/CamScripterAPI.d.ts +82 -17
  79. package/cjs/types/CamScripterAPI.js +22 -7
  80. package/cjs/types/CamStreamerAPI.d.ts +16 -5
  81. package/cjs/types/CamStreamerAPI.js +5 -1
  82. package/cjs/types/CamSwitcherAPI.d.ts +5 -5
  83. package/cjs/types/CamSwitcherEvents.d.ts +77 -0
  84. package/cjs/types/CamSwitcherEvents.js +8 -0
  85. package/cjs/types/PlaneTrackerAPI.d.ts +8 -0
  86. package/cjs/types/PlaneTrackerAPI.js +2 -0
  87. package/cjs/types/VapixAPI.d.ts +636 -519
  88. package/cjs/types/VapixAPI.js +62 -24
  89. package/cjs/types/common.d.ts +14 -5
  90. package/cjs/web/DefaultClient.d.ts +5 -5
  91. package/cjs/web/DefaultClient.js +22 -10
  92. package/cjs/web/WsClient.js +2 -2
  93. package/esm/CamOverlayAPI.d.ts +47 -26
  94. package/esm/CamOverlayAPI.js +169 -86
  95. package/esm/CamOverlayDrawingAPI.d.ts +2 -47
  96. package/esm/CamOverlayDrawingAPI.js +6 -3
  97. package/esm/CamOverlayPainter/Frame.d.ts +8 -37
  98. package/esm/CamOverlayPainter/Frame.js +33 -0
  99. package/esm/CamOverlayPainter/Painter.d.ts +16 -10
  100. package/esm/CamOverlayPainter/Painter.js +5 -3
  101. package/esm/CamOverlayPainter/ResourceManager.d.ts +3 -2
  102. package/esm/CamOverlayPainter/ResourceManager.js +7 -11
  103. package/esm/CamScripterAPI.d.ts +33 -16
  104. package/esm/CamScripterAPI.js +46 -37
  105. package/esm/CamScripterAPICameraEventsGenerator.d.ts +1 -1
  106. package/esm/CamScripterAPICameraEventsGenerator.js +6 -3
  107. package/esm/CamStreamerAPI.d.ts +16 -14
  108. package/esm/CamStreamerAPI.js +32 -32
  109. package/esm/CamSwitcherAPI.d.ts +42 -37
  110. package/esm/CamSwitcherAPI.js +116 -107
  111. package/esm/CamSwitcherEvents.d.ts +1 -1
  112. package/esm/PlaneTrackerAPI.d.ts +42 -0
  113. package/esm/PlaneTrackerAPI.js +207 -0
  114. package/esm/VapixAPI.d.ts +56 -43
  115. package/esm/VapixAPI.js +297 -208
  116. package/esm/VapixEvents.d.ts +1 -1
  117. package/esm/VapixEvents.js +3 -3
  118. package/esm/errors/errors.d.ts +3 -0
  119. package/esm/errors/errors.js +6 -0
  120. package/esm/events/AxisCameraStationEvents.d.ts +5 -4
  121. package/esm/events/AxisCameraStationEvents.js +18 -13
  122. package/esm/events/GenetecAgent.d.ts +6 -3
  123. package/esm/events/GenetecAgent.js +20 -9
  124. package/esm/index.d.ts +14 -1
  125. package/esm/index.js +14 -1
  126. package/esm/internal/Digest.js +6 -6
  127. package/esm/internal/ProxyClient.d.ts +8 -9
  128. package/esm/internal/ProxyClient.js +25 -29
  129. package/esm/internal/types.d.ts +42 -0
  130. package/esm/internal/types.js +1 -0
  131. package/esm/internal/utils.d.ts +4 -1
  132. package/esm/internal/utils.js +17 -1
  133. package/esm/internal/versionCompare.d.ts +2 -2
  134. package/esm/node/DefaultClient.d.ts +5 -6
  135. package/esm/node/DefaultClient.js +12 -14
  136. package/esm/node/HttpRequestSender.d.ts +1 -0
  137. package/esm/node/HttpRequestSender.js +13 -3
  138. package/esm/node/HttpServer.js +1 -1
  139. package/esm/node/WsClient.d.ts +2 -1
  140. package/esm/node/WsEventClient.d.ts +1 -1
  141. package/esm/node/index.d.ts +2 -0
  142. package/esm/node/index.js +2 -0
  143. package/esm/types/CamOverlayAPI/CamOverlayAPI.d.ts +3073 -0
  144. package/esm/types/CamOverlayAPI/CamOverlayAPI.js +124 -0
  145. package/esm/types/CamOverlayAPI/accuweatherSchema.d.ts +114 -0
  146. package/esm/types/CamOverlayAPI/accuweatherSchema.js +46 -0
  147. package/esm/types/CamOverlayAPI/customGraphicsSchema.d.ts +783 -0
  148. package/esm/types/CamOverlayAPI/customGraphicsSchema.js +71 -0
  149. package/esm/types/CamOverlayAPI/imagesSchema.d.ts +122 -0
  150. package/esm/types/CamOverlayAPI/imagesSchema.js +8 -0
  151. package/esm/types/CamOverlayAPI/index.d.ts +9 -0
  152. package/esm/types/CamOverlayAPI/index.js +9 -0
  153. package/esm/types/CamOverlayAPI/infotickerSchema.d.ts +130 -0
  154. package/esm/types/CamOverlayAPI/infotickerSchema.js +25 -0
  155. package/esm/types/CamOverlayAPI/pipSchema.d.ts +166 -0
  156. package/esm/types/CamOverlayAPI/pipSchema.js +38 -0
  157. package/esm/types/CamOverlayAPI/ptzCompassSchema.d.ts +126 -0
  158. package/esm/types/CamOverlayAPI/ptzCompassSchema.js +24 -0
  159. package/esm/types/CamOverlayAPI/ptzSchema.d.ts +146 -0
  160. package/esm/types/CamOverlayAPI/ptzSchema.js +11 -0
  161. package/esm/types/CamOverlayAPI/screenSharingSchema.d.ts +79 -0
  162. package/esm/types/CamOverlayAPI/screenSharingSchema.js +7 -0
  163. package/esm/types/CamOverlayAPI/webCameraSharingSchema.d.ts +79 -0
  164. package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +7 -0
  165. package/esm/types/CamOverlayDrawingAPI.d.ts +58 -0
  166. package/esm/types/CamOverlayDrawingAPI.js +1 -0
  167. package/esm/types/CamOverlayPainter.d.ts +74 -0
  168. package/esm/types/CamOverlayPainter.js +1 -0
  169. package/esm/types/CamScripterAPI.d.ts +82 -17
  170. package/esm/types/CamScripterAPI.js +21 -6
  171. package/esm/types/CamStreamerAPI.d.ts +16 -5
  172. package/esm/types/CamStreamerAPI.js +4 -0
  173. package/esm/types/CamSwitcherAPI.d.ts +5 -5
  174. package/esm/types/CamSwitcherEvents.d.ts +77 -0
  175. package/esm/types/CamSwitcherEvents.js +8 -0
  176. package/esm/types/PlaneTrackerAPI.d.ts +8 -0
  177. package/esm/types/PlaneTrackerAPI.js +1 -0
  178. package/esm/types/VapixAPI.d.ts +636 -519
  179. package/esm/types/VapixAPI.js +61 -23
  180. package/esm/types/common.d.ts +14 -5
  181. package/esm/web/DefaultClient.d.ts +5 -5
  182. package/esm/web/DefaultClient.js +22 -10
  183. package/esm/web/WsClient.js +2 -2
  184. package/package.json +9 -8
  185. package/cjs/internal/common.d.ts +0 -39
  186. package/cjs/internal/common.js +0 -27
  187. package/cjs/types/CamOverlayAPI.d.ts +0 -188
  188. package/cjs/types/CamOverlayAPI.js +0 -47
  189. package/esm/internal/common.d.ts +0 -39
  190. package/esm/internal/common.js +0 -20
  191. package/esm/types/CamOverlayAPI.d.ts +0 -188
  192. package/esm/types/CamOverlayAPI.js +0 -44
@@ -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,11 +1,18 @@
1
- import { CamOverlayDrawingAPI, CamOverlayDrawingOptions } from '../CamOverlayDrawingAPI';
2
- import ResourceManager from './ResourceManager';
3
- import { Frame, TFrameOptions } from './Frame';
4
- export declare const COORD: Record<string, [number, number]>;
5
- export type TPainterOptions = TFrameOptions & {
6
- screenWidth: number;
7
- screenHeight: number;
8
- coAlignment: string;
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';
6
+ export declare const COORD: {
7
+ readonly top_left: readonly [-1, -1];
8
+ readonly center_left: readonly [-1, 0];
9
+ readonly bottom_left: readonly [-1, 1];
10
+ readonly top_center: readonly [0, -1];
11
+ readonly center: readonly [0, 0];
12
+ readonly bottom_center: readonly [0, 1];
13
+ readonly top_right: readonly [1, -1];
14
+ readonly center_right: readonly [1, 0];
15
+ readonly bottom_right: readonly [1, 1];
9
16
  };
10
17
  export declare class Painter extends Frame {
11
18
  private screenWidth;
@@ -24,7 +31,7 @@ export declare class Painter extends Frame {
24
31
  registerImage(moniker: string, fileName: string): void;
25
32
  registerFont(moniker: string, fileName: string): void;
26
33
  setScreenSize(sw: number, sh: number): void;
27
- setCoAlignment(coAlignment: string): void;
34
+ setCoAlignment(coAlignment: TCoAlignment): void;
28
35
  protected layoutChanged(): void;
29
36
  display(scale?: number): Promise<void>;
30
37
  hide(): Promise<void>;
@@ -34,4 +41,3 @@ export declare class Painter extends Frame {
34
41
  private cleanupSurface;
35
42
  private positionConvertor;
36
43
  }
37
- 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;
@@ -87,6 +85,9 @@ class Painter extends Frame_1.Frame {
87
85
  let lastCachedLayer;
88
86
  for (let i = 0; i < this.layers.length; i++) {
89
87
  const layer = this.layers[i];
88
+ if (layer === undefined) {
89
+ continue;
90
+ }
90
91
  if (layer.cairoCache !== undefined &&
91
92
  layer.surfaceCache !== undefined &&
92
93
  surface === undefined &&
@@ -120,7 +121,7 @@ class Painter extends Frame_1.Frame {
120
121
  }
121
122
  for (let i = layerIdx; i < this.layers.length; i++) {
122
123
  const currentLayer = this.layers[i];
123
- if (currentLayer.surfaceCache !== undefined && currentLayer.cairoCache !== undefined) {
124
+ if (currentLayer?.surfaceCache !== undefined && currentLayer.cairoCache !== undefined) {
124
125
  await this.cleanupSurface(currentLayer.surfaceCache, currentLayer.cairoCache);
125
126
  currentLayer.surfaceCache = undefined;
126
127
  currentLayer.cairoCache = undefined;
@@ -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;
@@ -17,34 +18,30 @@ class ResourceManager {
17
18
  this.fontFileNames[moniker] = process.env.INSTALL_PATH + '/fonts/' + fileName;
18
19
  }
19
20
  async image(moniker) {
20
- if (moniker in this.images) {
21
+ if (this.images[moniker] !== undefined) {
21
22
  return this.images[moniker];
22
23
  }
23
- else if (moniker in this.imgFileNames) {
24
+ if (this.imgFileNames[moniker] !== undefined) {
24
25
  const imgData = await fs.readFile(this.imgFileNames[moniker]);
25
26
  this.images[moniker] = await this.co.uploadImageData(imgData);
26
27
  return this.images[moniker];
27
28
  }
28
- else {
29
- throw new Error('Error! Unknown image requested!');
30
- }
29
+ throw new Error('Error! Unknown image requested!');
31
30
  }
32
31
  async font(moniker) {
33
- if (moniker in this.fonts) {
32
+ if (this.fonts[moniker] !== undefined) {
34
33
  return this.fonts[moniker];
35
34
  }
36
- else if (moniker in this.fontFileNames) {
35
+ if (this.fontFileNames[moniker] !== undefined) {
37
36
  const fontData = await fs.readFile(this.fontFileNames[moniker]);
38
37
  this.fonts[moniker] = await this.co.uploadFontData(fontData);
39
38
  return this.fonts[moniker];
40
39
  }
41
- else {
42
- throw new Error('Error! Unknown font requested!');
43
- }
40
+ throw new Error('Error! Unknown font requested!');
44
41
  }
45
42
  clear() {
46
43
  this.images = {};
47
44
  this.fonts = {};
48
45
  }
49
46
  }
50
- exports.default = ResourceManager;
47
+ exports.ResourceManager = ResourceManager;
@@ -1,19 +1,36 @@
1
- import { IClient } from './internal/common';
2
- import { CamScripterOptions, TNodeState, TPackageInfoList, TStorage, TStorageType } from './types/CamScripterAPI';
3
- import { TNetworkCamera } from './types/common';
4
- export declare class CamOverlayAPI {
5
- private client;
6
- constructor(options?: CamScripterOptions | IClient);
7
- checkCameraTime(): Promise<boolean>;
8
- getStorageInfo(): Promise<TStorage>;
9
- getNetworkCameraList(): Promise<TNetworkCamera[]>;
10
- getPackageList(): Promise<TPackageInfoList>;
11
- installPackages(formData: FormData, storage: TStorageType): Promise<void>;
12
- uninstallPackage(packageId: string): Promise<void>;
13
- importSettings(packageId: string, formData: FormData): Promise<void>;
14
- exportSettings(packageId: string, formData: FormData): Promise<void>;
15
- getNodejsStatus(): Promise<TNodeState>;
16
- installNodejs(storage: TStorageType): Promise<void>;
1
+ import { IClient, TResponse } from './internal/types';
2
+ import { TNodeState, TPackageInfoList, TStorage, TStorageType } from './types/CamScripterAPI';
3
+ import { THttpRequestOptions, TNetworkCamera } from './types/common';
4
+ export declare class CamScripterAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
5
+ client: Client;
6
+ constructor(client: Client);
7
+ static getProxyUrlPath: () => string;
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<{
13
+ status: number;
14
+ message: string;
15
+ }>;
16
+ uninstallPackage(packageId: string, options?: THttpRequestOptions): Promise<{
17
+ status: number;
18
+ message: string;
19
+ }>;
20
+ importSettings(packageId: string, formData: FormData, options?: THttpRequestOptions): Promise<{
21
+ status: number;
22
+ message: string;
23
+ }>;
24
+ exportSettings(packageId: string, formData: FormData, options?: THttpRequestOptions): Promise<{
25
+ status: number;
26
+ message: string;
27
+ }>;
28
+ getNodejsStatus(options?: THttpRequestOptions): Promise<TNodeState>;
29
+ installNodejs(storage: TStorageType, options?: THttpRequestOptions): Promise<{
30
+ status: number;
31
+ message: string;
32
+ }>;
17
33
  private get;
18
34
  private post;
35
+ private getAgent;
19
36
  }
@@ -1,70 +1,79 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CamOverlayAPI = void 0;
4
- const common_1 = require("./internal/common");
5
- const DefaultClient_1 = require("./node/DefaultClient");
3
+ exports.CamScripterAPI = void 0;
4
+ const ProxyClient_1 = require("./internal/ProxyClient");
5
+ const utils_1 = require("./internal/utils");
6
6
  const CamScripterAPI_1 = require("./types/CamScripterAPI");
7
- const common_2 = require("./types/common");
8
- class CamOverlayAPI {
7
+ const common_1 = require("./types/common");
8
+ const BASE_PATH = '/local/camscripter';
9
+ class CamScripterAPI {
9
10
  client;
10
- constructor(options = {}) {
11
- if ((0, common_1.isClient)(options)) {
12
- this.client = options;
13
- }
14
- else {
15
- this.client = new DefaultClient_1.DefaultClient(options);
16
- }
11
+ constructor(client) {
12
+ this.client = client;
17
13
  }
18
- async checkCameraTime() {
19
- return (await this.get('/local/camscripter/camera_time.cgi')).state;
14
+ static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
15
+ async checkCameraTime(options) {
16
+ const data = await this.get(`${BASE_PATH}/camera_time.cgi`, undefined, options);
17
+ return CamScripterAPI_1.cameraTimeResponseSchema.parse(data).state;
20
18
  }
21
- async getStorageInfo() {
22
- const data = await this.get(`/local/camscripter/package/get_storage.cgi`);
23
- return CamScripterAPI_1.storageSchema.parse(data);
19
+ async getNetworkCameraList(options) {
20
+ const data = await this.get(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
21
+ return common_1.networkCameraListSchema.parse(data.camera_list);
24
22
  }
25
- async getNetworkCameraList() {
26
- const response = await this.get('/local/camscripter/network_camera_list.cgi');
27
- return common_2.networkCameraListSchema.parse(response.camera_list);
23
+ async getStorageInfo(options) {
24
+ const data = await this.get(`${BASE_PATH}/package/get_storage.cgi`, undefined, options);
25
+ return CamScripterAPI_1.storageSchema.parse(data);
28
26
  }
29
- async getPackageList() {
30
- const data = await this.get('/local/camscripter/package/list.cgi');
27
+ async getPackageList(options) {
28
+ const data = await this.get(`${BASE_PATH}/package/list.cgi`, undefined, options);
31
29
  return CamScripterAPI_1.packageInfoListSchema.parse(data);
32
30
  }
33
- async installPackages(formData, storage) {
34
- await this.post(`/local/camscripter/package/install.cgi?storage=${storage}`, formData);
31
+ async installPackages(formData, storage, options) {
32
+ const data = await this.post(`${BASE_PATH}/package/install.cgi?storage=${storage}`, formData, undefined, options);
33
+ return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
35
34
  }
36
- async uninstallPackage(packageId) {
37
- await this.get(`/local/camscripter/package/remove.cgi?package_name=${packageId}`);
35
+ async uninstallPackage(packageId, options) {
36
+ const data = await this.get(`${BASE_PATH}/package/remove.cgi?package_name=${packageId}`, undefined, options);
37
+ return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
38
38
  }
39
- async importSettings(packageId, formData) {
40
- await this.post(`/local/camscripter/package/data.cgi?action=IMPORT&package_name=${packageId}`, formData);
39
+ async importSettings(packageId, formData, options) {
40
+ const data = await this.post(`${BASE_PATH}/package/data.cgi?action=IMPORT&package_name=${packageId}`, formData, undefined, options);
41
+ return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
41
42
  }
42
- async exportSettings(packageId, formData) {
43
- await this.post(`/local/camscripter/package/data.cgi?action=EXPORT&package_name=${packageId}`, formData);
43
+ async exportSettings(packageId, formData, options) {
44
+ const data = await this.post(`${BASE_PATH}/package/data.cgi?action=EXPORT&package_name=${packageId}`, formData, undefined, options);
45
+ return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
44
46
  }
45
- async getNodejsStatus() {
46
- return (await this.get('/local/camscripter/diagnostics.cgi')).node_state;
47
+ async getNodejsStatus(options) {
48
+ const data = await this.get(`${BASE_PATH}/diagnostics.cgi`, undefined, options);
49
+ return CamScripterAPI_1.nodeStateSchema.parse(data);
47
50
  }
48
- async installNodejs(storage) {
49
- await this.get(`/local/camscripter/node_update.cgi?storage=${storage}`);
51
+ async installNodejs(storage, options) {
52
+ const data = await this.get(`${BASE_PATH}/node_update.cgi?storage=${storage}`, undefined, options);
53
+ return CamScripterAPI_1.camscripterApiResponseSchema.parse(data);
50
54
  }
51
- async get(path, params) {
52
- const res = await this.client.get(path, params);
55
+ async get(path, parameters, options) {
56
+ const agent = this.getAgent(options?.proxyParams);
57
+ const res = await agent.get({ path, parameters, timeout: options?.timeout });
53
58
  if (res.ok) {
54
59
  return await res.json();
55
60
  }
56
61
  else {
57
- throw new Error(await (0, common_1.responseStringify)(res));
62
+ throw new Error(await (0, utils_1.responseStringify)(res));
58
63
  }
59
64
  }
60
- async post(path, data, params) {
61
- const res = await this.client.post(path, data, params);
65
+ async post(path, data, parameters, options) {
66
+ const agent = this.getAgent(options?.proxyParams);
67
+ const res = await agent.post({ path, data, parameters, timeout: options?.timeout });
62
68
  if (res.ok) {
63
69
  return await res.json();
64
70
  }
65
71
  else {
66
- throw new Error(await (0, common_1.responseStringify)(res));
72
+ throw new Error(await (0, utils_1.responseStringify)(res));
67
73
  }
68
74
  }
75
+ getAgent(proxyParams) {
76
+ return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
77
+ }
69
78
  }
70
- exports.CamOverlayAPI = CamOverlayAPI;
79
+ exports.CamScripterAPI = CamScripterAPI;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import * as EventEmitter from 'events';
3
- import { WsOptions } from './internal/common';
3
+ import { WsOptions } from './internal/types';
4
4
  export type CamScripterOptions = WsOptions;
5
5
  export type TDeclaration = {
6
6
  type?: '' | 'SOURCE' | 'DATA';
@@ -91,10 +91,10 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
91
91
  }
92
92
  if (dataJSON.call_id !== undefined) {
93
93
  if (errorResponse !== undefined) {
94
- this.sendMessages[dataJSON.call_id].reject(new Error(errorResponse.error));
94
+ this.sendMessages[dataJSON.call_id]?.reject(new Error(errorResponse.error));
95
95
  }
96
96
  else {
97
- this.sendMessages[dataJSON.call_id].resolve(dataJSON);
97
+ this.sendMessages[dataJSON.call_id]?.resolve(dataJSON);
98
98
  }
99
99
  delete this.sendMessages[dataJSON.call_id];
100
100
  }
@@ -127,6 +127,9 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
127
127
  const now = Date.now();
128
128
  for (const callId in this.sendMessages) {
129
129
  const msg = this.sendMessages[callId];
130
+ if (!msg) {
131
+ continue;
132
+ }
130
133
  if (now - msg.sentTimestamp > 10000) {
131
134
  reconnect = true;
132
135
  msg.reject(new Error('Message timeout'));
@@ -150,7 +153,7 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
150
153
  }
151
154
  reportClose() {
152
155
  for (const callId in this.sendMessages) {
153
- this.sendMessages[callId].reject(new Error('Connection lost'));
156
+ this.sendMessages[callId]?.reject(new Error('Connection lost'));
154
157
  }
155
158
  this.sendMessages = {};
156
159
  this.emit('close');
@@ -1,16 +1,18 @@
1
- import { IClient } from './internal/common';
2
- import { CamStreamerAPIOptions, TStreamAttributes, TStreamList } from './types/CamStreamerAPI';
3
- export declare class CamStreamerAPI {
4
- private client;
5
- constructor(options?: CamStreamerAPIOptions | IClient);
6
- getStreamList(): Promise<TStreamList>;
7
- getStream(streamID: string): Promise<TStreamAttributes>;
8
- getStreamParameter(streamID: string, paramName: string): Promise<string>;
9
- setStream(streamID: string, params: Partial<TStreamAttributes>): Promise<void>;
10
- setStreamParameter(streamID: string, paramName: string, value: string): Promise<void>;
11
- isStreaming(streamID: string): Promise<boolean>;
12
- deleteStream(streamID: string): Promise<void>;
13
- wsAutoratization(): Promise<string>;
14
- getUtcTime(): Promise<number>;
1
+ import { IClient, TResponse } from './internal/types';
2
+ import { TStreamAttributes, TStreamList } from './types/CamStreamerAPI';
3
+ import { THttpRequestOptions } from './types/common';
4
+ export declare class CamStreamerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
5
+ client: Client;
6
+ constructor(client: Client);
7
+ getStreamList(options?: THttpRequestOptions): Promise<TStreamList>;
8
+ getStream(streamId: string, options?: THttpRequestOptions): Promise<TStreamAttributes>;
9
+ getStreamParameter(streamId: string, paramName: string, options?: THttpRequestOptions): Promise<string>;
10
+ setStream(streamId: string, params: Partial<TStreamAttributes>, options?: THttpRequestOptions): Promise<void>;
11
+ setStreamParameter(streamId: string, paramName: string, value: string, options?: THttpRequestOptions): Promise<void>;
12
+ isStreaming(streamId: string, options?: THttpRequestOptions): Promise<boolean>;
13
+ deleteStream(streamId: string, options?: THttpRequestOptions): Promise<void>;
14
+ wsAuthorization(options?: THttpRequestOptions): Promise<string>;
15
+ getUtcTime(options?: THttpRequestOptions): Promise<number>;
15
16
  private get;
17
+ private getAgent;
16
18
  }
@@ -1,65 +1,65 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CamStreamerAPI = void 0;
4
- const common_1 = require("./internal/common");
5
- const DefaultClient_1 = require("./node/DefaultClient");
4
+ const ProxyClient_1 = require("./internal/ProxyClient");
5
+ const utils_1 = require("./internal/utils");
6
6
  const CamStreamerAPI_1 = require("./types/CamStreamerAPI");
7
+ const BASE_PATH = '/local/camstreamer';
7
8
  class CamStreamerAPI {
8
9
  client;
9
- constructor(options = {}) {
10
- if ((0, common_1.isClient)(options)) {
11
- this.client = options;
12
- }
13
- else {
14
- this.client = new DefaultClient_1.DefaultClient(options);
15
- }
10
+ constructor(client) {
11
+ this.client = client;
16
12
  }
17
- async getStreamList() {
18
- const streamListRes = await this.get('/local/camstreamer/stream/list.cgi');
13
+ async getStreamList(options) {
14
+ const streamListRes = await this.get(`${BASE_PATH}/stream/list.cgi`, undefined, options);
19
15
  return CamStreamerAPI_1.streamListSchema.parse(streamListRes.data);
20
16
  }
21
- async getStream(streamID) {
22
- const stream = await this.get(`/local/camstreamer/stream/get.cgi?stream_id=${streamID}`);
17
+ async getStream(streamId, options) {
18
+ const stream = await this.get(`${BASE_PATH}/stream/get.cgi?stream_id=${streamId}`, undefined, options);
23
19
  return CamStreamerAPI_1.streamAttributesSchema.parse(stream.data);
24
20
  }
25
- async getStreamParameter(streamID, paramName) {
26
- const stream = await this.get(`/local/camstreamer/stream/get.cgi?stream_id=${streamID}`);
21
+ async getStreamParameter(streamId, paramName, options) {
22
+ const stream = await this.get(`${BASE_PATH}/stream/get.cgi?stream_id=${streamId}`, undefined, options);
27
23
  return stream.data[paramName];
28
24
  }
29
- async setStream(streamID, params) {
25
+ async setStream(streamId, params, options) {
30
26
  const { streamDelay, startTime, stopTime, ...rest } = params;
31
- await this.get('/local/camstreamer/stream/set.cgi', {
32
- stream_id: streamID,
27
+ await this.get(`${BASE_PATH}/stream/set.cgi`, {
28
+ stream_id: streamId,
33
29
  streamDelay: streamDelay ?? '',
34
30
  startTime: startTime ?? 'null',
35
31
  stopTime: stopTime ?? 'null',
36
32
  ...rest,
37
- });
33
+ }, options);
38
34
  }
39
- async setStreamParameter(streamID, paramName, value) {
40
- await this.get(`/local/camstreamer/stream/set.cgi?stream_id=${streamID}&${paramName}=${value}`);
35
+ async setStreamParameter(streamId, paramName, value, options) {
36
+ await this.get(`${BASE_PATH}/stream/set.cgi?stream_id=${streamId}&${paramName}=${value}`, undefined, options);
41
37
  }
42
- async isStreaming(streamID) {
43
- const response = await this.get(`/local/camstreamer/get_streamstat.cgi?stream_id=${streamID}`);
38
+ async isStreaming(streamId, options) {
39
+ const response = await this.get(`${BASE_PATH}/get_streamstat.cgi?stream_id=${streamId}`, undefined, options);
44
40
  return response.data.is_streaming === 1;
45
41
  }
46
- async deleteStream(streamID) {
47
- await this.get('/local/camstreamer/stream/remove.cgi', { stream_id: streamID });
42
+ async deleteStream(streamId, options) {
43
+ await this.get(`${BASE_PATH}/stream/remove.cgi`, { stream_id: streamId }, options);
48
44
  }
49
- wsAutoratization() {
50
- return this.get('/local/camstreamer/ws_authorization.cgi');
45
+ wsAuthorization(options) {
46
+ return this.get(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
51
47
  }
52
- async getUtcTime() {
53
- return await this.get('/local/camstreamer/get_utc_time.cgi');
48
+ async getUtcTime(options) {
49
+ return await this.get(`${BASE_PATH}/get_utc_time.cgi`, undefined, options);
54
50
  }
55
- async get(path, parameters) {
56
- const res = await this.client.get(path, parameters);
51
+ async get(path, parameters, options) {
52
+ const agent = this.getAgent(options?.proxyParams);
53
+ const res = await agent.get({ path, parameters, timeout: options?.timeout });
57
54
  if (res.ok) {
58
55
  return await res.json();
59
56
  }
60
57
  else {
61
- throw new Error(await (0, common_1.responseStringify)(res));
58
+ throw new Error(await (0, utils_1.responseStringify)(res));
62
59
  }
63
60
  }
61
+ getAgent(proxyParams) {
62
+ return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
63
+ }
64
64
  }
65
65
  exports.CamStreamerAPI = CamStreamerAPI;