node-hp-scan-to 1.3.1 → 1.4.1

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 (211) hide show
  1. package/README.md +76 -15
  2. package/dist/Destination.js.map +1 -1
  3. package/dist/DeviceCapabilities.d.ts +4 -0
  4. package/dist/DeviceCapabilities.js.map +1 -1
  5. package/dist/DiscoveryTree.js.map +1 -1
  6. package/dist/Event.js +2 -2
  7. package/dist/Event.js.map +1 -1
  8. package/dist/EventTable.js.map +1 -1
  9. package/dist/HPApi.js.map +1 -1
  10. package/dist/InputSource.d.ts +4 -0
  11. package/dist/InputSource.js +9 -0
  12. package/dist/InputSource.js.map +1 -0
  13. package/dist/Job.d.ts +2 -0
  14. package/dist/Job.js +2 -2
  15. package/dist/Job.js.map +1 -1
  16. package/dist/JpegUtil.js +1 -1
  17. package/dist/JpegUtil.js.map +1 -1
  18. package/dist/PathHelper.d.ts +4 -3
  19. package/dist/PathHelper.js +28 -13
  20. package/dist/PathHelper.js.map +1 -1
  21. package/dist/ScanCaps.d.ts +18 -0
  22. package/dist/ScanCaps.js +22 -0
  23. package/dist/ScanCaps.js.map +1 -1
  24. package/dist/ScanContent.js.map +1 -1
  25. package/dist/ScanJobManifest.js.map +1 -1
  26. package/dist/ScanJobSettings.d.ts +4 -1
  27. package/dist/ScanJobSettings.js +19 -8
  28. package/dist/ScanJobSettings.js.map +1 -1
  29. package/dist/ScanStatus.d.ts +2 -1
  30. package/dist/ScanStatus.js +3 -2
  31. package/dist/ScanStatus.js.map +1 -1
  32. package/dist/WalkupScanDestination.js +2 -2
  33. package/dist/WalkupScanDestination.js.map +1 -1
  34. package/dist/WalkupScanDestinations.js +1 -1
  35. package/dist/WalkupScanDestinations.js.map +1 -1
  36. package/dist/WalkupScanManifest.js.map +1 -1
  37. package/dist/WalkupScanToCompCaps.js.map +1 -1
  38. package/dist/WalkupScanToCompDestination.js +2 -2
  39. package/dist/WalkupScanToCompDestination.js.map +1 -1
  40. package/dist/WalkupScanToCompDestinations.js +1 -1
  41. package/dist/WalkupScanToCompDestinations.js.map +1 -1
  42. package/dist/WalkupScanToCompEvent.js.map +1 -1
  43. package/dist/WalkupScanToCompManifest.js.map +1 -1
  44. package/dist/index.js +26 -5
  45. package/dist/index.js.map +1 -1
  46. package/dist/listening.js.map +1 -1
  47. package/dist/readDeviceCapabilities.js +6 -1
  48. package/dist/readDeviceCapabilities.js.map +1 -1
  49. package/dist/scanProcessing.d.ts +6 -1
  50. package/dist/scanProcessing.js +61 -21
  51. package/dist/scanProcessing.js.map +1 -1
  52. package/dist/test/JpegUtil.test.js +10 -8
  53. package/dist/test/JpegUtil.test.js.map +1 -1
  54. package/dist/test/PathHelper.test.js +10 -11
  55. package/dist/test/PathHelper.test.js.map +1 -1
  56. package/dist/test/ScanCaps.test.d.ts +1 -0
  57. package/dist/test/ScanCaps.test.js +76 -0
  58. package/dist/test/ScanCaps.test.js.map +1 -0
  59. package/dist/test/ScanJobSettings.test.js +9 -3
  60. package/dist/test/ScanJobSettings.test.js.map +1 -1
  61. package/dist/test/scanProcessing.test.d.ts +1 -0
  62. package/dist/test/scanProcessing.test.js +103 -0
  63. package/dist/test/scanProcessing.test.js.map +1 -0
  64. package/package.json +7 -7
  65. package/src/Destination.ts +1 -1
  66. package/src/DeviceCapabilities.ts +4 -0
  67. package/src/DiscoveryTree.ts +1 -1
  68. package/src/Event.ts +4 -4
  69. package/src/EventTable.ts +1 -1
  70. package/src/HPApi.ts +19 -19
  71. package/src/InputSource.ts +4 -0
  72. package/src/Job.ts +19 -7
  73. package/src/JpegUtil.ts +18 -14
  74. package/src/PathHelper.ts +48 -20
  75. package/src/ScanCaps.ts +53 -1
  76. package/src/ScanContent.ts +1 -1
  77. package/src/ScanJobManifest.ts +3 -2
  78. package/src/ScanJobSettings.ts +23 -9
  79. package/src/ScanStatus.ts +6 -3
  80. package/src/WalkupScanDestination.ts +9 -5
  81. package/src/WalkupScanDestinations.ts +9 -4
  82. package/src/WalkupScanManifest.ts +3 -3
  83. package/src/WalkupScanToCompCaps.ts +2 -2
  84. package/src/WalkupScanToCompDestination.ts +15 -5
  85. package/src/WalkupScanToCompDestinations.ts +5 -4
  86. package/src/WalkupScanToCompEvent.ts +1 -1
  87. package/src/WalkupScanToCompManifest.ts +3 -3
  88. package/src/index.ts +90 -33
  89. package/src/listening.ts +14 -15
  90. package/src/readDeviceCapabilities.ts +12 -6
  91. package/src/scanProcessing.ts +129 -52
  92. package/dist/fixJpegSize.d.ts +0 -19
  93. package/dist/fixJpegSize.js +0 -292
  94. package/dist/fixJpegSize.js.map +0 -1
  95. package/dist/models/Destination.d.ts +0 -8
  96. package/dist/models/Destination.js +0 -68
  97. package/dist/models/Destination.js.map +0 -1
  98. package/dist/models/DiscoveryTree.d.ts +0 -16
  99. package/dist/models/DiscoveryTree.js +0 -38
  100. package/dist/models/DiscoveryTree.js.map +0 -1
  101. package/dist/models/Event.d.ts +0 -21
  102. package/dist/models/Event.js +0 -32
  103. package/dist/models/Event.js.map +0 -1
  104. package/dist/models/EventTable.d.ts +0 -16
  105. package/dist/models/EventTable.js +0 -33
  106. package/dist/models/EventTable.js.map +0 -1
  107. package/dist/models/Job.d.ts +0 -37
  108. package/dist/models/Job.js +0 -78
  109. package/dist/models/Job.js.map +0 -1
  110. package/dist/models/ScanCaps.d.ts +0 -7
  111. package/dist/models/ScanCaps.js +0 -17
  112. package/dist/models/ScanCaps.js.map +0 -1
  113. package/dist/models/ScanJobManifest.d.ts +0 -23
  114. package/dist/models/ScanJobManifest.js +0 -24
  115. package/dist/models/ScanJobManifest.js.map +0 -1
  116. package/dist/models/ScanJobSettings.d.ts +0 -8
  117. package/dist/models/ScanJobSettings.js +0 -56
  118. package/dist/models/ScanJobSettings.js.map +0 -1
  119. package/dist/models/WalkupScanDestination.d.ts +0 -22
  120. package/dist/models/WalkupScanDestination.js +0 -38
  121. package/dist/models/WalkupScanDestination.js.map +0 -1
  122. package/dist/models/WalkupScanDestinations.d.ts +0 -12
  123. package/dist/models/WalkupScanDestinations.js +0 -30
  124. package/dist/models/WalkupScanDestinations.js.map +0 -1
  125. package/dist/models/WalkupScanManifest.d.ts +0 -23
  126. package/dist/models/WalkupScanManifest.js +0 -25
  127. package/dist/models/WalkupScanManifest.js.map +0 -1
  128. package/dist/models/WalkupScanToCompCaps.d.ts +0 -12
  129. package/dist/models/WalkupScanToCompCaps.js +0 -20
  130. package/dist/models/WalkupScanToCompCaps.js.map +0 -1
  131. package/dist/models/WalkupScanToCompDestination.d.ts +0 -22
  132. package/dist/models/WalkupScanToCompDestination.js +0 -38
  133. package/dist/models/WalkupScanToCompDestination.js.map +0 -1
  134. package/dist/models/WalkupScanToCompDestinations.d.ts +0 -12
  135. package/dist/models/WalkupScanToCompDestinations.js +0 -30
  136. package/dist/models/WalkupScanToCompDestinations.js.map +0 -1
  137. package/dist/models/WalkupScanToCompEvent.d.ts +0 -11
  138. package/dist/models/WalkupScanToCompEvent.js +0 -20
  139. package/dist/models/WalkupScanToCompEvent.js.map +0 -1
  140. package/dist/models/WalkupScanToCompManifest.d.ts +0 -23
  141. package/dist/models/WalkupScanToCompManifest.js +0 -25
  142. package/dist/models/WalkupScanToCompManifest.js.map +0 -1
  143. package/dist/scanProcess.d.ts +0 -19
  144. package/dist/scanProcess.js +0 -292
  145. package/dist/scanProcess.js.map +0 -1
  146. package/dist/src/Destination.d.ts +0 -8
  147. package/dist/src/Destination.js +0 -68
  148. package/dist/src/Destination.js.map +0 -1
  149. package/dist/src/DiscoveryTree.d.ts +0 -16
  150. package/dist/src/DiscoveryTree.js +0 -38
  151. package/dist/src/DiscoveryTree.js.map +0 -1
  152. package/dist/src/Event.d.ts +0 -21
  153. package/dist/src/Event.js +0 -32
  154. package/dist/src/Event.js.map +0 -1
  155. package/dist/src/EventTable.d.ts +0 -16
  156. package/dist/src/EventTable.js +0 -33
  157. package/dist/src/EventTable.js.map +0 -1
  158. package/dist/src/HPApi.d.ts +0 -50
  159. package/dist/src/HPApi.js +0 -454
  160. package/dist/src/HPApi.js.map +0 -1
  161. package/dist/src/Job.d.ts +0 -37
  162. package/dist/src/Job.js +0 -78
  163. package/dist/src/Job.js.map +0 -1
  164. package/dist/src/JpegUtil.d.ts +0 -26
  165. package/dist/src/JpegUtil.js +0 -229
  166. package/dist/src/JpegUtil.js.map +0 -1
  167. package/dist/src/KnownShortcut.d.ts +0 -1
  168. package/dist/src/KnownShortcut.js +0 -3
  169. package/dist/src/KnownShortcut.js.map +0 -1
  170. package/dist/src/PathHelper.d.ts +0 -6
  171. package/dist/src/PathHelper.js +0 -52
  172. package/dist/src/PathHelper.js.map +0 -1
  173. package/dist/src/ScanCaps.d.ts +0 -7
  174. package/dist/src/ScanCaps.js +0 -17
  175. package/dist/src/ScanCaps.js.map +0 -1
  176. package/dist/src/ScanJobManifest.d.ts +0 -23
  177. package/dist/src/ScanJobManifest.js +0 -24
  178. package/dist/src/ScanJobManifest.js.map +0 -1
  179. package/dist/src/ScanJobSettings.d.ts +0 -8
  180. package/dist/src/ScanJobSettings.js +0 -56
  181. package/dist/src/ScanJobSettings.js.map +0 -1
  182. package/dist/src/ScanStatus.d.ts +0 -19
  183. package/dist/src/ScanStatus.js +0 -35
  184. package/dist/src/ScanStatus.js.map +0 -1
  185. package/dist/src/WalkupScanDestination.d.ts +0 -22
  186. package/dist/src/WalkupScanDestination.js +0 -38
  187. package/dist/src/WalkupScanDestination.js.map +0 -1
  188. package/dist/src/WalkupScanDestinations.d.ts +0 -12
  189. package/dist/src/WalkupScanDestinations.js +0 -30
  190. package/dist/src/WalkupScanDestinations.js.map +0 -1
  191. package/dist/src/WalkupScanManifest.d.ts +0 -23
  192. package/dist/src/WalkupScanManifest.js +0 -25
  193. package/dist/src/WalkupScanManifest.js.map +0 -1
  194. package/dist/src/WalkupScanToCompCaps.d.ts +0 -12
  195. package/dist/src/WalkupScanToCompCaps.js +0 -20
  196. package/dist/src/WalkupScanToCompCaps.js.map +0 -1
  197. package/dist/src/WalkupScanToCompDestination.d.ts +0 -22
  198. package/dist/src/WalkupScanToCompDestination.js +0 -38
  199. package/dist/src/WalkupScanToCompDestination.js.map +0 -1
  200. package/dist/src/WalkupScanToCompDestinations.d.ts +0 -12
  201. package/dist/src/WalkupScanToCompDestinations.js +0 -30
  202. package/dist/src/WalkupScanToCompDestinations.js.map +0 -1
  203. package/dist/src/WalkupScanToCompEvent.d.ts +0 -11
  204. package/dist/src/WalkupScanToCompEvent.js +0 -20
  205. package/dist/src/WalkupScanToCompEvent.js.map +0 -1
  206. package/dist/src/WalkupScanToCompManifest.d.ts +0 -23
  207. package/dist/src/WalkupScanToCompManifest.js +0 -25
  208. package/dist/src/WalkupScanToCompManifest.js.map +0 -1
  209. package/dist/src/delay.d.ts +0 -1
  210. package/dist/src/delay.js +0 -10
  211. package/dist/src/delay.js.map +0 -1
@@ -5,7 +5,7 @@ import { KnownShortcut } from "./KnownShortcut";
5
5
 
6
6
  const parser = new Parser();
7
7
  const parseString = promisify<string, WalkupScanDestinationsData>(
8
- parser.parseString
8
+ parser.parseString,
9
9
  );
10
10
 
11
11
  interface WalkupScanDestinationsData {
@@ -32,11 +32,11 @@ export default class WalkupScanDestination {
32
32
  this.data = data;
33
33
  }
34
34
  static async createWalkupScanDestination(
35
- content: string
35
+ content: string,
36
36
  ): Promise<WalkupScanDestination> {
37
37
  const parsed = await parseString(content);
38
38
  return new WalkupScanDestination(
39
- parsed["wus:WalkupScanDestinations"]["wus:WalkupScanDestination"][0]
39
+ parsed["wus:WalkupScanDestinations"]["wus:WalkupScanDestination"][0],
40
40
  );
41
41
  }
42
42
 
@@ -53,14 +53,18 @@ export default class WalkupScanDestination {
53
53
  }
54
54
 
55
55
  get shortcut(): null | KnownShortcut {
56
- if (this.data.hasOwnProperty("wus:WalkupScanSettings")) {
56
+ if (
57
+ Object.prototype.hasOwnProperty.call(this.data, "wus:WalkupScanSettings")
58
+ ) {
57
59
  return this.data["wus:WalkupScanSettings"]["0"]["wus:Shortcut"][0];
58
60
  }
59
61
  return null;
60
62
  }
61
63
 
62
64
  get scanPlexMode(): string | null {
63
- if (this.data.hasOwnProperty("wus:WalkupScanSettings")) {
65
+ if (
66
+ Object.prototype.hasOwnProperty.call(this.data, "wus:WalkupScanSettings")
67
+ ) {
64
68
  return this.data["wus:WalkupScanSettings"]["0"][
65
69
  "scantype:ScanSettings"
66
70
  ][0]["dd:ScanPlexMode"][0];
@@ -3,7 +3,7 @@ import { Parser } from "xml2js";
3
3
  const parser = new Parser();
4
4
  import { promisify } from "util";
5
5
  const parseString = promisify<string, WalkupScanDestinationsData>(
6
- parser.parseString
6
+ parser.parseString,
7
7
  );
8
8
 
9
9
  import WalkupScanDestination, {
@@ -22,7 +22,7 @@ export default class WalkupScanDestinations {
22
22
  this.data = data;
23
23
  }
24
24
  static async createWalkupScanDestinations(
25
- content: string
25
+ content: string,
26
26
  ): Promise<WalkupScanDestinations> {
27
27
  const parsed = await parseString(content);
28
28
  return new WalkupScanDestinations(parsed);
@@ -30,9 +30,14 @@ export default class WalkupScanDestinations {
30
30
 
31
31
  get destinations(): WalkupScanDestination[] {
32
32
  let walkupScanDestinations = this.data["wus:WalkupScanDestinations"];
33
- if (walkupScanDestinations.hasOwnProperty("wus:WalkupScanDestination")) {
33
+ if (
34
+ Object.prototype.hasOwnProperty.call(
35
+ walkupScanDestinations,
36
+ "wus:WalkupScanDestination",
37
+ )
38
+ ) {
34
39
  return walkupScanDestinations["wus:WalkupScanDestination"].map(
35
- (x) => new WalkupScanDestination(x)
40
+ (x) => new WalkupScanDestination(x),
36
41
  );
37
42
  } else {
38
43
  return [];
@@ -3,7 +3,7 @@ import { Parser } from "xml2js";
3
3
  const parser = new Parser();
4
4
  import { promisify } from "util";
5
5
  const parseString = promisify<string, WalkupScanManifestData>(
6
- parser.parseString
6
+ parser.parseString,
7
7
  );
8
8
 
9
9
  export interface WalkupScanManifestData {
@@ -31,7 +31,7 @@ export default class WalkupScanManifest {
31
31
  this.data = data;
32
32
  }
33
33
  static async createWalkupScanManifest(
34
- content: string
34
+ content: string,
35
35
  ): Promise<WalkupScanManifest> {
36
36
  const parsed = await parseString(content);
37
37
  return new WalkupScanManifest(parsed);
@@ -43,7 +43,7 @@ export default class WalkupScanManifest {
43
43
  ]["map:ResourceNode"].find(
44
44
  (x) =>
45
45
  x["map:ResourceType"][0]["wus:WalkupScanResourceType"][0] ===
46
- "WalkupScanDestinations"
46
+ "WalkupScanDestinations",
47
47
  );
48
48
 
49
49
  if (walkupScanToCompCaps === undefined) {
@@ -3,7 +3,7 @@ import { Parser } from "xml2js";
3
3
  const parser = new Parser();
4
4
  import { promisify } from "util";
5
5
  const parseString = promisify<string, WalkupScanToCompCapsData>(
6
- parser.parseString
6
+ parser.parseString,
7
7
  );
8
8
  export interface WalkupScanToCompCapsData {
9
9
  "wus:WalkupScanToCompCaps": {
@@ -20,7 +20,7 @@ export default class WalkupScanToCompCaps {
20
20
  }
21
21
 
22
22
  static async createWalkupScanToCompCaps(
23
- content: string
23
+ content: string,
24
24
  ): Promise<WalkupScanToCompCaps> {
25
25
  const parsed = await parseString(content);
26
26
  return new WalkupScanToCompCaps(parsed);
@@ -4,7 +4,7 @@ const parser = new Parser();
4
4
  import { promisify } from "util";
5
5
  import { KnownShortcut } from "./KnownShortcut";
6
6
  const parseString = promisify<string, WalkupScanToCompDestinationRoot>(
7
- parser.parseString
7
+ parser.parseString,
8
8
  );
9
9
 
10
10
  interface WalkupScanToCompDestinationRoot {
@@ -29,11 +29,11 @@ export default class WalkupScanToCompDestination {
29
29
  this.data = data;
30
30
  }
31
31
  static async createWalkupScanToCompDestination(
32
- content: string
32
+ content: string,
33
33
  ): Promise<WalkupScanToCompDestination> {
34
34
  const parsed = await parseString(content);
35
35
  return new WalkupScanToCompDestination(
36
- parsed["wus:WalkupScanToCompDestination"]
36
+ parsed["wus:WalkupScanToCompDestination"],
37
37
  );
38
38
  }
39
39
 
@@ -50,14 +50,24 @@ export default class WalkupScanToCompDestination {
50
50
  }
51
51
 
52
52
  get shortcut(): null | KnownShortcut {
53
- if (this.data.hasOwnProperty("wus:WalkupScanToCompSettings")) {
53
+ if (
54
+ Object.prototype.hasOwnProperty.call(
55
+ this.data,
56
+ "wus:WalkupScanToCompSettings",
57
+ )
58
+ ) {
54
59
  return this.data["wus:WalkupScanToCompSettings"]["0"]["wus:Shortcut"][0];
55
60
  }
56
61
  return null;
57
62
  }
58
63
 
59
64
  get scanPlexMode(): string | null {
60
- if (this.data.hasOwnProperty("wus:WalkupScanToCompSettings")) {
65
+ if (
66
+ Object.prototype.hasOwnProperty.call(
67
+ this.data,
68
+ "wus:WalkupScanToCompSettings",
69
+ )
70
+ ) {
61
71
  return (
62
72
  this.data["wus:WalkupScanToCompSettings"]["0"]["scantype:ScanSettings"][
63
73
  "0"
@@ -3,7 +3,7 @@ import { Parser } from "xml2js";
3
3
  const parser = new Parser();
4
4
  import { promisify } from "util";
5
5
  const parseString = promisify<string, WalkupScanToCompDestinationsData>(
6
- parser.parseString
6
+ parser.parseString,
7
7
  );
8
8
 
9
9
  import WalkupScanToCompDestination, {
@@ -22,7 +22,7 @@ export default class WalkupScanToCompDestinations {
22
22
  this.data = data;
23
23
  }
24
24
  static async createWalkupScanToCompDestinations(
25
- content: string
25
+ content: string,
26
26
  ): Promise<WalkupScanToCompDestinations> {
27
27
  const parsed = await parseString(content);
28
28
  return new WalkupScanToCompDestinations(parsed);
@@ -32,8 +32,9 @@ export default class WalkupScanToCompDestinations {
32
32
  let walkupScanToCompDestinations =
33
33
  this.data["wus:WalkupScanToCompDestinations"];
34
34
  if (
35
- walkupScanToCompDestinations.hasOwnProperty(
36
- "wus:WalkupScanToCompDestination"
35
+ Object.prototype.hasOwnProperty.call(
36
+ walkupScanToCompDestinations,
37
+ "wus:WalkupScanToCompDestination",
37
38
  )
38
39
  ) {
39
40
  return walkupScanToCompDestinations[
@@ -3,7 +3,7 @@ import { Parser } from "xml2js";
3
3
  const parser = new Parser();
4
4
  import { promisify } from "util";
5
5
  const parseString = promisify<string, WalkupScanToCompEventData>(
6
- parser.parseString
6
+ parser.parseString,
7
7
  );
8
8
 
9
9
  export interface WalkupScanToCompEventData {
@@ -3,7 +3,7 @@ import { Parser } from "xml2js";
3
3
  const parser = new Parser();
4
4
  import { promisify } from "util";
5
5
  const parseString = promisify<string, WalkupScanToCompManifestData>(
6
- parser.parseString
6
+ parser.parseString,
7
7
  );
8
8
 
9
9
  export interface WalkupScanToCompManifestData {
@@ -31,7 +31,7 @@ export default class WalkupScanToCompManifest {
31
31
  this.data = data;
32
32
  }
33
33
  static async createWalkupScanToCompManifest(
34
- content: string
34
+ content: string,
35
35
  ): Promise<WalkupScanToCompManifest> {
36
36
  const parsed = await parseString(content);
37
37
  return new WalkupScanToCompManifest(parsed);
@@ -43,7 +43,7 @@ export default class WalkupScanToCompManifest {
43
43
  ]["map:ResourceNode"].find(
44
44
  (x) =>
45
45
  x["map:ResourceType"][0]["wus:WalkupScanToCompResourceType"][0] ===
46
- "WalkupScanToCompCaps"
46
+ "WalkupScanToCompCaps",
47
47
  );
48
48
 
49
49
  if (walkupScanToCompCaps === undefined) {
package/src/index.ts CHANGED
@@ -11,27 +11,38 @@ import HPApi from "./HPApi";
11
11
  import PathHelper from "./PathHelper";
12
12
  import { delay } from "./delay";
13
13
  import { readDeviceCapabilities } from "./readDeviceCapabilities";
14
- import { clearRegistrations, RegistrationConfig, waitScanEvent } from "./listening";
15
- import { AdfAutoScanConfig, DirectoryConfig, saveScan, ScanConfig, scanFromAdf, waitAdfLoaded } from "./scanProcessing";
14
+ import {
15
+ clearRegistrations,
16
+ RegistrationConfig,
17
+ waitScanEvent,
18
+ } from "./listening";
19
+ import {
20
+ AdfAutoScanConfig,
21
+ DirectoryConfig,
22
+ saveScan,
23
+ ScanConfig,
24
+ scanFromAdf,
25
+ waitAdfLoaded,
26
+ } from "./scanProcessing";
16
27
 
17
28
  let iteration = 0;
18
29
 
19
30
  async function listenCmd(
20
31
  registrationConfig: RegistrationConfig,
21
32
  scanConfig: ScanConfig,
22
- deviceUpPollingInterval: number
33
+ deviceUpPollingInterval: number,
23
34
  ) {
24
35
  // first make sure the device is reachable
25
36
  await HPApi.waitDeviceUp(deviceUpPollingInterval);
26
37
  let deviceUp = true;
27
38
 
28
39
  const folder = await PathHelper.getOutputFolder(
29
- scanConfig.directoryConfig.directory
40
+ scanConfig.directoryConfig.directory,
30
41
  );
31
42
  console.log(`Target folder: ${folder}`);
32
43
 
33
44
  const tempFolder = await PathHelper.getOutputFolder(
34
- scanConfig.directoryConfig.tempDirectory
45
+ scanConfig.directoryConfig.tempDirectory,
35
46
  );
36
47
  console.log(`Temp folder: ${tempFolder}`);
37
48
 
@@ -44,7 +55,11 @@ async function listenCmd(
44
55
  console.log(`Running iteration: ${iteration} - errorCount: ${errorCount}`);
45
56
  try {
46
57
  const event = await waitScanEvent(deviceCapabilities, registrationConfig);
47
- scanCount++;
58
+ scanCount = await PathHelper.getNextScanNumber(
59
+ folder,
60
+ scanCount,
61
+ scanConfig.directoryConfig.filePattern,
62
+ );
48
63
  console.log(`Scan event captured, saving scan #${scanCount}`);
49
64
  await saveScan(
50
65
  event,
@@ -52,7 +67,7 @@ async function listenCmd(
52
67
  tempFolder,
53
68
  scanCount,
54
69
  deviceCapabilities,
55
- scanConfig
70
+ scanConfig,
56
71
  );
57
72
  } catch (e) {
58
73
  console.log(e);
@@ -77,22 +92,24 @@ async function listenCmd(
77
92
 
78
93
  async function adfAutoscanCmd(
79
94
  adfAutoScanConfig: AdfAutoScanConfig,
80
- deviceUpPollingInterval: number
95
+ deviceUpPollingInterval: number,
81
96
  ) {
82
97
  // first make sure the device is reachable
83
98
  await HPApi.waitDeviceUp(deviceUpPollingInterval);
84
99
  let deviceUp = true;
85
100
 
86
101
  const folder = await PathHelper.getOutputFolder(
87
- adfAutoScanConfig.directoryConfig.directory
102
+ adfAutoScanConfig.directoryConfig.directory,
88
103
  );
89
104
  console.log(`Target folder: ${folder}`);
90
105
 
91
106
  const tempFolder = await PathHelper.getOutputFolder(
92
- adfAutoScanConfig.directoryConfig.tempDirectory
107
+ adfAutoScanConfig.directoryConfig.tempDirectory,
93
108
  );
94
109
  console.log(`Temp folder: ${tempFolder}`);
95
110
 
111
+ const deviceCapabilities = await readDeviceCapabilities();
112
+
96
113
  let scanCount = 0;
97
114
  let keepActive = true;
98
115
  let errorCount = 0;
@@ -101,14 +118,21 @@ async function adfAutoscanCmd(
101
118
  try {
102
119
  await waitAdfLoaded(
103
120
  adfAutoScanConfig.pollingInterval,
104
- adfAutoScanConfig.startScanDelay
121
+ adfAutoScanConfig.startScanDelay,
105
122
  );
106
123
 
107
124
  scanCount++;
108
125
 
109
126
  console.log(`Scan event captured, saving scan #${scanCount}`);
110
127
 
111
- await scanFromAdf(scanCount, folder, tempFolder, adfAutoScanConfig);
128
+ await scanFromAdf(
129
+ scanCount,
130
+ folder,
131
+ tempFolder,
132
+ adfAutoScanConfig,
133
+ deviceCapabilities,
134
+ new Date()
135
+ );
112
136
  } catch (e) {
113
137
  console.log(e);
114
138
  if (await HPApi.isAlive()) {
@@ -162,7 +186,7 @@ function findOfficejetIp(deviceNamePrefix: string): Promise<string> {
162
186
  console.log(`Found: ${service.name}`);
163
187
  resolve(service.addresses[0]);
164
188
  }
165
- }
189
+ },
166
190
  );
167
191
  browser.start();
168
192
  });
@@ -175,19 +199,27 @@ function getConfig<T>(name: string): T | undefined {
175
199
  function setupScanParameters(command: Command): Command {
176
200
  command.option(
177
201
  "-d, --directory <dir>",
178
- "Directory where scans are saved (default: /tmp/scan-to-pc<random>)"
202
+ "Directory where scans are saved (default: /tmp/scan-to-pc<random>)",
179
203
  );
180
204
  command.option(
181
205
  "-t, --temp-directory <dir>",
182
- "Temp directory used for processing (default: /tmp/scan-to-pc<random>)"
206
+ "Temp directory used for processing (default: /tmp/scan-to-pc<random>)",
183
207
  );
184
208
  command.option(
185
209
  "-p, --pattern <pattern>",
186
- 'Pattern for filename (i.e. "scan"_dd.mm.yyyy_hh:MM:ss, without this its scanPage<number>)'
210
+ 'Pattern for filename (i.e. "scan"_dd.mm.yyyy_hh:MM:ss, without this its scanPage<number>)',
187
211
  );
188
212
  command.option(
189
213
  "-r, --resolution <dpi>",
190
- "Resolution in DPI of the scans (default: 200)"
214
+ "Resolution in DPI of the scans (default: 200)",
215
+ );
216
+ command.option(
217
+ "-w, --width <width>",
218
+ "With in pixel of the scans (default: 2481)",
219
+ );
220
+ command.option(
221
+ "-h, --height <height>",
222
+ "Height in pixel of the scans (default: 3507)",
191
223
  );
192
224
  return command;
193
225
  }
@@ -195,16 +227,16 @@ function setupScanParameters(command: Command): Command {
195
227
  function setupParameterOpts(command: Command): Command {
196
228
  command.option(
197
229
  "-ip, --address <ip>",
198
- "IP address of the device (this overrides -p)"
230
+ "IP address of the device (this overrides -p)",
199
231
  );
200
232
  command.option(
201
233
  "--device-up-polling-interval <deviceUpPollingInterval>",
202
234
  "Device up polling interval in milliseconds",
203
- parseFloat
235
+ parseFloat,
204
236
  );
205
237
  command.option(
206
238
  "-n, --name <name>",
207
- "Name of the device for service discovery"
239
+ "Name of the device for service discovery",
208
240
  ); // i.e. 'Deskjet 3520 series'
209
241
 
210
242
  command.option("-D, --debug", "Enable debug");
@@ -238,11 +270,33 @@ function getScanConfiguration(parentOption: OptionValues) {
238
270
  filePattern: parentOption.pattern || getConfig("pattern"),
239
271
  };
240
272
 
273
+ const configWidth = (
274
+ parentOption.width ||
275
+ getConfig("width") ||
276
+ 0
277
+ ).toString();
278
+ const width =
279
+ configWidth.toLowerCase() === "max"
280
+ ? Number.MAX_SAFE_INTEGER
281
+ : parseInt(configWidth, 10);
282
+
283
+ const configHeight = (
284
+ parentOption.width ||
285
+ getConfig("height") ||
286
+ "0"
287
+ ).toString();
288
+ const height =
289
+ configWidth.toLowerCase() === "max"
290
+ ? Number.MAX_SAFE_INTEGER
291
+ : parseInt(configHeight, 10);
292
+
241
293
  const scanConfig: ScanConfig = {
242
294
  resolution: parseInt(
243
- parentOption.resolution || getConfig("resolution") || 200,
244
- 10
295
+ parentOption.resolution || getConfig("resolution") || "200",
296
+ 10,
245
297
  ),
298
+ width: width,
299
+ height: height,
246
300
  directoryConfig,
247
301
  };
248
302
  return scanConfig;
@@ -256,7 +310,6 @@ function getDeviceUpPollingInterval(parentOption: OptionValues) {
256
310
  );
257
311
  }
258
312
 
259
-
260
313
  async function main() {
261
314
  setupParameterOpts(program);
262
315
  const cmdListen = program.createCommand("listen");
@@ -264,7 +317,7 @@ async function main() {
264
317
  .description("Listen the device for new scan job to save to this target")
265
318
  .option(
266
319
  "-l, --label <label>",
267
- "The label to display on the device (the default is the hostname)"
320
+ "The label to display on the device (the default is the hostname)",
268
321
  )
269
322
  .action(async (options, cmd) => {
270
323
  const parentOption = cmd.parent.opts();
@@ -290,31 +343,31 @@ async function main() {
290
343
  const cmdAdfAutoscan = program.createCommand("adf-autoscan");
291
344
  setupScanParameters(cmdAdfAutoscan)
292
345
  .addOption(
293
- new Option("--duplex", "If specified, the scan will be in duplex")
346
+ new Option("--duplex", "If specified, the scan will be in duplex"),
294
347
  )
295
348
  .addOption(
296
349
  new Option(
297
350
  "--pdf",
298
- "If specified, the scan result will be a pdf document, the default is multiple jpeg files"
299
- )
351
+ "If specified, the scan result will be a pdf document, the default is multiple jpeg files",
352
+ ),
300
353
  )
301
354
  .addOption(
302
355
  new Option(
303
356
  "--pollingInterval <pollingInterval>",
304
357
  "Time interval in millisecond between each lookup for content in the automatic document feeder",
305
- )
358
+ ),
306
359
  )
307
360
  .description(
308
- "Automatically trigger a new scan job to this target once paper is detected in the automatic document feeder (adf)"
361
+ "Automatically trigger a new scan job to this target once paper is detected in the automatic document feeder (adf)",
309
362
  )
310
363
  .addOption(
311
364
  new Option(
312
365
  "--start-scan-delay <startScanDelay>",
313
366
  "Once document are detected to be in the adf, this specify the wait delay in millisecond before triggering the scan",
314
- )
367
+ ),
315
368
  )
316
369
  .description(
317
- "Automatically trigger a new scan job to this target once paper is detected in the automatic document feeder (adf)"
370
+ "Automatically trigger a new scan job to this target once paper is detected in the automatic document feeder (adf)",
318
371
  )
319
372
  .action(async (options, cmd) => {
320
373
  const parentOption = cmd.parent.opts();
@@ -334,9 +387,13 @@ async function main() {
334
387
  isDuplex: options.isDuplex || getConfig("autoscan_duplex") || false,
335
388
  generatePdf: options.pdf || getConfig("autoscan_pdf") || false,
336
389
  pollingInterval:
337
- options.pollingInterval || getConfig("autoscan_pollingInterval") || 1000,
390
+ options.pollingInterval ||
391
+ getConfig("autoscan_pollingInterval") ||
392
+ 1000,
338
393
  startScanDelay:
339
- options.startScanDelay || getConfig("autoscan_startScanDelay") || 5000,
394
+ options.startScanDelay ||
395
+ getConfig("autoscan_startScanDelay") ||
396
+ 5000,
340
397
  };
341
398
 
342
399
  await adfAutoscanCmd(adfScanConfig, deviceUpPollingInterval);
package/src/listening.ts CHANGED
@@ -6,9 +6,8 @@ import { DeviceCapabilities } from "./DeviceCapabilities";
6
6
  export async function waitScanRequest(compEventURI: string): Promise<boolean> {
7
7
  const waitMax = 50;
8
8
  for (let i = 0; i < waitMax; i++) {
9
- let walkupScanToCompEvent = await HPApi.getWalkupScanToCompEvent(
10
- compEventURI
11
- );
9
+ let walkupScanToCompEvent =
10
+ await HPApi.getWalkupScanToCompEvent(compEventURI);
12
11
  let message = walkupScanToCompEvent.eventType;
13
12
  if (message === "HostSelected") {
14
13
  // this ok to wait
@@ -32,7 +31,7 @@ export async function waitScanRequest(compEventURI: string): Promise<boolean> {
32
31
 
33
32
  export async function waitForScanEvent(
34
33
  resourceURI: string,
35
- afterEtag: string | null = null
34
+ afterEtag: string | null = null,
36
35
  ): Promise<Event> {
37
36
  console.log("Start listening for new ScanEvent");
38
37
 
@@ -47,21 +46,21 @@ export async function waitForScanEvent(
47
46
  (ev) =>
48
47
  ev.isScanEvent &&
49
48
  ev.destinationURI &&
50
- ev.destinationURI.indexOf(resourceURI) >= 0
49
+ ev.destinationURI.indexOf(resourceURI) >= 0,
51
50
  );
52
51
  }
53
52
  return acceptedScanEvent;
54
53
  }
55
54
 
56
55
  async function registerWalkupScanToCompDestination(
57
- registrationConfig: RegistrationConfig
56
+ registrationConfig: RegistrationConfig,
58
57
  ): Promise<string> {
59
58
  const walkupScanDestinations = await HPApi.getWalkupScanToCompDestinations();
60
59
  const destinations = walkupScanDestinations.destinations;
61
60
 
62
61
  console.log(
63
62
  "Host destinations fetched:",
64
- destinations.map((d) => d.name).join(", ")
63
+ destinations.map((d) => d.name).join(", "),
65
64
  );
66
65
 
67
66
  const hostname = registrationConfig.label;
@@ -70,12 +69,12 @@ async function registerWalkupScanToCompDestination(
70
69
  let resourceURI;
71
70
  if (destination) {
72
71
  console.log(
73
- `Re-using existing destination: ${hostname} - ${destination.resourceURI}`
72
+ `Re-using existing destination: ${hostname} - ${destination.resourceURI}`,
74
73
  );
75
74
  resourceURI = destination.resourceURI;
76
75
  } else {
77
76
  resourceURI = await HPApi.registerWalkupScanToCompDestination(
78
- new Destination(hostname, hostname, true)
77
+ new Destination(hostname, hostname, true),
79
78
  );
80
79
  console.log(`New Destination registered: ${hostname} - ${resourceURI}`);
81
80
  }
@@ -86,14 +85,14 @@ async function registerWalkupScanToCompDestination(
86
85
  }
87
86
 
88
87
  async function registerWalkupScanDestination(
89
- registrationConfig: RegistrationConfig
88
+ registrationConfig: RegistrationConfig,
90
89
  ): Promise<string> {
91
90
  const walkupScanDestinations = await HPApi.getWalkupScanDestinations();
92
91
  const destinations = walkupScanDestinations.destinations;
93
92
 
94
93
  console.log(
95
94
  "Host destinations fetched:",
96
- destinations.map((d) => d.name).join(", ")
95
+ destinations.map((d) => d.name).join(", "),
97
96
  );
98
97
 
99
98
  const hostname = registrationConfig.label;
@@ -102,12 +101,12 @@ async function registerWalkupScanDestination(
102
101
  let resourceURI;
103
102
  if (destination) {
104
103
  console.log(
105
- `Re-using existing destination: ${hostname} - ${destination.resourceURI}`
104
+ `Re-using existing destination: ${hostname} - ${destination.resourceURI}`,
106
105
  );
107
106
  resourceURI = destination.resourceURI;
108
107
  } else {
109
108
  resourceURI = await HPApi.registerWalkupScanDestination(
110
- new Destination(hostname, hostname, false)
109
+ new Destination(hostname, hostname, false),
111
110
  );
112
111
  console.log(`New Destination registered: ${hostname} - ${resourceURI}`);
113
112
  }
@@ -123,7 +122,7 @@ export type RegistrationConfig = {
123
122
 
124
123
  export async function waitScanEvent(
125
124
  deviceCapabilities: DeviceCapabilities,
126
- registrationConfig: RegistrationConfig
125
+ registrationConfig: RegistrationConfig,
127
126
  ): Promise<Event> {
128
127
  let resourceURI: string;
129
128
  if (deviceCapabilities.useWalkupScanToComp) {
@@ -142,4 +141,4 @@ export async function clearRegistrations() {
142
141
  console.log(`Removing: ${dests.destinations[i].name}`);
143
142
  await HPApi.removeDestination(dests.destinations[i]);
144
143
  }
145
- }
144
+ }