@regulaforensics/ionic-native-document-reader 6.8.1 → 6.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regulaforensics/ionic-native-document-reader",
3
- "version": "6.8.1",
3
+ "version": "6.9.0",
4
4
  "description": "Ionic Native wrapper for cordova documentreader",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -16,9 +16,9 @@
16
16
  "@awesome-cordova-plugins/image-picker": "^5.36.0",
17
17
  "@ionic/react": "^6.0.0",
18
18
  "@ionic/react-router": "^6.0.0",
19
- "@regulaforensics/cordova-plugin-document-reader-api": "6.8.1",
20
- "@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "6.8.1",
21
- "@regulaforensics/ionic-native-document-reader": "6.8.1",
19
+ "@regulaforensics/cordova-plugin-document-reader-api": "6.9.0",
20
+ "@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "6.9.0",
21
+ "@regulaforensics/ionic-native-document-reader": "6.9.0",
22
22
  "@testing-library/jest-dom": "^5.11.9",
23
23
  "@testing-library/react": "^11.2.5",
24
24
  "@testing-library/user-event": "^12.6.3",
@@ -1,10 +1,11 @@
1
- import { IonPage, isPlatform } from '@ionic/react';
2
- import { DocumentReader, DocumentReaderScenario, Enum, DocumentReaderCompletion, DocumentReaderResults, DocumentReaderNotification } from '@regulaforensics/ionic-native-document-reader';
3
- import React from "react";
1
+ import { IonPage, isPlatform } from '@ionic/react'
2
+ import { DocumentReader, DocumentReaderScenario, Enum, DocumentReaderCompletion, DocumentReaderResults, DocumentReaderNotification, ScannerConfig, RecognizeConfig } from '@regulaforensics/ionic-native-document-reader'
3
+ import React from "react"
4
4
  import { DirectoryEntry, Entry, File, FileEntry, IFile } from '@awesome-cordova-plugins/file'
5
5
  import { AndroidPermissions } from "@awesome-cordova-plugins/android-permissions"
6
6
  import { ImagePicker } from "@awesome-cordova-plugins/image-picker"
7
7
 
8
+ var selectedScenario = "Mrz"
8
9
  var doRfid: boolean = false
9
10
  var isReadingRfidCustomUi: boolean = false
10
11
  var isReadingRfid: boolean = false
@@ -43,7 +44,7 @@ cancelButtonRef.addEventListener("click", stopRfid)
43
44
  updateUI()
44
45
  status.innerHTML = "loading......"
45
46
  status.style.backgroundColor = "grey"
46
- document.addEventListener("deviceready", onDeviceReady, false);
47
+ document.addEventListener("deviceready", onDeviceReady, false)
47
48
 
48
49
  function onDeviceReady() {
49
50
  readFile("public/assets", "regula.license", (license: any) => {
@@ -112,7 +113,8 @@ function stopRfid() {
112
113
  }
113
114
 
114
115
  function handleCompletion(completion?: DocumentReaderCompletion) {
115
- if (completion == undefined) return;
116
+ if (completion == undefined) return
117
+ console.log("DocReaderAction: " + completion.action)
116
118
  if (isReadingRfidCustomUi && (completion.action === Enum.DocReaderAction.CANCEL || completion.action === Enum.DocReaderAction.ERROR))
117
119
  hideRfidUI()
118
120
  if (isReadingRfidCustomUi && completion.action === Enum.DocReaderAction.NOTIFICATION)
@@ -156,14 +158,14 @@ function restartRfidUI() {
156
158
  }
157
159
 
158
160
  function updateRfidUI(notification: DocumentReaderNotification) {
159
- if (notification.code === Enum.eRFID_NotificationCodes.RFID_NOTIFICATION_PCSC_READING_DATAGROUP)
161
+ if (notification.notificationCode === Enum.eRFID_NotificationCodes.RFID_NOTIFICATION_PCSC_READING_DATAGROUP)
160
162
  rfidDescription = notification.dataFileType!.toString()
161
163
  rfidUIHeader = "Reading RFID"
162
164
  rfidUIHeaderColor = "black"
163
- rfidProgress = notification.value!
165
+ rfidProgress = notification.progress!
164
166
  updateUI()
165
167
  if (isPlatform("ios"))
166
- DocumentReader.setRfidSessionStatus(rfidDescription + "\n" + notification.value + "%")
168
+ DocumentReader.setRfidSessionStatus(rfidDescription + "\n" + notification.progress + "%")
167
169
  }
168
170
 
169
171
  function customRFID() {
@@ -235,7 +237,7 @@ function postInitialize(scenarios: Array<any>, canRfid: boolean) {
235
237
  input.value = (DocumentReaderScenario.fromJson(typeof index === "string" ? JSON.parse(index) : index)!.name)!
236
238
  if (index == 0)
237
239
  input.checked = true
238
- input.onclick = () => DocumentReader.setConfig({ processParams: { scenario: DocumentReaderScenario.fromJson(typeof index === "string" ? JSON.parse(index) : index)!.name } })
240
+ input.onclick = () => selectedScenario = DocumentReaderScenario.fromJson(typeof index === "string" ? JSON.parse(index) : index)!.name!
239
241
  input.style.display = "inline-block"
240
242
  }
241
243
  for (let input of inputs) {
@@ -295,7 +297,9 @@ function clearResults() {
295
297
  }
296
298
 
297
299
  function scan() {
298
- DocumentReader.showScanner().subscribe((m: string) =>
300
+ var config = new ScannerConfig()
301
+ config.scenario = selectedScenario
302
+ DocumentReader.scan(config).subscribe((m: string) =>
299
303
  handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m))))
300
304
  }
301
305
 
@@ -310,7 +314,10 @@ function recognize() {
310
314
  status.innerHTML = "processing image......"
311
315
  status.style.backgroundColor = "grey"
312
316
  let fileString = (file as string)
313
- DocumentReader.recognizeImage(fileString.substring(fileString.indexOf(",") + 1)).subscribe((m: string) =>
317
+ var config = new RecognizeConfig()
318
+ config.scenario = selectedScenario
319
+ config.image = fileString.substring(fileString.indexOf(",") + 1)
320
+ DocumentReader.recognize(config).subscribe((m: string) =>
314
321
  handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m))))
315
322
  })).catch(error2)
316
323
  }, error2)
@@ -334,7 +341,7 @@ const Home: React.FC = () => {
334
341
  return (
335
342
  <IonPage>
336
343
  </IonPage>
337
- );
338
- };
344
+ )
345
+ }
339
346
 
340
- export default Home;
347
+ export default Home