@capturebridge/sdk 0.12.1 → 0.14.2
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/CHANGELOG.md +93 -58
- package/Camera.js +63 -63
- package/CanonCamera.js +25 -25
- package/CaptureBridge.js +160 -160
- package/CapturePlugin.js +68 -68
- package/Common.js +258 -252
- package/Device.js +588 -595
- package/ICAO.js +86 -86
- package/IFace.js +237 -237
- package/ImageSource.js +110 -110
- package/Logs.js +129 -129
- package/MockCamera.js +17 -17
- package/Plugin.js +299 -299
- package/README.md +3 -3
- package/Scanner.js +55 -55
- package/SignatureTablet.js +86 -108
- package/SignatureTabletWidgets.js +164 -164
- package/StreamingCapturePlugin.js +129 -129
- package/TopazSigGem.js +68 -25
- package/Verifone.js +239 -192
- package/VerifoneControls.js +484 -0
- package/Version.js +7 -7
- package/WindowsScanner.js +25 -25
- package/package.json +1 -1
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
import CapturePlugin from './CapturePlugin.js'
|
|
2
|
-
import {
|
|
3
|
-
BASE_URL,
|
|
4
|
-
DATAURL_JPEG,
|
|
5
|
-
blobToBuffer,
|
|
6
|
-
DEFAULT_CAPTURE_OPT,
|
|
7
|
-
DEPRECATION_01
|
|
8
|
-
} from './Common.js'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* StreamingCapturePlugin
|
|
12
|
-
* @extends CapturePlugin
|
|
13
|
-
* @classdesc Class for invoking streaming-related methods
|
|
14
|
-
*/
|
|
15
|
-
class StreamingCapturePlugin extends CapturePlugin {
|
|
16
|
-
constructor (plugin, baseUrl = BASE_URL) {
|
|
17
|
-
super(plugin, baseUrl)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Get the CapturePlugin's stream endpoint URL.
|
|
22
|
-
*
|
|
23
|
-
* @description The URL returned from this endpoint can be attached to an
|
|
24
|
-
* img tag's src attribute. The camera's live stream will be started and
|
|
25
|
-
* begin streaming to the img tag as a
|
|
26
|
-
* {@link https://en.wikipedia.org/wiki/Motion_JPEG|Motion JPEG} stream.
|
|
27
|
-
* If the src is changed, the img removed from the DOM, or client disconnected
|
|
28
|
-
* for any reason, the live feed will automatically be stopped.
|
|
29
|
-
*
|
|
30
|
-
* @param {string|object} [deviceOpt] - Get the stream URL from either a
|
|
31
|
-
* specific Device ID or a Device Object. The default is the first available
|
|
32
|
-
* device.
|
|
33
|
-
*
|
|
34
|
-
* @async
|
|
35
|
-
* @method
|
|
36
|
-
* @returns {string} stream endpoint URL
|
|
37
|
-
* @example
|
|
38
|
-
* const img = document.createElement('img')
|
|
39
|
-
* img.src = await camera.streamUrl()
|
|
40
|
-
* document.body.appendChild(img)
|
|
41
|
-
*/
|
|
42
|
-
async streamUrl (streamOpt = {}, deviceOpt) {
|
|
43
|
-
const device = await this.setupDevice(deviceOpt)
|
|
44
|
-
return device.streamUrl(streamOpt)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get the most recent frame from a device's live feed.
|
|
49
|
-
*
|
|
50
|
-
* @description This method will startup the device's live
|
|
51
|
-
* feed if necessary and wait for it to initialize before returning a frame.
|
|
52
|
-
* Subsequent calls will return the next available frame.
|
|
53
|
-
* You must manually stop the live feed if you are using this method.
|
|
54
|
-
*
|
|
55
|
-
* If implementing a real-time preview, it is highly recommended to use the
|
|
56
|
-
* stream endpoint which will stream a Motion JPEG.
|
|
57
|
-
*
|
|
58
|
-
* @see {@link CapturePlugin#streamUrl}
|
|
59
|
-
* @see {@link CapturePlugin#stopFeed}
|
|
60
|
-
*
|
|
61
|
-
* @param {CaptureOptions} [captureOpt] - Additional options for capturing a
|
|
62
|
-
* photo.
|
|
63
|
-
*
|
|
64
|
-
* @param {string|object} [deviceOpt] - Return the frame from either a
|
|
65
|
-
* specific Device ID or a Device Object. The default, if not supplied, is the
|
|
66
|
-
* first available device.
|
|
67
|
-
*
|
|
68
|
-
* @async
|
|
69
|
-
* @method
|
|
70
|
-
* @example
|
|
71
|
-
* // Get the most recent frame from the camera's live feed as an ArrayBuffer
|
|
72
|
-
* // and add it to an img tag appended to the document's body.
|
|
73
|
-
* const img = document.createElement('img')
|
|
74
|
-
* img.src = await camera.getMostRecentFrame()
|
|
75
|
-
* document.body.appendChild(img)
|
|
76
|
-
*
|
|
77
|
-
* // Stop the live feed when done getting frames
|
|
78
|
-
* await camera.stopFeed()
|
|
79
|
-
*/
|
|
80
|
-
async getMostRecentFrame (captureOpt = {}, deviceOpt) {
|
|
81
|
-
if (typeof captureOpt === 'string' && DEPRECATION_01) {
|
|
82
|
-
captureOpt = { kind: captureOpt }
|
|
83
|
-
console.warn('CaptureBridge SDK Deprecation Warning: ' +
|
|
84
|
-
'`StreamingCapturePlugin.getMostRecentFrame()` converted the ' +
|
|
85
|
-
'`captureOpt` argument from a string (%s) to an object (%s). This ' +
|
|
86
|
-
'conversion may not be performed in future SDK versions.',
|
|
87
|
-
captureOpt.kind, JSON.stringify(captureOpt))
|
|
88
|
-
}
|
|
89
|
-
const mergedOpt = Object.assign({}, DEFAULT_CAPTURE_OPT, captureOpt)
|
|
90
|
-
const device = await this.setupDevice(mergedOpt)
|
|
91
|
-
switch (mergedOpt.kind) {
|
|
92
|
-
case 'objecturl':
|
|
93
|
-
return URL.createObjectURL(await device.frameAsBlob(mergedOpt))
|
|
94
|
-
case 'blob':
|
|
95
|
-
return await device.frameAsBlob(mergedOpt)
|
|
96
|
-
case 'buffer':
|
|
97
|
-
return await blobToBuffer(await device.frameAsBlob(mergedOpt))
|
|
98
|
-
case 'base64':
|
|
99
|
-
return await device.frameAsBase64(mergedOpt)
|
|
100
|
-
case 'dataurl':
|
|
101
|
-
return DATAURL_JPEG + (await device.frameAsBase64(mergedOpt))
|
|
102
|
-
}
|
|
103
|
-
throw new Error(`Unknown image response kind: ${mergedOpt.kind}`)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Stop the camera's live feed if it is running.
|
|
108
|
-
*
|
|
109
|
-
* @param {string|object} [deviceOpt] - Stop the feed for a specific Device ID
|
|
110
|
-
* or a Device Object. The default, if not supplied, is the first available
|
|
111
|
-
* device.
|
|
112
|
-
*
|
|
113
|
-
* @method
|
|
114
|
-
* @async
|
|
115
|
-
* @returns {object} Status of the stop operation
|
|
116
|
-
* @example
|
|
117
|
-
* // CapturePlugin is now running it's live feed in a background thread
|
|
118
|
-
* const frame = await camera.getMostRecentFrame()
|
|
119
|
-
* // Do some stuff with frame...
|
|
120
|
-
* // Stop the live feed
|
|
121
|
-
* console.log(await camera.stopFeed())
|
|
122
|
-
*/
|
|
123
|
-
async stopFeed (deviceOpt) {
|
|
124
|
-
const device = await this.setupDevice(deviceOpt)
|
|
125
|
-
return await device.stopFeed()
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export default StreamingCapturePlugin
|
|
1
|
+
import CapturePlugin from './CapturePlugin.js'
|
|
2
|
+
import {
|
|
3
|
+
BASE_URL,
|
|
4
|
+
DATAURL_JPEG,
|
|
5
|
+
blobToBuffer,
|
|
6
|
+
DEFAULT_CAPTURE_OPT,
|
|
7
|
+
DEPRECATION_01
|
|
8
|
+
} from './Common.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* StreamingCapturePlugin
|
|
12
|
+
* @extends CapturePlugin
|
|
13
|
+
* @classdesc Class for invoking streaming-related methods
|
|
14
|
+
*/
|
|
15
|
+
class StreamingCapturePlugin extends CapturePlugin {
|
|
16
|
+
constructor (plugin, baseUrl = BASE_URL) {
|
|
17
|
+
super(plugin, baseUrl)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get the CapturePlugin's stream endpoint URL.
|
|
22
|
+
*
|
|
23
|
+
* @description The URL returned from this endpoint can be attached to an
|
|
24
|
+
* img tag's src attribute. The camera's live stream will be started and
|
|
25
|
+
* begin streaming to the img tag as a
|
|
26
|
+
* {@link https://en.wikipedia.org/wiki/Motion_JPEG|Motion JPEG} stream.
|
|
27
|
+
* If the src is changed, the img removed from the DOM, or client disconnected
|
|
28
|
+
* for any reason, the live feed will automatically be stopped.
|
|
29
|
+
*
|
|
30
|
+
* @param {string|object} [deviceOpt] - Get the stream URL from either a
|
|
31
|
+
* specific Device ID or a Device Object. The default is the first available
|
|
32
|
+
* device.
|
|
33
|
+
*
|
|
34
|
+
* @async
|
|
35
|
+
* @method
|
|
36
|
+
* @returns {string} stream endpoint URL
|
|
37
|
+
* @example
|
|
38
|
+
* const img = document.createElement('img')
|
|
39
|
+
* img.src = await camera.streamUrl()
|
|
40
|
+
* document.body.appendChild(img)
|
|
41
|
+
*/
|
|
42
|
+
async streamUrl (streamOpt = {}, deviceOpt) {
|
|
43
|
+
const device = await this.setupDevice(deviceOpt)
|
|
44
|
+
return device.streamUrl(streamOpt)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the most recent frame from a device's live feed.
|
|
49
|
+
*
|
|
50
|
+
* @description This method will startup the device's live
|
|
51
|
+
* feed if necessary and wait for it to initialize before returning a frame.
|
|
52
|
+
* Subsequent calls will return the next available frame.
|
|
53
|
+
* You must manually stop the live feed if you are using this method.
|
|
54
|
+
*
|
|
55
|
+
* If implementing a real-time preview, it is highly recommended to use the
|
|
56
|
+
* stream endpoint which will stream a Motion JPEG.
|
|
57
|
+
*
|
|
58
|
+
* @see {@link CapturePlugin#streamUrl}
|
|
59
|
+
* @see {@link CapturePlugin#stopFeed}
|
|
60
|
+
*
|
|
61
|
+
* @param {CaptureOptions} [captureOpt] - Additional options for capturing a
|
|
62
|
+
* photo.
|
|
63
|
+
*
|
|
64
|
+
* @param {string|object} [deviceOpt] - Return the frame from either a
|
|
65
|
+
* specific Device ID or a Device Object. The default, if not supplied, is the
|
|
66
|
+
* first available device.
|
|
67
|
+
*
|
|
68
|
+
* @async
|
|
69
|
+
* @method
|
|
70
|
+
* @example
|
|
71
|
+
* // Get the most recent frame from the camera's live feed as an ArrayBuffer
|
|
72
|
+
* // and add it to an img tag appended to the document's body.
|
|
73
|
+
* const img = document.createElement('img')
|
|
74
|
+
* img.src = await camera.getMostRecentFrame()
|
|
75
|
+
* document.body.appendChild(img)
|
|
76
|
+
*
|
|
77
|
+
* // Stop the live feed when done getting frames
|
|
78
|
+
* await camera.stopFeed()
|
|
79
|
+
*/
|
|
80
|
+
async getMostRecentFrame (captureOpt = {}, deviceOpt) {
|
|
81
|
+
if (typeof captureOpt === 'string' && DEPRECATION_01) {
|
|
82
|
+
captureOpt = { kind: captureOpt }
|
|
83
|
+
console.warn('CaptureBridge SDK Deprecation Warning: ' +
|
|
84
|
+
'`StreamingCapturePlugin.getMostRecentFrame()` converted the ' +
|
|
85
|
+
'`captureOpt` argument from a string (%s) to an object (%s). This ' +
|
|
86
|
+
'conversion may not be performed in future SDK versions.',
|
|
87
|
+
captureOpt.kind, JSON.stringify(captureOpt))
|
|
88
|
+
}
|
|
89
|
+
const mergedOpt = Object.assign({}, DEFAULT_CAPTURE_OPT, captureOpt)
|
|
90
|
+
const device = await this.setupDevice(mergedOpt)
|
|
91
|
+
switch (mergedOpt.kind) {
|
|
92
|
+
case 'objecturl':
|
|
93
|
+
return URL.createObjectURL(await device.frameAsBlob(mergedOpt))
|
|
94
|
+
case 'blob':
|
|
95
|
+
return await device.frameAsBlob(mergedOpt)
|
|
96
|
+
case 'buffer':
|
|
97
|
+
return await blobToBuffer(await device.frameAsBlob(mergedOpt))
|
|
98
|
+
case 'base64':
|
|
99
|
+
return await device.frameAsBase64(mergedOpt)
|
|
100
|
+
case 'dataurl':
|
|
101
|
+
return DATAURL_JPEG + (await device.frameAsBase64(mergedOpt))
|
|
102
|
+
}
|
|
103
|
+
throw new Error(`Unknown image response kind: ${mergedOpt.kind}`)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Stop the camera's live feed if it is running.
|
|
108
|
+
*
|
|
109
|
+
* @param {string|object} [deviceOpt] - Stop the feed for a specific Device ID
|
|
110
|
+
* or a Device Object. The default, if not supplied, is the first available
|
|
111
|
+
* device.
|
|
112
|
+
*
|
|
113
|
+
* @method
|
|
114
|
+
* @async
|
|
115
|
+
* @returns {object} Status of the stop operation
|
|
116
|
+
* @example
|
|
117
|
+
* // CapturePlugin is now running it's live feed in a background thread
|
|
118
|
+
* const frame = await camera.getMostRecentFrame()
|
|
119
|
+
* // Do some stuff with frame...
|
|
120
|
+
* // Stop the live feed
|
|
121
|
+
* console.log(await camera.stopFeed())
|
|
122
|
+
*/
|
|
123
|
+
async stopFeed (deviceOpt) {
|
|
124
|
+
const device = await this.setupDevice(deviceOpt)
|
|
125
|
+
return await device.stopFeed()
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export default StreamingCapturePlugin
|
package/TopazSigGem.js
CHANGED
|
@@ -1,25 +1,68 @@
|
|
|
1
|
-
import SignatureTablet from './SignatureTablet.js'
|
|
2
|
-
import { BASE_URL } from './Common.js'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* TopazSigGem
|
|
6
|
-
* @classdesc
|
|
7
|
-
* Inherits all methods on the {@link SignatureTablet} class.
|
|
8
|
-
* @extends SignatureTablet
|
|
9
|
-
* @see {@link SignatureTablet}
|
|
10
|
-
*/
|
|
11
|
-
class TopazSigGem extends SignatureTablet {
|
|
12
|
-
/**
|
|
13
|
-
* Instantiate a Topaz SigGem Signature Tablet
|
|
14
|
-
* @constructor
|
|
15
|
-
* @param {string} [baseURL] - Protocol, domain, and port for the service.
|
|
16
|
-
* @example
|
|
17
|
-
* const
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
constructor (baseUrl = BASE_URL) {
|
|
21
|
-
super('capture_signature_topaz', baseUrl)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import SignatureTablet from './SignatureTablet.js'
|
|
2
|
+
import { BASE_URL, DEPRECATION_02 } from './Common.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* TopazSigGem
|
|
6
|
+
* @classdesc Class for communicating with a Topaz SigGem Signature Tablet.
|
|
7
|
+
* Inherits all methods on the {@link SignatureTablet} class.
|
|
8
|
+
* @extends SignatureTablet
|
|
9
|
+
* @see {@link SignatureTablet}
|
|
10
|
+
*/
|
|
11
|
+
class TopazSigGem extends SignatureTablet {
|
|
12
|
+
/**
|
|
13
|
+
* Instantiate a Topaz SigGem Signature Tablet
|
|
14
|
+
* @constructor
|
|
15
|
+
* @param {string} [baseURL] - Protocol, domain, and port for the service.
|
|
16
|
+
* @example
|
|
17
|
+
* const tablet = new TopazSigGem()
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
constructor (baseUrl = BASE_URL) {
|
|
21
|
+
super('capture_signature_topaz', baseUrl)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Render an Array of SignatureTabletWidgets and wait for user to click one.
|
|
26
|
+
*
|
|
27
|
+
* @description If any of the provided widgets are Buttons, the method will
|
|
28
|
+
* wait for one to be clicked and will then return the ID of the clicked
|
|
29
|
+
* widget.
|
|
30
|
+
*
|
|
31
|
+
* @param {Object[]} widgets An array of SignatureTabletWidgets to display.
|
|
32
|
+
* @param {Object} [sceneOpt] Options for configuring the scene.
|
|
33
|
+
* @param {boolean} [sceneOpt.clear=true] If `true`, the display will be
|
|
34
|
+
* cleared before adding the Objects.
|
|
35
|
+
* @param {Object} [sceneOpt.backlight=true] If `true`, the backlight will be
|
|
36
|
+
* enabled before adding the Objects.
|
|
37
|
+
*
|
|
38
|
+
* @async
|
|
39
|
+
* @method
|
|
40
|
+
* @returns {string?} ID of the clicked widget (if any Buttons were provided)
|
|
41
|
+
* @example
|
|
42
|
+
* const result = await tablet.displayObjects([
|
|
43
|
+
* new TextButton("OK", 20, 200),
|
|
44
|
+
* new TextButton("Cancel", 80, 200)
|
|
45
|
+
* ], {clear: false})
|
|
46
|
+
*
|
|
47
|
+
* console.log(`ID: ${result} was clicked`)
|
|
48
|
+
*/
|
|
49
|
+
async displayObjects (objects, sceneOpt = { clear: true, backlight: true }, deviceOpt) {
|
|
50
|
+
const device = await this.setupDevice(deviceOpt)
|
|
51
|
+
if (typeof sceneOpt === 'boolean' && DEPRECATION_02) {
|
|
52
|
+
const clear = sceneOpt
|
|
53
|
+
sceneOpt = { clear, backlight: true }
|
|
54
|
+
console.warn('CaptureBridge SDK Deprecation Warning: ' +
|
|
55
|
+
'`TopazSigGem.displayObjects()` converted the `sceneOpt` argument ' +
|
|
56
|
+
'from a boolean (%s) to an object (%s). This conversion may not be ' +
|
|
57
|
+
'performed in future SDK versions.',
|
|
58
|
+
clear, JSON.stringify(sceneOpt))
|
|
59
|
+
} else {
|
|
60
|
+
sceneOpt = Object.assign({ clear: true, backlight: true }, sceneOpt)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const { clicked } = await device.displayObjects(objects, sceneOpt)
|
|
64
|
+
return clicked
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default TopazSigGem
|