@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,213 +0,0 @@
|
|
|
1
|
-
import { Component } from '@angular/core'
|
|
2
|
-
import { Platform } from '@ionic/angular'
|
|
3
|
-
import { File } from '@awesome-cordova-plugins/file'
|
|
4
|
-
import { Camera as CameraClass,DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera/ngx'
|
|
5
|
-
|
|
6
|
-
import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario } from '@regulaforensics/document-reader'
|
|
7
|
-
import { setupBTDevice, useBtDevice } from './extra/bt_device'
|
|
8
|
-
import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid'
|
|
9
|
-
|
|
10
|
-
var documentReader = DocumentReader.instance
|
|
11
|
-
var selectedScenario
|
|
12
|
-
var doRfid = false
|
|
13
|
-
var isReadingRfid = false
|
|
14
|
-
|
|
15
|
-
async function init() {
|
|
16
|
-
if (!await initialize()) return
|
|
17
|
-
setScenarios(documentReader.availableScenarios)
|
|
18
|
-
setCanRfid(await documentReader.isRFIDAvailableForUse())
|
|
19
|
-
setStatus("Ready")
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function scan() {
|
|
23
|
-
if (!await documentReader.isReady()) return
|
|
24
|
-
clearResults()
|
|
25
|
-
documentReader.startScanner(
|
|
26
|
-
ScannerConfig.withScenario(selectedScenario),
|
|
27
|
-
handleCompletion,
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async function recognize() {
|
|
32
|
-
if (!await documentReader.isReady()) return
|
|
33
|
-
var image = await pickImage()
|
|
34
|
-
if (image == null) return
|
|
35
|
-
|
|
36
|
-
clearResults()
|
|
37
|
-
documentReader.recognize(
|
|
38
|
-
RecognizeConfig.withScenario(selectedScenario, { image: image }),
|
|
39
|
-
handleCompletion,
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function handleCompletion(action, results, error) {
|
|
44
|
-
handleException(error)
|
|
45
|
-
if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
|
|
46
|
-
displayResults(results)
|
|
47
|
-
} else if (DocReaderAction.finished(action) && shouldRfid(results)) {
|
|
48
|
-
isReadingRfid = true
|
|
49
|
-
readRfid()
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export async function displayResults(results) {
|
|
54
|
-
isReadingRfid = false
|
|
55
|
-
clearResults()
|
|
56
|
-
if (results == null) return
|
|
57
|
-
|
|
58
|
-
var name = await results.textFieldValueByType(FieldType.SURNAME_AND_GIVEN_NAMES)
|
|
59
|
-
var docImage = await results.graphicFieldImageByType(GraphicFieldType.DOCUMENT_IMAGE)
|
|
60
|
-
var portrait = await results.graphicFieldImageByType(GraphicFieldType.PORTRAIT)
|
|
61
|
-
portrait = await results.graphicFieldImageByTypeSource(GraphicFieldType.PORTRAIT, ResultType.RFID_IMAGE_DATA) ?? portrait
|
|
62
|
-
|
|
63
|
-
setStatus(name)
|
|
64
|
-
setPortrait(portrait)
|
|
65
|
-
setDocImage(docImage)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
var readRfid = () => {
|
|
69
|
-
documentReader.rfid(new RFIDConfig(handleCompletion))
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function shouldRfid(results) {
|
|
73
|
-
return doRfid &&
|
|
74
|
-
!isReadingRfid &&
|
|
75
|
-
results != null && results.chipPage != 0
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async function initialize() {
|
|
79
|
-
setStatus("Initializing...")
|
|
80
|
-
|
|
81
|
-
var license = await loadAsset("regula.license")
|
|
82
|
-
var initConfig = new InitConfig(license)
|
|
83
|
-
var [success, error] = await documentReader.initialize(initConfig)
|
|
84
|
-
|
|
85
|
-
handleException(error)
|
|
86
|
-
return success
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function handleException(error) {
|
|
90
|
-
if (error != null) {
|
|
91
|
-
setStatus(error.message)
|
|
92
|
-
console.log(error.code + ": " + error.message)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// ui --------------------------------------------------------------------------------------------------------------------
|
|
97
|
-
|
|
98
|
-
export function setStatus(data) {
|
|
99
|
-
if (data != null)
|
|
100
|
-
document.getElementById("status").innerHTML = data
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function setPortrait(data) {
|
|
104
|
-
if (data != null)
|
|
105
|
-
portraitUIImage.src = "data:image/png;base64," + data
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function setDocImage(data) {
|
|
109
|
-
if (data != null)
|
|
110
|
-
documentUIImage.src = "data:image/png;base64," + data
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function clearResults() {
|
|
114
|
-
setStatus("Ready")
|
|
115
|
-
portraitUIImage.src = "images/portrait.png"
|
|
116
|
-
documentUIImage.src = "images/document.png"
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function setCanRfid(data) {
|
|
120
|
-
var checkbox // implicitly any, since cordova sample is pure js
|
|
121
|
-
checkbox = document.getElementById('rfid-checkbox')
|
|
122
|
-
var checkboxDescription = document.getElementById("rfid-checkbox-description")
|
|
123
|
-
if (data) {
|
|
124
|
-
checkbox.disabled = false
|
|
125
|
-
checkboxDescription.innerHTML = "Process rfid reading"
|
|
126
|
-
checkboxDescription.onclick = () => {
|
|
127
|
-
doRfid = !doRfid
|
|
128
|
-
checkbox.checked = doRfid
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// not equal --------------------------------------------------------------------------------------------------------------------
|
|
134
|
-
|
|
135
|
-
async function loadAsset(path: string): Promise<string> {
|
|
136
|
-
var dir = await File.resolveDirectoryUrl(File.applicationDirectory + "www/assets")
|
|
137
|
-
var fileEntry = await File.getFile(dir, path, null)
|
|
138
|
-
var result = await new Promise<string>((resolve, _) => {
|
|
139
|
-
fileEntry.file(file => {
|
|
140
|
-
var reader = new FileReader()
|
|
141
|
-
reader.onloadend = (_) => resolve(reader.result as string)
|
|
142
|
-
reader.readAsDataURL(file)
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
return result
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async function pickImage(): Promise<string | null> {
|
|
149
|
-
return await Camera.getPicture({
|
|
150
|
-
destinationType: DestinationType.DATA_URL,
|
|
151
|
-
mediaType: MediaType.PICTURE,
|
|
152
|
-
sourceType: PictureSourceType.PHOTOLIBRARY
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
var Camera: CameraClass
|
|
157
|
-
var documentUIImage
|
|
158
|
-
var portraitUIImage
|
|
159
|
-
@Component({
|
|
160
|
-
selector: 'app-root',
|
|
161
|
-
templateUrl: 'main.html',
|
|
162
|
-
styleUrl: 'main.css'
|
|
163
|
-
})
|
|
164
|
-
export class Main {
|
|
165
|
-
constructor(platform: Platform, camera: CameraClass) {
|
|
166
|
-
Camera = camera
|
|
167
|
-
platform.ready().then(() => {
|
|
168
|
-
documentUIImage = document.getElementById("document-image")
|
|
169
|
-
portraitUIImage = document.getElementById("portrait-image")
|
|
170
|
-
document.getElementById("scan").onclick = () => scan()
|
|
171
|
-
document.getElementById("recognize").onclick = () => recognize()
|
|
172
|
-
|
|
173
|
-
// custom rfid
|
|
174
|
-
if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
|
|
175
|
-
|
|
176
|
-
// bt device
|
|
177
|
-
if (!useBtDevice) init()
|
|
178
|
-
else setupBTDevice()
|
|
179
|
-
})
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// not resolved --------------------------------------------------------------------------------------------------------------------
|
|
184
|
-
|
|
185
|
-
function setScenarios(data) {
|
|
186
|
-
selectedScenario = Scenario.MRZ
|
|
187
|
-
const scenariosContainer = document.getElementById("scenarios")
|
|
188
|
-
data.forEach(scenario => scenariosContainer.appendChild(createScenarioElement(scenario)))
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function createScenarioElement(scenario) {
|
|
192
|
-
const div = document.createElement('div')
|
|
193
|
-
div.className = 'row radio'
|
|
194
|
-
|
|
195
|
-
const input = document.createElement('input')
|
|
196
|
-
input.type = 'radio'
|
|
197
|
-
input.name = 'scenario'
|
|
198
|
-
input.value = scenario.name
|
|
199
|
-
input.checked = scenario.name === selectedScenario
|
|
200
|
-
|
|
201
|
-
const span = document.createElement('span')
|
|
202
|
-
span.style.width = '200px'
|
|
203
|
-
span.style.paddingLeft = '5px'
|
|
204
|
-
span.textContent = scenario.caption
|
|
205
|
-
|
|
206
|
-
input.onclick = () => selectedScenario = scenario.name
|
|
207
|
-
span.onclick = () => input.click()
|
|
208
|
-
|
|
209
|
-
div.appendChild(input)
|
|
210
|
-
div.appendChild(span)
|
|
211
|
-
|
|
212
|
-
return div
|
|
213
|
-
}
|