@regulaforensics/document-reader 8.3.242-beta → 8.3.246-beta
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/README.md +2 -3
- package/RNDocumentReader.podspec +1 -1
- package/examples/capacitor/package.json +1 -1
- package/examples/capacitor/src/extra/bt_device.tsx +2 -2
- package/examples/capacitor/src/extra/custom_rfid.tsx +8 -8
- package/examples/capacitor/src/main.tsx +24 -27
- package/examples/ionic/package.json +1 -1
- package/examples/ionic/src/extra/{bt_device.ts → bt_device.tsx} +2 -2
- package/examples/ionic/src/extra/{custom_rfid.ts → custom_rfid.tsx} +8 -8
- package/examples/ionic/src/{main.ts → main.tsx} +24 -27
- package/examples/ionic/tsconfig.json +3 -2
- package/examples/react_native/index.tsx +2 -1
- package/examples/react_native/package.json +1 -1
- package/examples/react_native/src/extra/bt_device.tsx +2 -3
- package/examples/react_native/src/extra/custom_rfid.tsx +8 -9
- package/examples/react_native/src/main.tsx +24 -28
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/examples/cordova/.vscode/launch.json +0 -28
- package/examples/cordova/.vscode/typings/cordova/cordova.d.ts +0 -80
- package/examples/cordova/README.md +0 -22
- package/examples/cordova/config.xml +0 -33
- package/examples/cordova/package-lock.json +0 -1772
- package/examples/cordova/package.json +0 -33
- package/examples/cordova/scripts/android.sh +0 -8
- package/examples/cordova/scripts/bundle.sh +0 -4
- package/examples/cordova/scripts/ios.sh +0 -8
- package/examples/cordova/scripts/setup.sh +0 -8
- package/examples/cordova/www/bootstrap.js +0 -30
- package/examples/cordova/www/images/document.png +0 -0
- package/examples/cordova/www/images/logo.png +0 -0
- package/examples/cordova/www/images/portrait.png +0 -0
- package/examples/cordova/www/index.html +0 -6
- package/examples/cordova/www/index.js +0 -30
- package/examples/cordova/www/src/extra/bt_device.js +0 -32
- package/examples/cordova/www/src/extra/custom_rfid.js +0 -60
- package/examples/cordova/www/src/main.css +0 -134
- package/examples/cordova/www/src/main.html +0 -38
- package/examples/cordova/www/src/main.js +0 -173
- /package/examples/ionic/{index.ts → index.tsx} +0 -0
package/README.md
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
# Regula Document Reader plugin
|
|
2
|
-
Document Reader allows you to read various kinds of identification documents, passports, driving licenses, ID cards, etc. All processing is performed completely offline on your device. This plugin makes possible to use it with react-native, cordova and
|
|
2
|
+
Document Reader allows you to read various kinds of identification documents, passports, driving licenses, ID cards, etc. All processing is performed completely offline on your device. This plugin makes possible to use it with react-native, cordova and capacitor applications.
|
|
3
3
|
|
|
4
4
|
## Demo applications
|
|
5
|
-
In the [examples](examples/) folder you can find
|
|
5
|
+
In the [examples](examples/) folder you can find 3 demo applications:
|
|
6
6
|
* [React-native](examples/react-native)
|
|
7
|
-
* [Cordova](examples/cordova)
|
|
8
7
|
* [Ionic(ionic app with cordova, angular)](examples/ionic)
|
|
9
8
|
* [Capacitor(ionic app with capacitor, react)](examples/capacitor)
|
|
10
9
|
|
package/RNDocumentReader.podspec
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"android": "scripts/android.sh"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@regulaforensics/document-reader": "8.3.
|
|
9
|
+
"@regulaforensics/document-reader": "8.3.246-beta",
|
|
10
10
|
"@regulaforensics/document-reader-core-fullauthrfid": "8.3.9-beta",
|
|
11
11
|
"@regulaforensics/document-reader-btdevice": "8.3.10-beta",
|
|
12
12
|
"@awesome-cordova-plugins/file": "6.6.0",
|
|
@@ -5,7 +5,7 @@ export const useBtDevice = false
|
|
|
5
5
|
export const btDeviceName = "Regula 0000"
|
|
6
6
|
|
|
7
7
|
export function setupBTDevice() {
|
|
8
|
-
var connectButton = document.getElementById("connect")
|
|
8
|
+
var connectButton = document.getElementById("connect")!
|
|
9
9
|
connectButton.style.display = "flex"
|
|
10
10
|
connectButton.onclick = () => connect()
|
|
11
11
|
setStatus("Connect to a bluetooth device")
|
|
@@ -16,7 +16,7 @@ async function connect() {
|
|
|
16
16
|
if (await DocumentReader.instance.connectBluetoothDevice(btDeviceName)) {
|
|
17
17
|
await init()
|
|
18
18
|
DocumentReader.instance.functionality.useAuthenticator = true
|
|
19
|
-
document.getElementById("bt-device")
|
|
19
|
+
document.getElementById("bt-device")!.style.display = "none"
|
|
20
20
|
} else
|
|
21
21
|
setStatus("Failed to connect")
|
|
22
22
|
}
|
|
@@ -28,7 +28,7 @@ function setup() {
|
|
|
28
28
|
setProgress(-1)
|
|
29
29
|
currentProgress = -1
|
|
30
30
|
setShowing(true)
|
|
31
|
-
document.getElementById("cancel-rfid")
|
|
31
|
+
document.getElementById("cancel-rfid")!.onclick = () => stop()
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function stop() {
|
|
@@ -37,13 +37,13 @@ function stop() {
|
|
|
37
37
|
setShowing(false)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function setDescription(data) {
|
|
41
|
-
document.getElementById("rfid-description")
|
|
40
|
+
function setDescription(data: string) {
|
|
41
|
+
document.getElementById("rfid-description")!.innerHTML = data
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
var currentProgress = -1
|
|
45
|
-
function setProgress(next) {
|
|
46
|
-
var progress = document.getElementById("progress")
|
|
45
|
+
function setProgress(next: number) {
|
|
46
|
+
var progress = document.getElementById("progress")!
|
|
47
47
|
// make progress bar look better
|
|
48
48
|
if (next == 0) return // ignore idle 0s, leave progress at 100 while its not moving
|
|
49
49
|
if (next < currentProgress) next = 0 // move to 0 if progress finaly started moving
|
|
@@ -55,7 +55,7 @@ function setProgress(next) {
|
|
|
55
55
|
currentProgress = next
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
function setShowing(data) {
|
|
59
|
-
document.getElementById("main")
|
|
60
|
-
document.getElementById("custom-rfid")
|
|
58
|
+
function setShowing(data: boolean) {
|
|
59
|
+
document.getElementById("main")!.style.display = data ? "none" : "flex"
|
|
60
|
+
document.getElementById("custom-rfid")!.style.display = data ? "flex" : "none"
|
|
61
61
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario } from '@regulaforensics/document-reader'
|
|
1
|
+
import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario, Results, DocReaderException, DocReaderScenario } from '@regulaforensics/document-reader'
|
|
2
2
|
import { loadAsset, pickImage } from '../index'
|
|
3
3
|
import { initializeWithBTDevice, setupBTDevice, useBtDevice } from './extra/bt_device'
|
|
4
4
|
import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid'
|
|
5
5
|
|
|
6
6
|
var documentReader = DocumentReader.instance
|
|
7
|
-
var selectedScenario
|
|
7
|
+
var selectedScenario = Scenario.MRZ
|
|
8
8
|
var doRfid = false
|
|
9
9
|
var isReadingRfid = false
|
|
10
10
|
|
|
@@ -36,7 +36,7 @@ async function recognize() {
|
|
|
36
36
|
)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export function handleCompletion(action, results, error) {
|
|
39
|
+
export function handleCompletion(action: DocReaderAction, results: Results | null, error: DocReaderException | null) {
|
|
40
40
|
handleException(error)
|
|
41
41
|
if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
|
|
42
42
|
displayResults(results)
|
|
@@ -46,7 +46,7 @@ export function handleCompletion(action, results, error) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export async function displayResults(results) {
|
|
49
|
+
export async function displayResults(results: Results | null) {
|
|
50
50
|
isReadingRfid = false
|
|
51
51
|
clearResults()
|
|
52
52
|
if (results == null) return
|
|
@@ -65,7 +65,7 @@ var readRfid = () => {
|
|
|
65
65
|
documentReader.rfid(new RFIDConfig(handleCompletion))
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function shouldRfid(results) {
|
|
68
|
+
function shouldRfid(results: Results | null) {
|
|
69
69
|
return doRfid &&
|
|
70
70
|
!isReadingRfid &&
|
|
71
71
|
results != null && results.chipPage != 0
|
|
@@ -82,7 +82,7 @@ var initialize = async () => {
|
|
|
82
82
|
return success
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
export function handleException(error) {
|
|
85
|
+
export function handleException(error: DocReaderException | null) {
|
|
86
86
|
if (error != null) {
|
|
87
87
|
setStatus(error.message)
|
|
88
88
|
console.log(error.code + ": " + error.message)
|
|
@@ -91,13 +91,13 @@ export function handleException(error) {
|
|
|
91
91
|
|
|
92
92
|
// --------------------------------------------------------------------------------------------------------------------
|
|
93
93
|
|
|
94
|
-
var documentUIImage
|
|
95
|
-
var portraitUIImage
|
|
94
|
+
var documentUIImage: HTMLImageElement
|
|
95
|
+
var portraitUIImage: HTMLImageElement
|
|
96
96
|
export function main() {
|
|
97
|
-
documentUIImage = document.getElementById("document-image")
|
|
98
|
-
portraitUIImage = document.getElementById("portrait-image")
|
|
99
|
-
document.getElementById("scan")
|
|
100
|
-
document.getElementById("recognize")
|
|
97
|
+
documentUIImage = document.getElementById("document-image") as HTMLImageElement
|
|
98
|
+
portraitUIImage = document.getElementById("portrait-image") as HTMLImageElement
|
|
99
|
+
document.getElementById("scan")!.onclick = () => scan()
|
|
100
|
+
document.getElementById("recognize")!.onclick = () => recognize()
|
|
101
101
|
|
|
102
102
|
// custom rfid
|
|
103
103
|
if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
|
|
@@ -110,17 +110,17 @@ export function main() {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
export function setStatus(data) {
|
|
113
|
+
export function setStatus(data: string | null) {
|
|
114
114
|
if (data != null)
|
|
115
|
-
document.getElementById("status")
|
|
115
|
+
document.getElementById("status")!.innerHTML = data
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
function setPortrait(data) {
|
|
118
|
+
function setPortrait(data: string | null) {
|
|
119
119
|
if (data != null)
|
|
120
120
|
portraitUIImage.src = "data:image/png;base64," + data
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
function setDocImage(data) {
|
|
123
|
+
function setDocImage(data: string | null) {
|
|
124
124
|
if (data != null)
|
|
125
125
|
documentUIImage.src = "data:image/png;base64," + data
|
|
126
126
|
}
|
|
@@ -131,10 +131,9 @@ function clearResults() {
|
|
|
131
131
|
documentUIImage.src = "images/document.png"
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
function setCanRfid(data) {
|
|
135
|
-
var checkbox
|
|
136
|
-
|
|
137
|
-
var checkboxDescription = document.getElementById("rfid-checkbox-description")
|
|
134
|
+
function setCanRfid(data: boolean) {
|
|
135
|
+
var checkbox = document.getElementById('rfid-checkbox') as HTMLInputElement
|
|
136
|
+
var checkboxDescription = document.getElementById("rfid-checkbox-description")!
|
|
138
137
|
if (data) {
|
|
139
138
|
checkbox.disabled = false
|
|
140
139
|
checkboxDescription.innerHTML = "Process rfid reading"
|
|
@@ -147,9 +146,8 @@ function setCanRfid(data) {
|
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
148
|
|
|
150
|
-
function setScenarios(data) {
|
|
151
|
-
|
|
152
|
-
var scenariosContainer = document.getElementById("scenarios")
|
|
149
|
+
function setScenarios(data: DocReaderScenario[]) {
|
|
150
|
+
var scenariosContainer = document.getElementById("scenarios")!
|
|
153
151
|
|
|
154
152
|
data.forEach(scenario => {
|
|
155
153
|
var checked = selectedScenario == scenario.name ? "checked" : ""
|
|
@@ -161,11 +159,10 @@ function setScenarios(data) {
|
|
|
161
159
|
})
|
|
162
160
|
|
|
163
161
|
data.forEach(scenario => {
|
|
164
|
-
var element
|
|
165
|
-
|
|
166
|
-
var elementCaption = document.getElementById(scenario.name + "-caption")
|
|
162
|
+
var element = document.getElementById(scenario.name) as HTMLInputElement
|
|
163
|
+
var elementCaption = document.getElementById(scenario.name + "-caption")!
|
|
167
164
|
var onclick = () => {
|
|
168
|
-
selectedScenario = scenario.name
|
|
165
|
+
selectedScenario = scenario.name as Scenario
|
|
169
166
|
element.checked = true
|
|
170
167
|
}
|
|
171
168
|
element.onclick = onclick
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"android": "scripts/android.sh"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@regulaforensics/document-reader": "8.3.
|
|
9
|
+
"@regulaforensics/document-reader": "8.3.246-beta",
|
|
10
10
|
"@regulaforensics/document-reader-core-fullauthrfid": "8.3.9-beta",
|
|
11
11
|
"@regulaforensics/document-reader-btdevice": "8.3.10-beta",
|
|
12
12
|
"@awesome-cordova-plugins/file": "6.14.0",
|
|
@@ -5,7 +5,7 @@ export const useBtDevice = false
|
|
|
5
5
|
export const btDeviceName = "Regula 0000"
|
|
6
6
|
|
|
7
7
|
export function setupBTDevice() {
|
|
8
|
-
var connectButton = document.getElementById("connect")
|
|
8
|
+
var connectButton = document.getElementById("connect")!
|
|
9
9
|
connectButton.style.display = "flex"
|
|
10
10
|
connectButton.onclick = () => connect()
|
|
11
11
|
setStatus("Connect to a bluetooth device")
|
|
@@ -16,7 +16,7 @@ async function connect() {
|
|
|
16
16
|
if (await DocumentReader.instance.connectBluetoothDevice(btDeviceName)) {
|
|
17
17
|
await init()
|
|
18
18
|
DocumentReader.instance.functionality.useAuthenticator = true
|
|
19
|
-
document.getElementById("bt-device")
|
|
19
|
+
document.getElementById("bt-device")!.style.display = "none"
|
|
20
20
|
} else
|
|
21
21
|
setStatus("Failed to connect")
|
|
22
22
|
}
|
|
@@ -28,7 +28,7 @@ function setup() {
|
|
|
28
28
|
setProgress(-1)
|
|
29
29
|
currentProgress = -1
|
|
30
30
|
setShowing(true)
|
|
31
|
-
document.getElementById("cancel-rfid")
|
|
31
|
+
document.getElementById("cancel-rfid")!.onclick = () => stop()
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function stop() {
|
|
@@ -37,13 +37,13 @@ function stop() {
|
|
|
37
37
|
setShowing(false)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function setDescription(data) {
|
|
41
|
-
document.getElementById("rfid-description")
|
|
40
|
+
function setDescription(data: string) {
|
|
41
|
+
document.getElementById("rfid-description")!.innerHTML = data
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
var currentProgress = -1
|
|
45
|
-
function setProgress(next) {
|
|
46
|
-
var progress = document.getElementById("progress")
|
|
45
|
+
function setProgress(next: number) {
|
|
46
|
+
var progress = document.getElementById("progress")!
|
|
47
47
|
// make progress bar look better
|
|
48
48
|
if (next == 0) return // ignore idle 0s, leave progress at 100 while its not moving
|
|
49
49
|
if (next < currentProgress) next = 0 // move to 0 if progress finaly started moving
|
|
@@ -55,7 +55,7 @@ function setProgress(next) {
|
|
|
55
55
|
currentProgress = next
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
function setShowing(data) {
|
|
59
|
-
document.getElementById("main")
|
|
60
|
-
document.getElementById("custom-rfid")
|
|
58
|
+
function setShowing(data: boolean) {
|
|
59
|
+
document.getElementById("main")!.style.display = data ? "none" : "flex"
|
|
60
|
+
document.getElementById("custom-rfid")!.style.display = data ? "flex" : "none"
|
|
61
61
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario } from '@regulaforensics/document-reader'
|
|
1
|
+
import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario, Results, DocReaderException, DocReaderScenario } from '@regulaforensics/document-reader'
|
|
2
2
|
import { loadAsset, pickImage } from '../index'
|
|
3
3
|
import { initializeWithBTDevice, setupBTDevice, useBtDevice } from './extra/bt_device'
|
|
4
4
|
import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid'
|
|
5
5
|
|
|
6
6
|
var documentReader = DocumentReader.instance
|
|
7
|
-
var selectedScenario
|
|
7
|
+
var selectedScenario = Scenario.MRZ
|
|
8
8
|
var doRfid = false
|
|
9
9
|
var isReadingRfid = false
|
|
10
10
|
|
|
@@ -36,7 +36,7 @@ async function recognize() {
|
|
|
36
36
|
)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export function handleCompletion(action, results, error) {
|
|
39
|
+
export function handleCompletion(action: DocReaderAction, results: Results | null, error: DocReaderException | null) {
|
|
40
40
|
handleException(error)
|
|
41
41
|
if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
|
|
42
42
|
displayResults(results)
|
|
@@ -46,7 +46,7 @@ export function handleCompletion(action, results, error) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export async function displayResults(results) {
|
|
49
|
+
export async function displayResults(results: Results | null) {
|
|
50
50
|
isReadingRfid = false
|
|
51
51
|
clearResults()
|
|
52
52
|
if (results == null) return
|
|
@@ -65,7 +65,7 @@ var readRfid = () => {
|
|
|
65
65
|
documentReader.rfid(new RFIDConfig(handleCompletion))
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function shouldRfid(results) {
|
|
68
|
+
function shouldRfid(results: Results | null) {
|
|
69
69
|
return doRfid &&
|
|
70
70
|
!isReadingRfid &&
|
|
71
71
|
results != null && results.chipPage != 0
|
|
@@ -82,7 +82,7 @@ var initialize = async () => {
|
|
|
82
82
|
return success
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
export function handleException(error) {
|
|
85
|
+
export function handleException(error: DocReaderException | null) {
|
|
86
86
|
if (error != null) {
|
|
87
87
|
setStatus(error.message)
|
|
88
88
|
console.log(error.code + ": " + error.message)
|
|
@@ -91,13 +91,13 @@ export function handleException(error) {
|
|
|
91
91
|
|
|
92
92
|
// --------------------------------------------------------------------------------------------------------------------
|
|
93
93
|
|
|
94
|
-
var documentUIImage
|
|
95
|
-
var portraitUIImage
|
|
94
|
+
var documentUIImage: HTMLImageElement
|
|
95
|
+
var portraitUIImage: HTMLImageElement
|
|
96
96
|
export function main() {
|
|
97
|
-
documentUIImage = document.getElementById("document-image")
|
|
98
|
-
portraitUIImage = document.getElementById("portrait-image")
|
|
99
|
-
document.getElementById("scan")
|
|
100
|
-
document.getElementById("recognize")
|
|
97
|
+
documentUIImage = document.getElementById("document-image") as HTMLImageElement
|
|
98
|
+
portraitUIImage = document.getElementById("portrait-image") as HTMLImageElement
|
|
99
|
+
document.getElementById("scan")!.onclick = () => scan()
|
|
100
|
+
document.getElementById("recognize")!.onclick = () => recognize()
|
|
101
101
|
|
|
102
102
|
// custom rfid
|
|
103
103
|
if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
|
|
@@ -110,17 +110,17 @@ export function main() {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
export function setStatus(data) {
|
|
113
|
+
export function setStatus(data: string | null) {
|
|
114
114
|
if (data != null)
|
|
115
|
-
document.getElementById("status")
|
|
115
|
+
document.getElementById("status")!.innerHTML = data
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
function setPortrait(data) {
|
|
118
|
+
function setPortrait(data: string | null) {
|
|
119
119
|
if (data != null)
|
|
120
120
|
portraitUIImage.src = "data:image/png;base64," + data
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
function setDocImage(data) {
|
|
123
|
+
function setDocImage(data: string | null) {
|
|
124
124
|
if (data != null)
|
|
125
125
|
documentUIImage.src = "data:image/png;base64," + data
|
|
126
126
|
}
|
|
@@ -131,10 +131,9 @@ function clearResults() {
|
|
|
131
131
|
documentUIImage.src = "images/document.png"
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
function setCanRfid(data) {
|
|
135
|
-
var checkbox
|
|
136
|
-
|
|
137
|
-
var checkboxDescription = document.getElementById("rfid-checkbox-description")
|
|
134
|
+
function setCanRfid(data: boolean) {
|
|
135
|
+
var checkbox = document.getElementById('rfid-checkbox') as HTMLInputElement
|
|
136
|
+
var checkboxDescription = document.getElementById("rfid-checkbox-description")!
|
|
138
137
|
if (data) {
|
|
139
138
|
checkbox.disabled = false
|
|
140
139
|
checkboxDescription.innerHTML = "Process rfid reading"
|
|
@@ -147,9 +146,8 @@ function setCanRfid(data) {
|
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
148
|
|
|
150
|
-
function setScenarios(data) {
|
|
151
|
-
|
|
152
|
-
var scenariosContainer = document.getElementById("scenarios")
|
|
149
|
+
function setScenarios(data: DocReaderScenario[]) {
|
|
150
|
+
var scenariosContainer = document.getElementById("scenarios")!
|
|
153
151
|
|
|
154
152
|
data.forEach(scenario => {
|
|
155
153
|
var checked = selectedScenario == scenario.name ? "checked" : ""
|
|
@@ -161,11 +159,10 @@ function setScenarios(data) {
|
|
|
161
159
|
})
|
|
162
160
|
|
|
163
161
|
data.forEach(scenario => {
|
|
164
|
-
var element
|
|
165
|
-
|
|
166
|
-
var elementCaption = document.getElementById(scenario.name + "-caption")
|
|
162
|
+
var element = document.getElementById(scenario.name) as HTMLInputElement
|
|
163
|
+
var elementCaption = document.getElementById(scenario.name + "-caption")!
|
|
167
164
|
var onclick = () => {
|
|
168
|
-
selectedScenario = scenario.name
|
|
165
|
+
selectedScenario = scenario.name as Scenario
|
|
169
166
|
element.checked = true
|
|
170
167
|
}
|
|
171
168
|
element.onclick = onclick
|
|
@@ -16,7 +16,7 @@ const onMessage = (json: any) => {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const document = {
|
|
20
20
|
getElementById(id: string): any {
|
|
21
21
|
return new Proxy({}, {
|
|
22
22
|
set(_, prop: string, value) {
|
|
@@ -54,6 +54,7 @@ function parseValue(value: any) {
|
|
|
54
54
|
return value
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
(globalThis as any).document = document;
|
|
57
58
|
registerRootComponent(() =>
|
|
58
59
|
<WebView
|
|
59
60
|
ref={ref => { webViewRef = ref }}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"start": "expo start"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@regulaforensics/document-reader": "8.3.
|
|
11
|
+
"@regulaforensics/document-reader": "8.3.246-beta",
|
|
12
12
|
"@regulaforensics/document-reader-core-fullauthrfid": "8.3.9-beta",
|
|
13
13
|
"@regulaforensics/document-reader-btdevice": "8.3.10-beta",
|
|
14
14
|
"react-native": "0.79.5",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { document } from '../../index'
|
|
2
1
|
import { DocumentReader, InitConfig } from "@regulaforensics/document-reader"
|
|
3
2
|
import { handleException, init, setStatus } from "../main"
|
|
4
3
|
|
|
@@ -6,7 +5,7 @@ export const useBtDevice = false
|
|
|
6
5
|
export const btDeviceName = "Regula 0000"
|
|
7
6
|
|
|
8
7
|
export function setupBTDevice() {
|
|
9
|
-
var connectButton = document.getElementById("connect")
|
|
8
|
+
var connectButton = document.getElementById("connect")!
|
|
10
9
|
connectButton.style.display = "flex"
|
|
11
10
|
connectButton.onclick = () => connect()
|
|
12
11
|
setStatus("Connect to a bluetooth device")
|
|
@@ -17,7 +16,7 @@ async function connect() {
|
|
|
17
16
|
if (await DocumentReader.instance.connectBluetoothDevice(btDeviceName)) {
|
|
18
17
|
await init()
|
|
19
18
|
DocumentReader.instance.functionality.useAuthenticator = true
|
|
20
|
-
document.getElementById("bt-device")
|
|
19
|
+
document.getElementById("bt-device")!.style.display = "none"
|
|
21
20
|
} else
|
|
22
21
|
setStatus("Failed to connect")
|
|
23
22
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { document } from '../../index'
|
|
2
1
|
import { DocReaderAction, DocumentReader, RFIDConfig, RFIDDataFileType, RFIDNotificationCodes } from "@regulaforensics/document-reader"
|
|
3
2
|
import { displayResults, setStatus } from "../main"
|
|
4
3
|
|
|
@@ -29,7 +28,7 @@ function setup() {
|
|
|
29
28
|
setProgress(-1)
|
|
30
29
|
currentProgress = -1
|
|
31
30
|
setShowing(true)
|
|
32
|
-
document.getElementById("cancel-rfid")
|
|
31
|
+
document.getElementById("cancel-rfid")!.onclick = () => stop()
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
function stop() {
|
|
@@ -38,13 +37,13 @@ function stop() {
|
|
|
38
37
|
setShowing(false)
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
function setDescription(data) {
|
|
42
|
-
document.getElementById("rfid-description")
|
|
40
|
+
function setDescription(data: string) {
|
|
41
|
+
document.getElementById("rfid-description")!.innerHTML = data
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
var currentProgress = -1
|
|
46
|
-
function setProgress(next) {
|
|
47
|
-
var progress = document.getElementById("progress")
|
|
45
|
+
function setProgress(next: number) {
|
|
46
|
+
var progress = document.getElementById("progress")!
|
|
48
47
|
// make progress bar look better
|
|
49
48
|
if (next == 0) return // ignore idle 0s, leave progress at 100 while its not moving
|
|
50
49
|
if (next < currentProgress) next = 0 // move to 0 if progress finaly started moving
|
|
@@ -56,7 +55,7 @@ function setProgress(next) {
|
|
|
56
55
|
currentProgress = next
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
function setShowing(data) {
|
|
60
|
-
document.getElementById("main")
|
|
61
|
-
document.getElementById("custom-rfid")
|
|
58
|
+
function setShowing(data: boolean) {
|
|
59
|
+
document.getElementById("main")!.style.display = data ? "none" : "flex"
|
|
60
|
+
document.getElementById("custom-rfid")!.style.display = data ? "flex" : "none"
|
|
62
61
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario } from '@regulaforensics/document-reader'
|
|
1
|
+
import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario, Results, DocReaderException, DocReaderScenario } from '@regulaforensics/document-reader'
|
|
3
2
|
import { loadAsset, pickImage } from '../index'
|
|
4
3
|
import { initializeWithBTDevice, setupBTDevice, useBtDevice } from './extra/bt_device'
|
|
5
4
|
import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid'
|
|
6
5
|
|
|
7
6
|
var documentReader = DocumentReader.instance
|
|
8
|
-
var selectedScenario
|
|
7
|
+
var selectedScenario = Scenario.MRZ
|
|
9
8
|
var doRfid = false
|
|
10
9
|
var isReadingRfid = false
|
|
11
10
|
|
|
@@ -37,7 +36,7 @@ async function recognize() {
|
|
|
37
36
|
)
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
export function handleCompletion(action, results, error) {
|
|
39
|
+
export function handleCompletion(action: DocReaderAction, results: Results | null, error: DocReaderException | null) {
|
|
41
40
|
handleException(error)
|
|
42
41
|
if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
|
|
43
42
|
displayResults(results)
|
|
@@ -47,7 +46,7 @@ export function handleCompletion(action, results, error) {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
export async function displayResults(results) {
|
|
49
|
+
export async function displayResults(results: Results | null) {
|
|
51
50
|
isReadingRfid = false
|
|
52
51
|
clearResults()
|
|
53
52
|
if (results == null) return
|
|
@@ -66,7 +65,7 @@ var readRfid = () => {
|
|
|
66
65
|
documentReader.rfid(new RFIDConfig(handleCompletion))
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
function shouldRfid(results) {
|
|
68
|
+
function shouldRfid(results: Results | null) {
|
|
70
69
|
return doRfid &&
|
|
71
70
|
!isReadingRfid &&
|
|
72
71
|
results != null && results.chipPage != 0
|
|
@@ -83,7 +82,7 @@ var initialize = async () => {
|
|
|
83
82
|
return success
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
export function handleException(error) {
|
|
85
|
+
export function handleException(error: DocReaderException | null) {
|
|
87
86
|
if (error != null) {
|
|
88
87
|
setStatus(error.message)
|
|
89
88
|
console.log(error.code + ": " + error.message)
|
|
@@ -92,13 +91,13 @@ export function handleException(error) {
|
|
|
92
91
|
|
|
93
92
|
// --------------------------------------------------------------------------------------------------------------------
|
|
94
93
|
|
|
95
|
-
var documentUIImage
|
|
96
|
-
var portraitUIImage
|
|
94
|
+
var documentUIImage: HTMLImageElement
|
|
95
|
+
var portraitUIImage: HTMLImageElement
|
|
97
96
|
export function main() {
|
|
98
|
-
documentUIImage = document.getElementById("document-image")
|
|
99
|
-
portraitUIImage = document.getElementById("portrait-image")
|
|
100
|
-
document.getElementById("scan")
|
|
101
|
-
document.getElementById("recognize")
|
|
97
|
+
documentUIImage = document.getElementById("document-image") as HTMLImageElement
|
|
98
|
+
portraitUIImage = document.getElementById("portrait-image") as HTMLImageElement
|
|
99
|
+
document.getElementById("scan")!.onclick = () => scan()
|
|
100
|
+
document.getElementById("recognize")!.onclick = () => recognize()
|
|
102
101
|
|
|
103
102
|
// custom rfid
|
|
104
103
|
if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
|
|
@@ -111,17 +110,17 @@ export function main() {
|
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
|
|
114
|
-
export function setStatus(data) {
|
|
113
|
+
export function setStatus(data: string | null) {
|
|
115
114
|
if (data != null)
|
|
116
|
-
document.getElementById("status")
|
|
115
|
+
document.getElementById("status")!.innerHTML = data
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
function setPortrait(data) {
|
|
118
|
+
function setPortrait(data: string | null) {
|
|
120
119
|
if (data != null)
|
|
121
120
|
portraitUIImage.src = "data:image/png;base64," + data
|
|
122
121
|
}
|
|
123
122
|
|
|
124
|
-
function setDocImage(data) {
|
|
123
|
+
function setDocImage(data: string | null) {
|
|
125
124
|
if (data != null)
|
|
126
125
|
documentUIImage.src = "data:image/png;base64," + data
|
|
127
126
|
}
|
|
@@ -132,10 +131,9 @@ function clearResults() {
|
|
|
132
131
|
documentUIImage.src = "images/document.png"
|
|
133
132
|
}
|
|
134
133
|
|
|
135
|
-
function setCanRfid(data) {
|
|
136
|
-
var checkbox
|
|
137
|
-
|
|
138
|
-
var checkboxDescription = document.getElementById("rfid-checkbox-description")
|
|
134
|
+
function setCanRfid(data: boolean) {
|
|
135
|
+
var checkbox = document.getElementById('rfid-checkbox') as HTMLInputElement
|
|
136
|
+
var checkboxDescription = document.getElementById("rfid-checkbox-description")!
|
|
139
137
|
if (data) {
|
|
140
138
|
checkbox.disabled = false
|
|
141
139
|
checkboxDescription.innerHTML = "Process rfid reading"
|
|
@@ -148,9 +146,8 @@ function setCanRfid(data) {
|
|
|
148
146
|
}
|
|
149
147
|
}
|
|
150
148
|
|
|
151
|
-
function setScenarios(data) {
|
|
152
|
-
|
|
153
|
-
var scenariosContainer = document.getElementById("scenarios")
|
|
149
|
+
function setScenarios(data: DocReaderScenario[]) {
|
|
150
|
+
var scenariosContainer = document.getElementById("scenarios")!
|
|
154
151
|
|
|
155
152
|
data.forEach(scenario => {
|
|
156
153
|
var checked = selectedScenario == scenario.name ? "checked" : ""
|
|
@@ -162,11 +159,10 @@ function setScenarios(data) {
|
|
|
162
159
|
})
|
|
163
160
|
|
|
164
161
|
data.forEach(scenario => {
|
|
165
|
-
var element
|
|
166
|
-
|
|
167
|
-
var elementCaption = document.getElementById(scenario.name + "-caption")
|
|
162
|
+
var element = document.getElementById(scenario.name) as HTMLInputElement
|
|
163
|
+
var elementCaption = document.getElementById(scenario.name + "-caption")!
|
|
168
164
|
var onclick = () => {
|
|
169
|
-
selectedScenario = scenario.name
|
|
165
|
+
selectedScenario = scenario.name as Scenario
|
|
170
166
|
element.checked = true
|
|
171
167
|
}
|
|
172
168
|
element.onclick = onclick
|