@regulaforensics/document-reader 8.2.204-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 +2 -2
- package/android/build.gradle +2 -2
- package/android/cordova.gradle +2 -2
- package/android/src/main/java/com/regula/plugin/documentreader/Config.kt +3 -1
- package/examples/capacitor/README.md +10 -0
- package/examples/capacitor/index.html +2 -7
- package/examples/capacitor/index.tsx +39 -0
- package/examples/capacitor/package.json +3 -3
- package/examples/capacitor/scripts/setup.sh +4 -0
- package/examples/capacitor/src/extra/bt_device.tsx +8 -7
- package/examples/capacitor/src/extra/custom_rfid.tsx +8 -8
- package/examples/capacitor/src/main.css +4 -1
- package/examples/capacitor/src/main.html +1 -4
- package/examples/capacitor/src/main.tsx +58 -94
- package/examples/ionic/README.md +10 -0
- package/examples/ionic/config.xml +2 -0
- package/examples/ionic/index.tsx +54 -0
- package/examples/ionic/package.json +3 -3
- package/examples/ionic/src/extra/{bt_device.ts → bt_device.tsx} +8 -7
- package/examples/ionic/src/extra/{custom_rfid.ts → custom_rfid.tsx} +8 -8
- package/examples/ionic/src/main.css +4 -1
- package/examples/ionic/src/main.html +1 -4
- package/examples/ionic/src/main.tsx +171 -0
- package/examples/ionic/tsconfig.json +3 -2
- package/examples/react_native/README.md +10 -0
- package/examples/react_native/index.tsx +28 -5
- package/examples/react_native/package-lock.json +476 -421
- package/examples/react_native/package.json +10 -10
- package/examples/react_native/src/extra/bt_device.tsx +8 -8
- package/examples/react_native/src/extra/custom_rfid.tsx +8 -9
- package/examples/react_native/src/main.css +4 -1
- package/examples/react_native/src/main.html +1 -4
- package/examples/react_native/src/main.tsx +59 -84
- package/ios/RGLWConfig.m +2 -0
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/www/capacitor/index.js +16 -16
- package/www/capacitor/params/process_params/ProcessParams.js +7 -0
- package/www/cordova.js +23 -16
- package/www/react-native/index.js +16 -16
- package/www/react-native/params/process_params/ProcessParams.js +7 -0
- package/www/types/index.d.ts +8 -8
- package/www/types/params/process_params/ProcessParams.d.ts +4 -0
- 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 -12
- package/examples/cordova/config.xml +0 -30
- package/examples/cordova/package-lock.json +0 -1314
- package/examples/cordova/package.json +0 -32
- package/examples/cordova/scripts/android.sh +0 -8
- package/examples/cordova/scripts/ios.sh +0 -8
- package/examples/cordova/scripts/setup.sh +0 -8
- 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 -40
- package/examples/cordova/www/src/extra/bt_device.js +0 -31
- package/examples/cordova/www/src/extra/custom_rfid.js +0 -60
- package/examples/cordova/www/src/main.css +0 -131
- package/examples/cordova/www/src/main.html +0 -41
- package/examples/cordova/www/src/main.js +0 -202
- package/examples/ionic/index.ts +0 -16
- package/examples/ionic/src/main.ts +0 -213
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "document-reader",
|
|
3
|
-
"scripts": {
|
|
4
|
-
"setup": "scripts/setup.sh",
|
|
5
|
-
"ios": "scripts/ios.sh",
|
|
6
|
-
"android": "scripts/android.sh"
|
|
7
|
-
},
|
|
8
|
-
"dependencies": {
|
|
9
|
-
"@regulaforensics/document-reader": "8.2.204-beta",
|
|
10
|
-
"@regulaforensics/document-reader-core-fullauthrfid": "8.2.8-beta",
|
|
11
|
-
"@regulaforensics/document-reader-btdevice": "8.2.8-beta",
|
|
12
|
-
"cordova-ios": "7.1.1",
|
|
13
|
-
"cordova-android": "13.0.0",
|
|
14
|
-
"cordova-plugin-file": "8.1.3",
|
|
15
|
-
"cordova-plugin-camera": "8.0.0",
|
|
16
|
-
"cordova-plugin-dialogs": "2.0.2"
|
|
17
|
-
},
|
|
18
|
-
"cordova": {
|
|
19
|
-
"plugins": {
|
|
20
|
-
"@regulaforensics/document-reader": {},
|
|
21
|
-
"@regulaforensics/document-reader-core-fullauthrfid": {},
|
|
22
|
-
"@regulaforensics/document-reader-btdevice": {},
|
|
23
|
-
"cordova-plugin-file": {},
|
|
24
|
-
"cordova-plugin-camera": {},
|
|
25
|
-
"cordova-plugin-dialogs": {}
|
|
26
|
-
},
|
|
27
|
-
"platforms": [
|
|
28
|
-
"android",
|
|
29
|
-
"ios"
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
document.addEventListener('deviceready', () => {
|
|
2
|
-
// imports
|
|
3
|
-
window.DocumentReader = DocumentReaderPlugin.DocumentReader
|
|
4
|
-
DocReaderAction = DocumentReaderPlugin.DocReaderAction
|
|
5
|
-
FieldType = DocumentReaderPlugin.FieldType
|
|
6
|
-
GraphicFieldType = DocumentReaderPlugin.GraphicFieldType
|
|
7
|
-
InitConfig = DocumentReaderPlugin.InitConfig
|
|
8
|
-
RecognizeConfig = DocumentReaderPlugin.RecognizeConfig
|
|
9
|
-
ResultType = DocumentReaderPlugin.ResultType
|
|
10
|
-
RFIDConfig = DocumentReaderPlugin.RFIDConfig
|
|
11
|
-
ScannerConfig = DocumentReaderPlugin.ScannerConfig
|
|
12
|
-
Scenario = DocumentReaderPlugin.Scenario
|
|
13
|
-
RFIDDataFileType = DocumentReaderPlugin.RFIDDataFileType
|
|
14
|
-
RFIDNotificationCodes = DocumentReaderPlugin.RFIDNotificationCodes
|
|
15
|
-
|
|
16
|
-
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + 'www/src/main.html', (fileEntry) => {
|
|
17
|
-
fileEntry.file((file) => {
|
|
18
|
-
const reader = new FileReader()
|
|
19
|
-
reader.onloadend = async function () {
|
|
20
|
-
await loadModule('src/main.js')
|
|
21
|
-
await loadModule('src/extra/bt_device.js')
|
|
22
|
-
await loadModule('src/extra/custom_rfid.js')
|
|
23
|
-
|
|
24
|
-
document.getElementById('content').innerHTML = this.result
|
|
25
|
-
document.dispatchEvent(new CustomEvent("ready"))
|
|
26
|
-
}
|
|
27
|
-
reader.readAsText(file)
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
function loadModule(src) {
|
|
33
|
-
return new Promise((resolve) => {
|
|
34
|
-
const script = document.createElement('script');
|
|
35
|
-
script.type = 'module';
|
|
36
|
-
script.src = src;
|
|
37
|
-
script.onload = resolve;
|
|
38
|
-
document.body.appendChild(script);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { handleException, setStatus } from "../main.js"
|
|
2
|
-
|
|
3
|
-
export const useBtDevice = false
|
|
4
|
-
const btDeviceName = "Regula 0000"
|
|
5
|
-
|
|
6
|
-
export function setupBTDevice() {
|
|
7
|
-
document.getElementById("bt-device").style.display = "flex"
|
|
8
|
-
document.getElementById("connect").onclick = () => connect()
|
|
9
|
-
setStatus("Connect to a bluetooth device")
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async function connect() {
|
|
13
|
-
setStatus("Searching for devices...")
|
|
14
|
-
if (await DocumentReader.instance.connectBluetoothDevice(btDeviceName)) {
|
|
15
|
-
await initialize()
|
|
16
|
-
DocumentReader.instance.functionality.useAuthenticator = true
|
|
17
|
-
document.getElementById("bt-device").style.display = "none"
|
|
18
|
-
} else
|
|
19
|
-
setStatus("Failed to connect")
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function initialize() {
|
|
23
|
-
setStatus("Initializing...")
|
|
24
|
-
|
|
25
|
-
var initConfig = InitConfig.withBleDevice()
|
|
26
|
-
initConfig.delayedNNLoad = true
|
|
27
|
-
var [success, error] = await DocumentReader.instance.initialize(initConfig)
|
|
28
|
-
|
|
29
|
-
handleException(error)
|
|
30
|
-
return success
|
|
31
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { displayResults, setStatus } from "../main.js"
|
|
2
|
-
|
|
3
|
-
export const useRfidSelfHostedUI = false
|
|
4
|
-
|
|
5
|
-
export function rfidSelfHostedUI() {
|
|
6
|
-
var config = RFIDConfig.withoutUI((action, results, _) => {
|
|
7
|
-
if (DocReaderAction.stopped(action)) stop()
|
|
8
|
-
if (DocReaderAction.finished(action)) displayResults(results)
|
|
9
|
-
if (DocReaderAction.interrupted(action)) setStatus("Error reading RFID")
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
config.onProgress = async (notification) => {
|
|
13
|
-
if (notification.progress == 1) return
|
|
14
|
-
if (notification.notificationCode == RFIDNotificationCodes.PCSC_READING_DATAGROUP)
|
|
15
|
-
setDescription(await RFIDDataFileType.getTranslation(notification.dataFileType))
|
|
16
|
-
setStatus("Reading RFID")
|
|
17
|
-
setProgress(notification.progress)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
setup()
|
|
21
|
-
DocumentReader.instance.rfid(config)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function setup() {
|
|
25
|
-
setStatus("Reading RFID")
|
|
26
|
-
setDescription("Place your phone on top of the NFC tag")
|
|
27
|
-
setProgress(-1)
|
|
28
|
-
currentProgress = -1
|
|
29
|
-
setShowing(true)
|
|
30
|
-
document.getElementById("cancel-rfid").onclick = () => stop()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function stop() {
|
|
34
|
-
DocumentReader.instance.stopRFIDReader()
|
|
35
|
-
displayResults(null)
|
|
36
|
-
setShowing(false)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function setDescription(data) {
|
|
40
|
-
document.getElementById("rfid-description").innerHTML = data
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
var currentProgress = -1
|
|
44
|
-
function setProgress(next) {
|
|
45
|
-
var progress = document.getElementById("progress")
|
|
46
|
-
// make progress bar look better
|
|
47
|
-
if (next == 0) return // ignore idle 0s, leave progress at 100 while its not moving
|
|
48
|
-
if (next < currentProgress) next = 0 // move to 0 if progress finaly started moving
|
|
49
|
-
if (next >= 95) next = 100 // rfid never returns 100 and it looks ugly, fix it
|
|
50
|
-
if (next < currentProgress) progress.style.transition = 'none' // instantly reset progress
|
|
51
|
-
else progress.style.transition = 'width 0.5s' // smoothly increase progress
|
|
52
|
-
|
|
53
|
-
progress.style.width = next + "%"
|
|
54
|
-
currentProgress = next
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function setShowing(data) {
|
|
58
|
-
document.getElementById("main").style.display = data ? "none" : "flex"
|
|
59
|
-
document.getElementById("custom-rfid").style.display = data ? "flex" : "none"
|
|
60
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
html,
|
|
2
|
-
body {
|
|
3
|
-
width: 99%;
|
|
4
|
-
height: 99vh;
|
|
5
|
-
display: flex;
|
|
6
|
-
flex-direction: column;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.column {
|
|
10
|
-
display: flex;
|
|
11
|
-
flex-direction: column;
|
|
12
|
-
align-items: center;
|
|
13
|
-
justify-content: center;
|
|
14
|
-
width: 100%;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.row {
|
|
18
|
-
display: flex;
|
|
19
|
-
flex-direction: row;
|
|
20
|
-
align-items: center;
|
|
21
|
-
justify-content: center;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.header {
|
|
25
|
-
text-align: center;
|
|
26
|
-
padding-top: 80px;
|
|
27
|
-
margin-top: -10px;
|
|
28
|
-
background-color: rgba(0, 0, 0, 0.03);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.title {
|
|
32
|
-
font-weight: 600;
|
|
33
|
-
font-size: 18px;
|
|
34
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.divider {
|
|
38
|
-
height: 1px;
|
|
39
|
-
background-color: rgba(0, 0, 0, 0.075);
|
|
40
|
-
margin-top: 13px;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.scroll {
|
|
44
|
-
flex-grow: 1;
|
|
45
|
-
overflow-y: auto;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.no-scroll {
|
|
49
|
-
flex-grow: 1;
|
|
50
|
-
overflow-y: hidden;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.button {
|
|
54
|
-
width: 175px;
|
|
55
|
-
height: 40px;
|
|
56
|
-
margin: 5px;
|
|
57
|
-
margin-top: 10px;
|
|
58
|
-
background-color: #4285F4;
|
|
59
|
-
color: white;
|
|
60
|
-
border: none;
|
|
61
|
-
padding: 10px 20px;
|
|
62
|
-
font-size: 16px;
|
|
63
|
-
border-radius: 100px;
|
|
64
|
-
cursor: pointer;
|
|
65
|
-
transition: all 0.3s ease;
|
|
66
|
-
user-select: none;
|
|
67
|
-
-webkit-user-select: none;
|
|
68
|
-
-moz-user-select: none;
|
|
69
|
-
-ms-user-select: none;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.button:active {
|
|
73
|
-
position: relative;
|
|
74
|
-
top: 1px;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.text-button {
|
|
78
|
-
background: none;
|
|
79
|
-
border: none;
|
|
80
|
-
color: #2196f3;
|
|
81
|
-
font-size: 20px;
|
|
82
|
-
font-weight: bold;
|
|
83
|
-
padding: 5px;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.text-button:active {
|
|
87
|
-
position: relative;
|
|
88
|
-
top: 1px;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.radio {
|
|
92
|
-
align-items: baseline;
|
|
93
|
-
padding: 15px;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
input[type="checkbox"] {
|
|
97
|
-
width: 20px;
|
|
98
|
-
height: 20px;
|
|
99
|
-
border: 2px solid black;
|
|
100
|
-
background-color: white;
|
|
101
|
-
display: inline-block;
|
|
102
|
-
position: relative;
|
|
103
|
-
cursor: pointer;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
input[type="text"] {
|
|
107
|
-
width: 173px;
|
|
108
|
-
height: 40px;
|
|
109
|
-
font-size: 15px;
|
|
110
|
-
margin: 5px;
|
|
111
|
-
border-radius: 100px;
|
|
112
|
-
padding-left: 10px;
|
|
113
|
-
padding-right: 10px;
|
|
114
|
-
margin-top: 10px;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.progress-bar {
|
|
118
|
-
width: 75%;
|
|
119
|
-
padding: 3px;
|
|
120
|
-
margin-top: 40px;
|
|
121
|
-
background-color: #eee;
|
|
122
|
-
border-radius: 8px;
|
|
123
|
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
#progress {
|
|
127
|
-
width: 0%;
|
|
128
|
-
height: 20px;
|
|
129
|
-
background-color: #4285F4;
|
|
130
|
-
border-radius: 5px;
|
|
131
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<div class="column" style="height: 100%">
|
|
2
|
-
<div class="column header">
|
|
3
|
-
<span id="status" class="title">Loading...</span>
|
|
4
|
-
<div class="column divider"></div>
|
|
5
|
-
</div>
|
|
6
|
-
<div id="main" class="column no-scroll">
|
|
7
|
-
<div class="row">
|
|
8
|
-
<div class="column" style="padding: 5px;">
|
|
9
|
-
<p>Portrait</p>
|
|
10
|
-
<img id="portrait-image" src="images/portrait.png" height="160px" width="120px">
|
|
11
|
-
</div>
|
|
12
|
-
<div class="column" style="padding: 5px;">
|
|
13
|
-
<p>Document image</p>
|
|
14
|
-
<img id="document-image" src="images/document.png" height="160px" width="200px">
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
<div id="bt-device" class="row" style="display: none;">
|
|
18
|
-
<input type="text" placeholder="Regula 0000" />
|
|
19
|
-
<button id="connect" class="button">Connect</button>
|
|
20
|
-
</div>
|
|
21
|
-
<div id="scenario-container" class="column no-scroll" style="margin-top: 15px; background-color: rgba(0, 0, 0, 0.03);">
|
|
22
|
-
<div id="scenarios" class="scroll"></div>
|
|
23
|
-
</div>
|
|
24
|
-
<div class="row" style="width: 360px; padding-top: 15px;">
|
|
25
|
-
<span id="rfid-checkbox-description" style="font-size: 18px;width: 100%;">Process rfid reading(unavailable)</span>
|
|
26
|
-
<input id="rfid-checkbox" type="checkbox" style="margin-left: auto;" disabled />
|
|
27
|
-
</div>
|
|
28
|
-
<div class="row">
|
|
29
|
-
<button id="scan" class="button">Scan document</button>
|
|
30
|
-
<button id="recognize" class="button">Scan image</button>
|
|
31
|
-
</div>
|
|
32
|
-
<div style="padding-top: 20px;"></div>
|
|
33
|
-
</div>
|
|
34
|
-
<div id="custom-rfid" class="column no-scroll" style="display: none;">
|
|
35
|
-
<span id="rfid-description" style="font-size: 22px">Place your phone on top of the NFC tag</span>
|
|
36
|
-
<div class="progress-bar">
|
|
37
|
-
<div id="progress"></div>
|
|
38
|
-
</div>
|
|
39
|
-
<button id="cancel-rfid" class="text-button" style="margin-top: 50px;">X</button>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { setupBTDevice, useBtDevice } from './extra/bt_device.js'
|
|
2
|
-
import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid.js'
|
|
3
|
-
|
|
4
|
-
var documentReader = DocumentReader.instance
|
|
5
|
-
var selectedScenario
|
|
6
|
-
var doRfid = false
|
|
7
|
-
var isReadingRfid = false
|
|
8
|
-
|
|
9
|
-
async function init() {
|
|
10
|
-
if (!await initialize()) return
|
|
11
|
-
setScenarios(documentReader.availableScenarios)
|
|
12
|
-
setCanRfid(await documentReader.isRFIDAvailableForUse())
|
|
13
|
-
setStatus("Ready")
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function scan() {
|
|
17
|
-
if (!await documentReader.isReady()) return
|
|
18
|
-
clearResults()
|
|
19
|
-
documentReader.startScanner(
|
|
20
|
-
ScannerConfig.withScenario(selectedScenario),
|
|
21
|
-
handleCompletion,
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async function recognize() {
|
|
26
|
-
if (!await documentReader.isReady()) return
|
|
27
|
-
var image = await pickImage()
|
|
28
|
-
if (image == null) return
|
|
29
|
-
|
|
30
|
-
clearResults()
|
|
31
|
-
documentReader.recognize(
|
|
32
|
-
RecognizeConfig.withScenario(selectedScenario, { image: image }),
|
|
33
|
-
handleCompletion,
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function handleCompletion(action, results, error) {
|
|
38
|
-
handleException(error)
|
|
39
|
-
if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
|
|
40
|
-
displayResults(results)
|
|
41
|
-
} else if (DocReaderAction.finished(action) && shouldRfid(results)) {
|
|
42
|
-
isReadingRfid = true
|
|
43
|
-
readRfid()
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export async function displayResults(results) {
|
|
48
|
-
isReadingRfid = false
|
|
49
|
-
clearResults()
|
|
50
|
-
if (results == null) return
|
|
51
|
-
|
|
52
|
-
var name = await results.textFieldValueByType(FieldType.SURNAME_AND_GIVEN_NAMES)
|
|
53
|
-
var docImage = await results.graphicFieldImageByType(GraphicFieldType.DOCUMENT_IMAGE)
|
|
54
|
-
var portrait = await results.graphicFieldImageByType(GraphicFieldType.PORTRAIT)
|
|
55
|
-
portrait = await results.graphicFieldImageByTypeSource(GraphicFieldType.PORTRAIT, ResultType.RFID_IMAGE_DATA) ?? portrait
|
|
56
|
-
|
|
57
|
-
setStatus(name)
|
|
58
|
-
setPortrait(portrait)
|
|
59
|
-
setDocImage(docImage)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
var readRfid = () => {
|
|
63
|
-
documentReader.rfid(new RFIDConfig(handleCompletion))
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function shouldRfid(results) {
|
|
67
|
-
return doRfid &&
|
|
68
|
-
!isReadingRfid &&
|
|
69
|
-
results != null && results.chipPage != 0
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async function initialize() {
|
|
73
|
-
setStatus("Initializing...")
|
|
74
|
-
|
|
75
|
-
var license = await loadAsset("regula.license")
|
|
76
|
-
var initConfig = new InitConfig(license)
|
|
77
|
-
var [success, error] = await documentReader.initialize(initConfig)
|
|
78
|
-
|
|
79
|
-
handleException(error)
|
|
80
|
-
return success
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function handleException(error) {
|
|
84
|
-
if (error != null) {
|
|
85
|
-
setStatus(error.message)
|
|
86
|
-
console.log(error.code + ": " + error.message)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// ui --------------------------------------------------------------------------------------------------------------------
|
|
91
|
-
|
|
92
|
-
export function setStatus(data) {
|
|
93
|
-
if (data != null)
|
|
94
|
-
document.getElementById("status").innerHTML = data
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function setPortrait(data) {
|
|
98
|
-
if (data != null)
|
|
99
|
-
portraitUIImage.src = "data:image/png;base64," + data
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function setDocImage(data) {
|
|
103
|
-
if (data != null)
|
|
104
|
-
documentUIImage.src = "data:image/png;base64," + data
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function clearResults() {
|
|
108
|
-
setStatus("Ready")
|
|
109
|
-
portraitUIImage.src = "images/portrait.png"
|
|
110
|
-
documentUIImage.src = "images/document.png"
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function setCanRfid(data) {
|
|
114
|
-
var checkbox // implicitly any, since cordova sample is pure js
|
|
115
|
-
checkbox = document.getElementById('rfid-checkbox')
|
|
116
|
-
var checkboxDescription = document.getElementById("rfid-checkbox-description")
|
|
117
|
-
if (data) {
|
|
118
|
-
checkbox.disabled = false
|
|
119
|
-
checkboxDescription.innerHTML = "Process rfid reading"
|
|
120
|
-
checkboxDescription.onclick = () => {
|
|
121
|
-
doRfid = !doRfid
|
|
122
|
-
checkbox.checked = doRfid
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// not equal --------------------------------------------------------------------------------------------------------------------
|
|
128
|
-
|
|
129
|
-
async function loadAsset(path) {
|
|
130
|
-
path = cordova.file.applicationDirectory + "www/" + path
|
|
131
|
-
return new Promise((resolve, _) => {
|
|
132
|
-
window.resolveLocalFileSystemURL(path, (fileEntry) => {
|
|
133
|
-
fileEntry.file((file) => {
|
|
134
|
-
var reader = new FileReader()
|
|
135
|
-
reader.onloadend = function (_) { resolve(this.result) }
|
|
136
|
-
reader.readAsDataURL(file)
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
})
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function pickImage() {
|
|
143
|
-
return new Promise((resolve, _) => {
|
|
144
|
-
navigator.camera.getPicture(
|
|
145
|
-
(imageData) => resolve(imageData),
|
|
146
|
-
(_) => resolve(null),
|
|
147
|
-
{
|
|
148
|
-
destinationType: Camera.DestinationType.DATA_URL,
|
|
149
|
-
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
|
|
150
|
-
mediaType: Camera.MediaType.PICTURE
|
|
151
|
-
}
|
|
152
|
-
)
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
var documentUIImage
|
|
157
|
-
var portraitUIImage
|
|
158
|
-
document.addEventListener('ready', () => {
|
|
159
|
-
documentUIImage = document.getElementById("document-image")
|
|
160
|
-
portraitUIImage = document.getElementById("portrait-image")
|
|
161
|
-
document.getElementById("scan").onclick = () => scan()
|
|
162
|
-
document.getElementById("recognize").onclick = () => recognize()
|
|
163
|
-
|
|
164
|
-
// custom rfid
|
|
165
|
-
if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
|
|
166
|
-
|
|
167
|
-
// bt device
|
|
168
|
-
if (!useBtDevice) init()
|
|
169
|
-
else setupBTDevice()
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
// not resolved --------------------------------------------------------------------------------------------------------------------
|
|
173
|
-
|
|
174
|
-
function setScenarios(data) {
|
|
175
|
-
selectedScenario = Scenario.MRZ
|
|
176
|
-
const scenariosContainer = document.getElementById("scenarios")
|
|
177
|
-
data.forEach(scenario => scenariosContainer.appendChild(createScenarioElement(scenario)))
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function createScenarioElement(scenario) {
|
|
181
|
-
const div = document.createElement('div')
|
|
182
|
-
div.className = 'row radio'
|
|
183
|
-
|
|
184
|
-
const input = document.createElement('input')
|
|
185
|
-
input.type = 'radio'
|
|
186
|
-
input.name = 'scenario'
|
|
187
|
-
input.value = scenario.name
|
|
188
|
-
input.checked = scenario.name === selectedScenario
|
|
189
|
-
|
|
190
|
-
const span = document.createElement('span')
|
|
191
|
-
span.style.width = '200px'
|
|
192
|
-
span.style.paddingLeft = '5px'
|
|
193
|
-
span.textContent = scenario.caption
|
|
194
|
-
|
|
195
|
-
input.onclick = () => selectedScenario = scenario.name
|
|
196
|
-
span.onclick = () => input.click()
|
|
197
|
-
|
|
198
|
-
div.appendChild(input)
|
|
199
|
-
div.appendChild(span)
|
|
200
|
-
|
|
201
|
-
return div
|
|
202
|
-
}
|
package/examples/ionic/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import 'zone.js';
|
|
2
|
-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
|
3
|
-
import { BrowserModule } from '@angular/platform-browser'
|
|
4
|
-
import { IonicModule, Platform } from '@ionic/angular'
|
|
5
|
-
import { Camera } from '@awesome-cordova-plugins/camera/ngx'
|
|
6
|
-
import { Main } from './src/main'
|
|
7
|
-
import { NgModule } from '@angular/core'
|
|
8
|
-
|
|
9
|
-
@NgModule({
|
|
10
|
-
bootstrap: [Main],
|
|
11
|
-
providers: [Platform, Camera],
|
|
12
|
-
imports: [BrowserModule, IonicModule.forRoot()]
|
|
13
|
-
})
|
|
14
|
-
class MainModule { }
|
|
15
|
-
|
|
16
|
-
platformBrowserDynamic().bootstrapModule(MainModule)
|