@capturebridge/sdk 0.12.0 → 0.14.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 (46) hide show
  1. package/CHANGELOG.md +93 -58
  2. package/Camera.js +63 -63
  3. package/CanonCamera.js +25 -25
  4. package/CaptureBridge.js +160 -160
  5. package/CapturePlugin.js +68 -68
  6. package/Common.js +258 -252
  7. package/Device.js +588 -595
  8. package/ICAO.js +86 -86
  9. package/IFace.js +237 -237
  10. package/ImageSource.js +110 -110
  11. package/Logs.js +129 -129
  12. package/MockCamera.js +17 -17
  13. package/Plugin.js +299 -299
  14. package/README.md +3 -3
  15. package/Scanner.js +55 -55
  16. package/SignatureTablet.js +86 -108
  17. package/SignatureTabletWidgets.js +164 -164
  18. package/StreamingCapturePlugin.js +129 -129
  19. package/TopazSigGem.js +68 -25
  20. package/Verifone.js +239 -192
  21. package/VerifoneControls.js +484 -0
  22. package/Version.js +7 -7
  23. package/WindowsScanner.js +25 -25
  24. package/package.json +1 -1
  25. package/examples/canon.html +0 -20
  26. package/examples/canon.js +0 -44
  27. package/examples/canon_getframe.html +0 -20
  28. package/examples/canon_getframe.js +0 -46
  29. package/examples/canon_lan.html +0 -20
  30. package/examples/canon_lan.js +0 -46
  31. package/examples/canon_minimal.html +0 -7
  32. package/examples/canon_minimal.js +0 -27
  33. package/examples/empty.jpg +0 -0
  34. package/examples/icao.html +0 -7
  35. package/examples/icao.jpg +0 -0
  36. package/examples/icao.js +0 -80
  37. package/examples/mockcamera.html +0 -20
  38. package/examples/mockcamera.js +0 -39
  39. package/examples/mockcamera_getframe.html +0 -20
  40. package/examples/mockcamera_getframe.js +0 -40
  41. package/examples/mockcamera_minimal.html +0 -7
  42. package/examples/mockcamera_minimal.js +0 -21
  43. package/examples/verifone_signature.html +0 -7
  44. package/examples/verifone_signature.js +0 -14
  45. package/examples/windows_scanner_minimal.html +0 -8
  46. package/examples/windows_scanner_minimal.js +0 -19
package/CHANGELOG.md CHANGED
@@ -1,58 +1,93 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [0.12.0] - 2024-08-08
9
-
10
- ### Changed
11
-
12
- - `BASE_URL` will default to `window.location.origin` if available, else
13
- https://local.capturebridge.net:9001) will be used.
14
-
15
- ## [0.11.4] - 2024-07-29
16
-
17
- ### Added
18
-
19
- - Added `background` parameter to `ICAO.check()` and `IFace.icao()` that will
20
- fill in any part of the cropped image that falls outside the source image.
21
-
22
- ## [0.11.0] - 2024-06-21
23
-
24
- ### Added
25
-
26
- - Added `DeviceForms` and `ControlProperty` classes for configuring forms for
27
- `Verifone`.
28
- - Added `Verifone.renderForm()`
29
-
30
- ## [0.10.0] - 2024-06-17
31
-
32
- ### Changed
33
-
34
- - Introduced breaking changes to the structure of the object returned from
35
- `ICAO.check()`
36
- - `ICAO` class will default to use the `capture_verify_iface` plugin if no
37
- plugin is provided to the constructor.
38
-
39
- ### Added
40
-
41
- - Coordinates of the cropped photo are now returned from `ICAO.check()` if a face
42
- was found.
43
-
44
- ## [0.9.0] - 2024-06-06
45
-
46
- ### Added
47
-
48
- - Introduced Changelog.
49
- - Add Verifone class and examples (features signature capture support for the M450)
50
- - Add `format` parameter to `DEFAULT_CAPTURE_OPT` (defaults to `null` which will
51
- use the plugin's default image format.)
52
- - Add `CaptureResponseFormat` type definition to documentation.
53
-
54
- ### Fixed
55
-
56
- - Fix bug where `null` would be sent for some URL parameters.
57
-
58
- [0.9.0]: https://www.npmjs.com/package/@capturebridge/sdk/v/0.9.0
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.14.0] - 2024-09-17
9
+
10
+ ### Added
11
+
12
+ - Add `Verifone.readMagstripe()` method for reading magstripe from Verifone.
13
+
14
+ ## [0.13.0] - 2024-09-10
15
+
16
+ ### Added
17
+
18
+ - Add Verifone dynamic form support and examples.
19
+
20
+ ### Changed
21
+
22
+ - `TopazSigGem.displayObjects()` previously accepted a boolean parameter for
23
+ it's second argument, which if `true`, would clear the screen before displaying
24
+ the objects. This method now accepts a `sceneOpt` object which contains
25
+ `clear` and `backlight` boolean. A deprecation flag has been added to preserve
26
+ the original function signature such that, if a boolean is provided, the method
27
+ will fallback to the previous behavior of clearing the screen and emit a console
28
+ warning. If an object is provided it will utilize any `clear` or `backlight`
29
+ boolean properties.
30
+
31
+ ```js
32
+ // Previous behavior, still works but will emit deprecation warning
33
+ await tablet.displayObjects([
34
+ new Text('My hovercraft is full of eels.', 100, 400),
35
+ ], false)
36
+
37
+ // New behavior
38
+ const result = await tablet.displayObjects([
39
+ new Text('My hovercraft is full of eels.', 100, 400),
40
+ ], {clear: false, backlight: true})
41
+ ```
42
+
43
+ ## [0.12.0] - 2024-08-08
44
+
45
+ ### Changed
46
+
47
+ - `BASE_URL` will default to `window.location.origin` if available, else
48
+ https://local.capturebridge.net:9001) will be used.
49
+
50
+ ## [0.11.4] - 2024-07-29
51
+
52
+ ### Added
53
+
54
+ - Added `background` parameter to `ICAO.check()` and `IFace.icao()` that will
55
+ fill in any part of the cropped image that falls outside the source image.
56
+
57
+ ## [0.11.0] - 2024-06-21
58
+
59
+ ### Added
60
+
61
+ - Added `DeviceForms` and `ControlProperty` classes for configuring forms for
62
+ `Verifone`.
63
+ - Added `Verifone.renderForm()`
64
+
65
+ ## [0.10.0] - 2024-06-17
66
+
67
+ ### Changed
68
+
69
+ - Introduced breaking changes to the structure of the object returned from
70
+ `ICAO.check()`
71
+ - `ICAO` class will default to use the `capture_verify_iface` plugin if no
72
+ plugin is provided to the constructor.
73
+
74
+ ### Added
75
+
76
+ - Coordinates of the cropped photo are now returned from `ICAO.check()` if a face
77
+ was found.
78
+
79
+ ## [0.9.0] - 2024-06-06
80
+
81
+ ### Added
82
+
83
+ - Introduced Changelog.
84
+ - Add Verifone class and examples (features signature capture support for the M450)
85
+ - Add `format` parameter to `DEFAULT_CAPTURE_OPT` (defaults to `null` which will
86
+ use the plugin's default image format.)
87
+ - Add `CaptureResponseFormat` type definition to documentation.
88
+
89
+ ### Fixed
90
+
91
+ - Fix bug where `null` would be sent for some URL parameters.
92
+
93
+ [0.9.0]: https://www.npmjs.com/package/@capturebridge/sdk/v/0.9.0
package/Camera.js CHANGED
@@ -1,63 +1,63 @@
1
- import StreamingCapturePlugin from './StreamingCapturePlugin.js'
2
- import {
3
- BASE_URL,
4
- DEFAULT_CAPTURE_OPT,
5
- DEPRECATION_01,
6
- asyncToCallback
7
- } from './Common.js'
8
-
9
- /**
10
- * Camera
11
- * @classdesc Class for invoking methods on a Camera
12
- * @extends StreamingCapturePlugin
13
- * @see {@link CanonCamera}
14
- */
15
- class Camera extends StreamingCapturePlugin {
16
- /**
17
- * Instantiate a Generic Camera
18
- * @constructor
19
- * @param {string} pluginId - The Id of the desired plugin to use for this
20
- * camera instance. The plugin must support the `start_feed`, `stop_feed`,
21
- * `devices`, and `capture` methods.
22
- * @param {string} [baseURL] - Protocol, domain, and port for the service.
23
- * @example
24
- * const camera = new Camera('capture_camera_canon')
25
- */
26
- constructor (pluginId, baseUrl = BASE_URL) {
27
- super(pluginId, baseUrl)
28
- }
29
-
30
- /**
31
- * Capture a photo
32
- * @param {CaptureOptions} [captureOpt] - Additional options for capturing a
33
- * photo.
34
- * @param {string|object} [deviceOpt] - Take the photo using either a specific
35
- * Device ID or a Device Object. The default is the first available device.
36
- *
37
- * @async
38
- * @example
39
- * // Capture a photo as an ObjectURL, add it to an img element and append to
40
- * // the document's body.
41
- * const img = document.createElement('img')
42
- * img.src = await camera.takePhoto()
43
- * document.body.appendChild(img)
44
- */
45
- async takePhoto (captureOpt = {}, deviceOpt) {
46
- if (typeof captureOpt === 'string' && DEPRECATION_01) {
47
- captureOpt = { kind: captureOpt }
48
- console.warn('CaptureBridge SDK Deprecation Warning: ' +
49
- '`Camera.takePhoto()` converted the `captureOpt` argument from a ' +
50
- 'string (%s) to an object (%s). This conversion may not be performed ' +
51
- 'in future SDK versions.',
52
- captureOpt.kind, JSON.stringify(captureOpt))
53
- }
54
- const mergedOpt = Object.assign({}, DEFAULT_CAPTURE_OPT, captureOpt)
55
- return await this.fullCapture(mergedOpt, deviceOpt)
56
- }
57
-
58
- takePhotoHandler (captureOpt = {}, deviceOpt, callback) {
59
- asyncToCallback(this, this.fullCapture, callback, captureOpt, deviceOpt)
60
- }
61
- }
62
-
63
- export default Camera
1
+ import StreamingCapturePlugin from './StreamingCapturePlugin.js'
2
+ import {
3
+ BASE_URL,
4
+ DEFAULT_CAPTURE_OPT,
5
+ DEPRECATION_01,
6
+ asyncToCallback
7
+ } from './Common.js'
8
+
9
+ /**
10
+ * Camera
11
+ * @classdesc Class for invoking methods on a Camera
12
+ * @extends StreamingCapturePlugin
13
+ * @see {@link CanonCamera}
14
+ */
15
+ class Camera extends StreamingCapturePlugin {
16
+ /**
17
+ * Instantiate a Generic Camera
18
+ * @constructor
19
+ * @param {string} pluginId - The Id of the desired plugin to use for this
20
+ * camera instance. The plugin must support the `start_feed`, `stop_feed`,
21
+ * `devices`, and `capture` methods.
22
+ * @param {string} [baseURL] - Protocol, domain, and port for the service.
23
+ * @example
24
+ * const camera = new Camera('capture_camera_canon')
25
+ */
26
+ constructor (pluginId, baseUrl = BASE_URL) {
27
+ super(pluginId, baseUrl)
28
+ }
29
+
30
+ /**
31
+ * Capture a photo
32
+ * @param {CaptureOptions} [captureOpt] - Additional options for capturing a
33
+ * photo.
34
+ * @param {string|object} [deviceOpt] - Take the photo using either a specific
35
+ * Device ID or a Device Object. The default is the first available device.
36
+ *
37
+ * @async
38
+ * @example
39
+ * // Capture a photo as an ObjectURL, add it to an img element and append to
40
+ * // the document's body.
41
+ * const img = document.createElement('img')
42
+ * img.src = await camera.takePhoto()
43
+ * document.body.appendChild(img)
44
+ */
45
+ async takePhoto (captureOpt = {}, deviceOpt) {
46
+ if (typeof captureOpt === 'string' && DEPRECATION_01) {
47
+ captureOpt = { kind: captureOpt }
48
+ console.warn('CaptureBridge SDK Deprecation Warning: ' +
49
+ '`Camera.takePhoto()` converted the `captureOpt` argument from a ' +
50
+ 'string (%s) to an object (%s). This conversion may not be performed ' +
51
+ 'in future SDK versions.',
52
+ captureOpt.kind, JSON.stringify(captureOpt))
53
+ }
54
+ const mergedOpt = Object.assign({}, DEFAULT_CAPTURE_OPT, captureOpt)
55
+ return await this.fullCapture(mergedOpt, deviceOpt)
56
+ }
57
+
58
+ takePhotoHandler (captureOpt = {}, deviceOpt, callback) {
59
+ asyncToCallback(this, this.fullCapture, callback, captureOpt, deviceOpt)
60
+ }
61
+ }
62
+
63
+ export default Camera
package/CanonCamera.js CHANGED
@@ -1,25 +1,25 @@
1
- import Camera from './Camera.js'
2
- import { BASE_URL } from './Common.js'
3
-
4
- /**
5
- * CanonCamera
6
- * @classdesc Convenience class for instantiating a Canon Camera Object.
7
- * Inherits all methods on the {@link Camera} class.
8
- * @extends Camera
9
- * @see {@link Camera}
10
- */
11
- class CanonCamera extends Camera {
12
- /**
13
- * Instantiate a Canon Camera
14
- * @constructor
15
- * @param {string} [baseURL] - Protocol, domain, and port for the service.
16
- * @example
17
- * const camera = new CanonCamera()
18
- * const base64 = await camera.takePhoto({kind: 'base64'})
19
- */
20
- constructor (baseUrl = BASE_URL) {
21
- super('capture_camera_canon', baseUrl)
22
- }
23
- }
24
-
25
- export default CanonCamera
1
+ import Camera from './Camera.js'
2
+ import { BASE_URL } from './Common.js'
3
+
4
+ /**
5
+ * CanonCamera
6
+ * @classdesc Convenience class for instantiating a Canon Camera Object.
7
+ * Inherits all methods on the {@link Camera} class.
8
+ * @extends Camera
9
+ * @see {@link Camera}
10
+ */
11
+ class CanonCamera extends Camera {
12
+ /**
13
+ * Instantiate a Canon Camera
14
+ * @constructor
15
+ * @param {string} [baseURL] - Protocol, domain, and port for the service.
16
+ * @example
17
+ * const camera = new CanonCamera()
18
+ * const base64 = await camera.takePhoto({kind: 'base64'})
19
+ */
20
+ constructor (baseUrl = BASE_URL) {
21
+ super('capture_camera_canon', baseUrl)
22
+ }
23
+ }
24
+
25
+ export default CanonCamera
package/CaptureBridge.js CHANGED
@@ -1,160 +1,160 @@
1
- import Plugin from './Plugin.js'
2
- import { BASE_URL, asyncToCallback, checkResponse } from './Common.js'
3
-
4
- /**
5
- * Capture Bridge
6
- *
7
- * @classdesc Class for interacting with the HTTP API's base methods.
8
- */
9
- class CaptureBridge {
10
- baseUrl
11
- /**
12
- * Instantiate a client for interacting with the Capture Bridge service.
13
- * @constructor
14
- * @param {string} [baseURL] - Protocol, domain, and port for the service.
15
- * @example
16
- * const captureBridge = new CaptureBridge()
17
- */
18
- constructor (baseUrl = BASE_URL) {
19
- this.baseUrl = baseUrl
20
- }
21
-
22
- /**
23
- * Get service version info
24
- * @method
25
- * @async
26
- * @returns {object} Service version info.
27
- * @see {@link https://local.capturebridge.net:9001/doc/#api-Service-GetVersion|API Endpoint (/version)}
28
- * @example
29
- * const captureBridge = new CaptureBridge()
30
- * const {version} = await captureBridge.version()
31
- * console.log(version)
32
- */
33
- async version () {
34
- const response = await fetch(`${this.baseUrl}/version`)
35
- return await response.json()
36
- }
37
-
38
- /**
39
- * Get service version info (Callback)
40
- * @method
41
- * @see {@link https://local.capturebridge.net:9001/doc/#api-Service-GetVersion|API Endpoint (/version)}
42
- * @param {function} callback - Invoked with two arguments. The first argument
43
- * is an Error object (if an error occurred) or null. The second argument is
44
- * the version info.
45
- * @example
46
- * captureBridge.versionHandler((error, {version}) => {
47
- * if (error) {
48
- * console.error('Error fetching version:', error)
49
- * } else {
50
- * console.log(`Version: ${version}`)
51
- * }
52
- * })
53
- */
54
- versionHandler (callback) {
55
- asyncToCallback(this, this.version, callback)
56
- }
57
-
58
- /**
59
- * Get service status information
60
- * @method
61
- * @async
62
- * @see {@link https://local.capturebridge.net:9001/doc/#api-Service-GetStatus|API Endpoint (/status)}
63
- * @returns {object} Service status information.
64
- * @example
65
- * const captureBridge = new CaptureBridge()
66
- * const statusInfo = await captureBridge.status()
67
- * console.log(statusInfo)
68
- */
69
- async status () {
70
- const response = await fetch(`${this.baseUrl}/status`)
71
- return await response.json()
72
- }
73
-
74
- /**
75
- * Get service status information (Callback)
76
- * @method
77
- * @see {@link https://local.capturebridge.net:9001/doc/#api-Service-GetStatus|API Endpoint (/status)}
78
- * @param {function} callback - Invoked with two arguments. The first argument
79
- * is an Error object (if an error occurred) or null. The second argument is
80
- * the status info.
81
- * object.
82
- * @example
83
- * const captureBridge = new CaptureBridge()
84
- * captureBridge.statusHandler(statusInfo => console.log(statusInfo))
85
- */
86
- statusHandler (callback) {
87
- asyncToCallback(this, this.status, callback)
88
- }
89
-
90
- /**
91
- * Get all installed plugins
92
- * @method
93
- * @async
94
- * @see {@link https://local.capturebridge.net:9001/doc/#api-Plugin-GetPlugins|API Endpoint (/plugin)}
95
- * @see {@link Plugin}
96
- * @returns {object[]} Array of {@link Plugin} objects.
97
- * @example
98
- * const plugins = await captureBridge.plugins()
99
- */
100
- async plugins () {
101
- const response = await fetch(`${this.baseUrl}/plugin`)
102
- const plugins = await response.json()
103
- return plugins.map(p => new Plugin(p, this.baseUrl))
104
- }
105
-
106
- /**
107
- * Get all installed plugins (Callback)
108
- * @method
109
- * @see {@link https://local.capturebridge.net:9001/doc/#api-Plugin-GetPlugins|API Endpoint (/plugin)}
110
- * @see {@link Plugin}
111
- * @param {function} callback - Invoked with two arguments. The first argument
112
- * is an Error object (if an error occurred) or null. The second argument is
113
- * an Array of {@link Plugin} objects. If no plugins are installed the second
114
- * argument will be an empty Array.
115
- * @example
116
- * captureBridge.pluginsHandler(plugins => console.log(plugins))
117
- */
118
- pluginsHandler (callback) {
119
- asyncToCallback(this, this.plugins, callback)
120
- }
121
-
122
- /**
123
- * Get a single plugin by ID
124
- * @method
125
- * @async
126
- * @see {@link https://local.capturebridge.net:9001/doc/#api-Plugin-GetPlugins|API Endpoint (/plugin)}
127
- * @see {@link Plugin}
128
- * @param {string} id - Plugin ID
129
- * @returns {object?} {@link Plugin} object or null
130
- * @example
131
- * const plugin = await captureBridge.plugin('capture_camera_canon')
132
- */
133
- async plugin (id) {
134
- const response = await fetch(`${this.baseUrl}/plugin/${id}`)
135
- await checkResponse(response)
136
- const pluginJSON = await response.json()
137
- return new Plugin(pluginJSON)
138
- }
139
-
140
- /**
141
- * Get a single plugin by ID (Callback version).
142
- * @method
143
- * @see {@link https://local.capturebridge.net:9001/doc/#api-Plugin-GetPlugins|API Endpoint (/plugin)}
144
- * @see {@link Plugin}
145
- * @param {string} id - Plugin ID
146
- * @param {function} callback - Invoked with two arguments. The first argument
147
- * is an Error object (if an error occurred) or null. The second argument is
148
- * the requested {@link Plugin} object. If no matching plugin was found the
149
- * second argument will be null.
150
- * @example
151
- * captureBridge.pluginHandler('capture_camera_canon', (error, plugin) => {
152
- * console.log(error, plugin)
153
- * })
154
- */
155
- pluginHandler (id, callback) {
156
- asyncToCallback(this, this.plugin, callback, id)
157
- }
158
- }
159
-
160
- export default CaptureBridge
1
+ import Plugin from './Plugin.js'
2
+ import { BASE_URL, asyncToCallback, checkResponse } from './Common.js'
3
+
4
+ /**
5
+ * Capture Bridge
6
+ *
7
+ * @classdesc Class for interacting with the HTTP API's base methods.
8
+ */
9
+ class CaptureBridge {
10
+ baseUrl
11
+ /**
12
+ * Instantiate a client for interacting with the Capture Bridge service.
13
+ * @constructor
14
+ * @param {string} [baseURL] - Protocol, domain, and port for the service.
15
+ * @example
16
+ * const captureBridge = new CaptureBridge()
17
+ */
18
+ constructor (baseUrl = BASE_URL) {
19
+ this.baseUrl = baseUrl
20
+ }
21
+
22
+ /**
23
+ * Get service version info
24
+ * @method
25
+ * @async
26
+ * @returns {object} Service version info.
27
+ * @see {@link https://local.capturebridge.net:9001/doc/#api-Service-GetVersion|API Endpoint (/version)}
28
+ * @example
29
+ * const captureBridge = new CaptureBridge()
30
+ * const {version} = await captureBridge.version()
31
+ * console.log(version)
32
+ */
33
+ async version () {
34
+ const response = await fetch(`${this.baseUrl}/version`)
35
+ return await response.json()
36
+ }
37
+
38
+ /**
39
+ * Get service version info (Callback)
40
+ * @method
41
+ * @see {@link https://local.capturebridge.net:9001/doc/#api-Service-GetVersion|API Endpoint (/version)}
42
+ * @param {function} callback - Invoked with two arguments. The first argument
43
+ * is an Error object (if an error occurred) or null. The second argument is
44
+ * the version info.
45
+ * @example
46
+ * captureBridge.versionHandler((error, {version}) => {
47
+ * if (error) {
48
+ * console.error('Error fetching version:', error)
49
+ * } else {
50
+ * console.log(`Version: ${version}`)
51
+ * }
52
+ * })
53
+ */
54
+ versionHandler (callback) {
55
+ asyncToCallback(this, this.version, callback)
56
+ }
57
+
58
+ /**
59
+ * Get service status information
60
+ * @method
61
+ * @async
62
+ * @see {@link https://local.capturebridge.net:9001/doc/#api-Service-GetStatus|API Endpoint (/status)}
63
+ * @returns {object} Service status information.
64
+ * @example
65
+ * const captureBridge = new CaptureBridge()
66
+ * const statusInfo = await captureBridge.status()
67
+ * console.log(statusInfo)
68
+ */
69
+ async status () {
70
+ const response = await fetch(`${this.baseUrl}/status`)
71
+ return await response.json()
72
+ }
73
+
74
+ /**
75
+ * Get service status information (Callback)
76
+ * @method
77
+ * @see {@link https://local.capturebridge.net:9001/doc/#api-Service-GetStatus|API Endpoint (/status)}
78
+ * @param {function} callback - Invoked with two arguments. The first argument
79
+ * is an Error object (if an error occurred) or null. The second argument is
80
+ * the status info.
81
+ * object.
82
+ * @example
83
+ * const captureBridge = new CaptureBridge()
84
+ * captureBridge.statusHandler(statusInfo => console.log(statusInfo))
85
+ */
86
+ statusHandler (callback) {
87
+ asyncToCallback(this, this.status, callback)
88
+ }
89
+
90
+ /**
91
+ * Get all installed plugins
92
+ * @method
93
+ * @async
94
+ * @see {@link https://local.capturebridge.net:9001/doc/#api-Plugin-GetPlugins|API Endpoint (/plugin)}
95
+ * @see {@link Plugin}
96
+ * @returns {object[]} Array of {@link Plugin} objects.
97
+ * @example
98
+ * const plugins = await captureBridge.plugins()
99
+ */
100
+ async plugins () {
101
+ const response = await fetch(`${this.baseUrl}/plugin`)
102
+ const plugins = await response.json()
103
+ return plugins.map(p => new Plugin(p, this.baseUrl))
104
+ }
105
+
106
+ /**
107
+ * Get all installed plugins (Callback)
108
+ * @method
109
+ * @see {@link https://local.capturebridge.net:9001/doc/#api-Plugin-GetPlugins|API Endpoint (/plugin)}
110
+ * @see {@link Plugin}
111
+ * @param {function} callback - Invoked with two arguments. The first argument
112
+ * is an Error object (if an error occurred) or null. The second argument is
113
+ * an Array of {@link Plugin} objects. If no plugins are installed the second
114
+ * argument will be an empty Array.
115
+ * @example
116
+ * captureBridge.pluginsHandler(plugins => console.log(plugins))
117
+ */
118
+ pluginsHandler (callback) {
119
+ asyncToCallback(this, this.plugins, callback)
120
+ }
121
+
122
+ /**
123
+ * Get a single plugin by ID
124
+ * @method
125
+ * @async
126
+ * @see {@link https://local.capturebridge.net:9001/doc/#api-Plugin-GetPlugins|API Endpoint (/plugin)}
127
+ * @see {@link Plugin}
128
+ * @param {string} id - Plugin ID
129
+ * @returns {object?} {@link Plugin} object or null
130
+ * @example
131
+ * const plugin = await captureBridge.plugin('capture_camera_canon')
132
+ */
133
+ async plugin (id) {
134
+ const response = await fetch(`${this.baseUrl}/plugin/${id}`)
135
+ await checkResponse(response)
136
+ const pluginJSON = await response.json()
137
+ return new Plugin(pluginJSON)
138
+ }
139
+
140
+ /**
141
+ * Get a single plugin by ID (Callback version).
142
+ * @method
143
+ * @see {@link https://local.capturebridge.net:9001/doc/#api-Plugin-GetPlugins|API Endpoint (/plugin)}
144
+ * @see {@link Plugin}
145
+ * @param {string} id - Plugin ID
146
+ * @param {function} callback - Invoked with two arguments. The first argument
147
+ * is an Error object (if an error occurred) or null. The second argument is
148
+ * the requested {@link Plugin} object. If no matching plugin was found the
149
+ * second argument will be null.
150
+ * @example
151
+ * captureBridge.pluginHandler('capture_camera_canon', (error, plugin) => {
152
+ * console.log(error, plugin)
153
+ * })
154
+ */
155
+ pluginHandler (id, callback) {
156
+ asyncToCallback(this, this.plugin, callback, id)
157
+ }
158
+ }
159
+
160
+ export default CaptureBridge