@capturebridge/sdk 0.7.0 → 0.8.0
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.
- package/Camera.js +63 -68
- package/CanonCamera.js +25 -25
- package/CaptureBridge.js +160 -162
- package/CapturePlugin.js +68 -79
- package/Common.js +182 -98
- package/Device.js +547 -451
- package/ICAO.js +70 -70
- package/IFace.js +278 -274
- package/Logs.js +129 -129
- package/MockCamera.js +17 -10
- package/Plugin.js +299 -298
- package/Scanner.js +55 -64
- package/SignatureTablet.js +108 -109
- package/SignatureTabletWidgets.js +164 -153
- package/StreamingCapturePlugin.js +129 -121
- package/TopazSigGem.js +25 -25
- package/Version.js +8 -0
- package/WindowsScanner.js +25 -0
- package/examples/canon.html +66 -0
- package/examples/canon_getframe.html +68 -0
- package/examples/canon_lan.html +68 -0
- package/examples/canon_minimal.html +37 -0
- package/examples/mockcamera.html +61 -0
- package/examples/mockcamera_getframe.html +63 -0
- package/examples/mockcamera_minimal.html +31 -0
- package/examples/windows_scanner_minimal.html +32 -0
- package/package.json +2 -2
package/Scanner.js
CHANGED
|
@@ -1,64 +1,55 @@
|
|
|
1
|
-
import CapturePlugin from './CapturePlugin.js'
|
|
2
|
-
import { BASE_URL } from './Common.js'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Scanner
|
|
6
|
-
* @classdesc Class for invoking methods on a Scanner
|
|
7
|
-
*
|
|
8
|
-
* @see {@link CanonScanner}
|
|
9
|
-
*/
|
|
10
|
-
class Scanner extends CapturePlugin {
|
|
11
|
-
/**
|
|
12
|
-
* Instantiate a Generic Scanner
|
|
13
|
-
* @constructor
|
|
14
|
-
* @param {string} [baseURL] - Protocol, domain, and port for the service.
|
|
15
|
-
* @param {string} pluginId - The Id of the desired plugin to use for this
|
|
16
|
-
* scanner instance. The plugin must support the "devices", and "capture"
|
|
17
|
-
* methods.
|
|
18
|
-
* @example
|
|
19
|
-
* const scanner = new Scanner('capture_scanner_windows')
|
|
20
|
-
*/
|
|
21
|
-
constructor (plugin, baseUrl = BASE_URL) {
|
|
22
|
-
super(plugin, baseUrl)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Scan a document
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* img.src = await scanner.scan()
|
|
57
|
-
* document.body.appendChild(img)
|
|
58
|
-
*/
|
|
59
|
-
async scan (kind = 'buffer', deviceOpt) {
|
|
60
|
-
return await this.fullCapture(kind, deviceOpt)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default Scanner
|
|
1
|
+
import CapturePlugin from './CapturePlugin.js'
|
|
2
|
+
import { BASE_URL, DEFAULT_CAPTURE_OPT, DEPRECATION_01 } from './Common.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Scanner
|
|
6
|
+
* @classdesc Class for invoking methods on a Scanner
|
|
7
|
+
*
|
|
8
|
+
* @see {@link CanonScanner}
|
|
9
|
+
*/
|
|
10
|
+
class Scanner extends CapturePlugin {
|
|
11
|
+
/**
|
|
12
|
+
* Instantiate a Generic Scanner
|
|
13
|
+
* @constructor
|
|
14
|
+
* @param {string} [baseURL] - Protocol, domain, and port for the service.
|
|
15
|
+
* @param {string} pluginId - The Id of the desired plugin to use for this
|
|
16
|
+
* scanner instance. The plugin must support the "devices", and "capture"
|
|
17
|
+
* methods.
|
|
18
|
+
* @example
|
|
19
|
+
* const scanner = new Scanner('capture_scanner_windows')
|
|
20
|
+
*/
|
|
21
|
+
constructor (plugin, baseUrl = BASE_URL) {
|
|
22
|
+
super(plugin, baseUrl)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Scan a document
|
|
27
|
+
*
|
|
28
|
+
* @param {CaptureOptions} [captureOpt] - Additional options for capturing a
|
|
29
|
+
* signature.
|
|
30
|
+
*
|
|
31
|
+
* @param {string|object} [deviceOpt] - Can a document using either a specific
|
|
32
|
+
* Device ID or a Device Object. The default is the first available device.
|
|
33
|
+
*
|
|
34
|
+
* @async
|
|
35
|
+
* @example
|
|
36
|
+
* // Scan document as an ArrayBuffer and add it to an img tag appended to
|
|
37
|
+
* // the document's body.
|
|
38
|
+
* const img = document.createElement('img')
|
|
39
|
+
* img.src = await scanner.scan()
|
|
40
|
+
* document.body.appendChild(img)
|
|
41
|
+
*/
|
|
42
|
+
async scan (captureOpt = {}, deviceOpt) {
|
|
43
|
+
if (typeof captureOpt === 'string' && DEPRECATION_01) {
|
|
44
|
+
captureOpt = { kind: captureOpt }
|
|
45
|
+
console.warn('CaptureBridge SDK Deprecation Warning: `Scanner.scan()` ' +
|
|
46
|
+
'converted the `captureOpt` argument from a string (%s) to an object ' +
|
|
47
|
+
'(%s). This conversion may not be performed in future SDK versions.',
|
|
48
|
+
captureOpt.kind, JSON.stringify(captureOpt))
|
|
49
|
+
}
|
|
50
|
+
const mergedOpt = Object.assign({}, DEFAULT_CAPTURE_OPT, captureOpt)
|
|
51
|
+
return await this.fullCapture(mergedOpt, deviceOpt)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default Scanner
|
package/SignatureTablet.js
CHANGED
|
@@ -1,109 +1,108 @@
|
|
|
1
|
-
import StreamingCapturePlugin from './StreamingCapturePlugin.js'
|
|
2
|
-
import { BASE_URL } from './Common.js'
|
|
3
|
-
|
|
4
|
-
|
|
5
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|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
export default SignatureTablet
|
|
1
|
+
import StreamingCapturePlugin from './StreamingCapturePlugin.js'
|
|
2
|
+
import { BASE_URL, DEFAULT_CAPTURE_OPT, DEPRECATION_01 } from './Common.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SignatureTablet
|
|
6
|
+
* @classdesc Class for invoking methods on a Signature Capture Tablet
|
|
7
|
+
* @extends StreamingCapturePlugin
|
|
8
|
+
* @see {@link TopazSigGem}
|
|
9
|
+
*/
|
|
10
|
+
class SignatureTablet extends StreamingCapturePlugin {
|
|
11
|
+
#captureBridge
|
|
12
|
+
#scene = {}
|
|
13
|
+
|
|
14
|
+
constructor (plugin, baseUrl = BASE_URL) {
|
|
15
|
+
super(plugin, baseUrl)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Clear the tablet's display.
|
|
20
|
+
*
|
|
21
|
+
* @description This method will set the tablet's LCD screen to an empty white
|
|
22
|
+
* background. The blacklight will also be enabled if it is not already.
|
|
23
|
+
*
|
|
24
|
+
* @param {boolean} [backlight] If provided and set to true, will enable
|
|
25
|
+
* backlight. If false, it will be disabled. If unspecified no action will be
|
|
26
|
+
* taken on the backlight.
|
|
27
|
+
*
|
|
28
|
+
* @param {string|object} [deviceOpt] - Clear the display of a either a
|
|
29
|
+
* specific Device ID or a Device Object. The default is the first available
|
|
30
|
+
* device.
|
|
31
|
+
*
|
|
32
|
+
* @async
|
|
33
|
+
* @method
|
|
34
|
+
* @returns {object}
|
|
35
|
+
* @example
|
|
36
|
+
* const img = document.createElement('img')
|
|
37
|
+
* img.src = await camera.streamUrl()
|
|
38
|
+
* document.body.appendChild(img)
|
|
39
|
+
*/
|
|
40
|
+
async clear (backlight, deviceOpt) {
|
|
41
|
+
const device = await this.setupDevice(deviceOpt)
|
|
42
|
+
return device.clear(backlight)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Display an Array of objects on the display.
|
|
47
|
+
*
|
|
48
|
+
* @description If any objects are Button types, the method will wait for one
|
|
49
|
+
* to be clicked and will then return the ID of the clicked object.
|
|
50
|
+
*
|
|
51
|
+
* @param {object[]} objects An array of Signature Tablet Widgets to display.
|
|
52
|
+
*
|
|
53
|
+
* @param {boolean} [clear] If true (the default), the display will be cleared
|
|
54
|
+
* before adding the objects.
|
|
55
|
+
*
|
|
56
|
+
* @param {string|object} [deviceOpt] - Display the objects on either a
|
|
57
|
+
* specific Device ID or a Device Object. The default is the first available
|
|
58
|
+
* device.
|
|
59
|
+
*
|
|
60
|
+
* @async
|
|
61
|
+
* @method
|
|
62
|
+
* @returns {string?} ID of the clicked object if any
|
|
63
|
+
* @example
|
|
64
|
+
* const result = await tablet.displayObjects([
|
|
65
|
+
* new Button("OK", 20, 200),
|
|
66
|
+
* new Button("Cancel", 80, 200)
|
|
67
|
+
* ])
|
|
68
|
+
*
|
|
69
|
+
* console.log(`${result} was clicked`)
|
|
70
|
+
*/
|
|
71
|
+
async displayObjects (objects, clear = true, deviceOpt) {
|
|
72
|
+
const device = await this.setupDevice(deviceOpt)
|
|
73
|
+
return device.displayObjects(objects, clear)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Capture a high resolution signature
|
|
78
|
+
*
|
|
79
|
+
* @param {CaptureOptions} [captureOpt] - Additional options for capturing a
|
|
80
|
+
* signature.
|
|
81
|
+
*
|
|
82
|
+
* @param {string|object} [deviceOpt] - Capture the signature using either a
|
|
83
|
+
* specific Device ID or a Device Object. The default is the first available
|
|
84
|
+
* device.
|
|
85
|
+
*
|
|
86
|
+
* @async
|
|
87
|
+
* @example
|
|
88
|
+
* // Capture signature as an ArrayBuffer and add it to an img tag appended to
|
|
89
|
+
* // the document's body.
|
|
90
|
+
* const img = document.createElement('img')
|
|
91
|
+
* img.src = await tablet.signature()
|
|
92
|
+
* document.body.appendChild(img)
|
|
93
|
+
*/
|
|
94
|
+
async signature (captureOpt = {}, deviceOpt) {
|
|
95
|
+
if (typeof captureOpt === 'string' && DEPRECATION_01) {
|
|
96
|
+
captureOpt = { kind: captureOpt }
|
|
97
|
+
console.warn('CaptureBridge SDK Deprecation Warning: ' +
|
|
98
|
+
'`SignatureTablet.signature()` converted the `captureOpt` argument ' +
|
|
99
|
+
'from a string (%s) to an object (%s). This conversion may not be ' +
|
|
100
|
+
'performed in future SDK versions.',
|
|
101
|
+
captureOpt.kind, JSON.stringify(captureOpt))
|
|
102
|
+
}
|
|
103
|
+
const mergedOpt = Object.assign({}, DEFAULT_CAPTURE_OPT, captureOpt)
|
|
104
|
+
return await this.fullCapture(mergedOpt, deviceOpt)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default SignatureTablet
|