@regulaforensics/document-reader 9.9.1155-beta → 9.9.1162-rc
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 +1 -3
- package/RNDocumentReader.podspec +21 -0
- package/android/CVDDocumentReader.kt +3 -4
- package/android/build.gradle +36 -0
- package/android/cordova.gradle +12 -0
- package/android/src/main/kotlin/com/regula/plugin/{document/reader → documentreader}/BluetoothUtil.kt +1 -1
- package/android/src/main/kotlin/com/regula/plugin/{document/reader → documentreader}/Config.kt +3 -3
- package/android/src/main/kotlin/com/regula/plugin/{document/reader → documentreader}/JSONConstructor.kt +4 -4
- package/android/src/main/kotlin/com/regula/plugin/{document/reader → documentreader}/Main.kt +3 -3
- package/android/src/main/kotlin/com/regula/plugin/{document/reader → documentreader}/RNDocumentReaderModule.kt +3 -4
- package/android/src/main/kotlin/com/regula/plugin/{document/reader → documentreader}/Utils.kt +1 -1
- package/app.plugin.js +7 -10
- package/examples/capacitor/README.md +0 -2
- package/examples/capacitor/android/app/build.gradle +10 -1
- package/examples/capacitor/android/app/src/main/AndroidManifest.xml +0 -9
- package/examples/capacitor/android/build.gradle +3 -12
- package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/examples/capacitor/android/gradle.properties +0 -4
- package/examples/capacitor/android/gradlew +7 -4
- package/examples/capacitor/android/gradlew.bat +24 -12
- package/examples/capacitor/android/variables.gradle +9 -13
- package/examples/capacitor/index.tsx +23 -15
- package/examples/capacitor/ios/App/App/AppDelegate.swift +40 -5
- package/examples/capacitor/ios/App/App/Info.plist +2 -19
- package/examples/capacitor/ios/App/App.xcodeproj/project.pbxproj +86 -30
- package/examples/capacitor/package.json +18 -13
- package/examples/capacitor/scripts/android.sh +8 -5
- package/examples/capacitor/scripts/ios.sh +7 -5
- package/examples/capacitor/scripts/setup.sh +7 -2
- package/examples/capacitor/src/main.css +0 -5
- package/examples/capacitor/vite.config.ts +12 -0
- package/examples/ionic/README.md +0 -2
- package/examples/ionic/config.xml +1 -1
- package/examples/ionic/index.tsx +3 -8
- package/examples/ionic/package-lock.json +7536 -6029
- package/examples/ionic/package.json +33 -24
- package/examples/ionic/scripts/android.sh +2 -0
- package/examples/ionic/scripts/ios.sh +2 -0
- package/examples/ionic/scripts/setup.sh +2 -0
- package/examples/ionic/tsconfig.json +1 -0
- package/examples/react_native/README.md +0 -2
- package/examples/react_native/app.config.ts +2 -1
- package/examples/react_native/package-lock.json +4015 -2002
- package/examples/react_native/package.json +19 -14
- package/examples/react_native/scripts/android.sh +3 -3
- package/examples/react_native/scripts/ios.sh +3 -3
- package/examples/react_native/scripts/setup.sh +3 -4
- package/examples/react_native/vendor/image-size-metro-compat/index.cjs +16 -0
- package/examples/react_native/vendor/image-size-metro-compat/package.json +8 -0
- package/package.json +1 -1
- package/plugin.xml +12 -12
- package/test/package-lock.json +1 -1
- package/Package.swift +0 -28
- package/android/build.gradle.kts +0 -37
- package/android/cordova.gradle.kts +0 -13
- package/examples/capacitor/android/app/src/main/res/xml/file_paths.xml +0 -5
- package/examples/capacitor/capacitor.config.json +0 -15
- package/examples/capacitor/ios/App/App/SceneDelegate.swift +0 -23
- package/examples/capacitor/ios/App/CapApp-SPM/Sources/CapApp-SPM/CapApp-SPM.swift +0 -1
- package/examples/capacitor-cocoapods/README.md +0 -22
- package/examples/capacitor-cocoapods/android/app/build.gradle +0 -50
- package/examples/capacitor-cocoapods/android/app/proguard-rules.pro +0 -21
- package/examples/capacitor-cocoapods/android/app/src/main/AndroidManifest.xml +0 -27
- package/examples/capacitor-cocoapods/android/app/src/main/assets/Regula/.gitkeep +0 -0
- package/examples/capacitor-cocoapods/android/app/src/main/java/com/regula/example/dr/capacitor/MainActivity.java +0 -5
- package/examples/capacitor-cocoapods/android/app/src/main/res/drawable/ic_launcher.png +0 -0
- package/examples/capacitor-cocoapods/android/app/src/main/res/drawable/ic_launcher_foreground.png +0 -0
- package/examples/capacitor-cocoapods/android/app/src/main/res/drawable/ic_launcher_round.png +0 -0
- package/examples/capacitor-cocoapods/android/app/src/main/res/drawable/launcher.xml +0 -4
- package/examples/capacitor-cocoapods/android/app/src/main/res/drawable/launcher_round.xml +0 -4
- package/examples/capacitor-cocoapods/android/app/src/main/res/drawable/splash.png +0 -0
- package/examples/capacitor-cocoapods/android/app/src/main/res/layout/activity_main.xml +0 -12
- package/examples/capacitor-cocoapods/android/app/src/main/res/values/styles.xml +0 -22
- package/examples/capacitor-cocoapods/android/build.gradle +0 -30
- package/examples/capacitor-cocoapods/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/examples/capacitor-cocoapods/android/gradle/wrapper/gradle-wrapper.properties +0 -7
- package/examples/capacitor-cocoapods/android/gradle.properties +0 -22
- package/examples/capacitor-cocoapods/android/gradlew +0 -251
- package/examples/capacitor-cocoapods/android/gradlew.bat +0 -94
- package/examples/capacitor-cocoapods/android/settings.gradle +0 -5
- package/examples/capacitor-cocoapods/android/variables.gradle +0 -16
- package/examples/capacitor-cocoapods/index.html +0 -5
- package/examples/capacitor-cocoapods/index.tsx +0 -39
- package/examples/capacitor-cocoapods/ios/App/App/App.entitlements +0 -10
- package/examples/capacitor-cocoapods/ios/App/App/AppDelegate.swift +0 -49
- package/examples/capacitor-cocoapods/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png +0 -0
- package/examples/capacitor-cocoapods/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -14
- package/examples/capacitor-cocoapods/ios/App/App/Assets.xcassets/Contents.json +0 -6
- package/examples/capacitor-cocoapods/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json +0 -23
- package/examples/capacitor-cocoapods/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png +0 -0
- package/examples/capacitor-cocoapods/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png +0 -0
- package/examples/capacitor-cocoapods/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png +0 -0
- package/examples/capacitor-cocoapods/ios/App/App/Base.lproj/LaunchScreen.storyboard +0 -32
- package/examples/capacitor-cocoapods/ios/App/App/Info.plist +0 -69
- package/examples/capacitor-cocoapods/ios/App/App.xcodeproj/project.pbxproj +0 -430
- package/examples/capacitor-cocoapods/ios/App/App.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/examples/capacitor-cocoapods/package.json +0 -30
- package/examples/capacitor-cocoapods/public/assets/.gitkeep +0 -0
- package/examples/capacitor-cocoapods/public/images/document.png +0 -0
- package/examples/capacitor-cocoapods/public/images/portrait.png +0 -0
- package/examples/capacitor-cocoapods/scripts/android.sh +0 -11
- package/examples/capacitor-cocoapods/scripts/ios.sh +0 -10
- package/examples/capacitor-cocoapods/scripts/setup.sh +0 -14
- package/examples/capacitor-cocoapods/src/extra/bt_device.tsx +0 -33
- package/examples/capacitor-cocoapods/src/extra/custom_rfid.tsx +0 -61
- package/examples/capacitor-cocoapods/src/main.css +0 -148
- package/examples/capacitor-cocoapods/src/main.html +0 -38
- package/examples/capacitor-cocoapods/src/main.tsx +0 -172
- package/examples/capacitor-cocoapods/tsconfig.json +0 -5
- package/examples/capacitor-cocoapods/vite.config.ts +0 -17
- package/examples/ionic-cocoapods/README.md +0 -22
- package/examples/ionic-cocoapods/angular.json +0 -39
- package/examples/ionic-cocoapods/assets/.gitkeep +0 -0
- package/examples/ionic-cocoapods/config.xml +0 -63
- package/examples/ionic-cocoapods/images/document.png +0 -0
- package/examples/ionic-cocoapods/images/icon.png +0 -0
- package/examples/ionic-cocoapods/images/portrait.png +0 -0
- package/examples/ionic-cocoapods/index.html +0 -19
- package/examples/ionic-cocoapods/index.tsx +0 -58
- package/examples/ionic-cocoapods/ionic.config.json +0 -7
- package/examples/ionic-cocoapods/package-lock.json +0 -16579
- package/examples/ionic-cocoapods/package.json +0 -58
- package/examples/ionic-cocoapods/scripts/android.sh +0 -8
- package/examples/ionic-cocoapods/scripts/ios.sh +0 -8
- package/examples/ionic-cocoapods/scripts/setup.sh +0 -8
- package/examples/ionic-cocoapods/src/extra/bt_device.tsx +0 -33
- package/examples/ionic-cocoapods/src/extra/custom_rfid.tsx +0 -61
- package/examples/ionic-cocoapods/src/main.css +0 -148
- package/examples/ionic-cocoapods/src/main.html +0 -38
- package/examples/ionic-cocoapods/src/main.tsx +0 -172
- package/examples/ionic-cocoapods/tsconfig.json +0 -14
- package/ios/module.modulemap +0 -7
- package/react-native-document-reader.podspec +0 -14
- /package/examples/{capacitor-cocoapods → capacitor}/android/app/capacitor.build.gradle +0 -0
- /package/examples/{capacitor-cocoapods → capacitor}/android/capacitor.settings.gradle +0 -0
- /package/examples/{capacitor-cocoapods → capacitor}/ionic.config.json +0 -0
- /package/examples/{capacitor-cocoapods → capacitor}/ios/App/App/Base.lproj/Main.storyboard +0 -0
- /package/examples/{capacitor-cocoapods → capacitor}/ios/App/App.xcworkspace/contents.xcworkspacedata +0 -0
- /package/examples/{capacitor-cocoapods → capacitor}/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- /package/examples/{capacitor-cocoapods → capacitor}/ios/App/Podfile +0 -0
- /package/examples/{capacitor-cocoapods → capacitor}/ios/App/Podfile.lock +0 -0
- /package/examples/{capacitor-cocoapods → capacitor}/package-lock.json +0 -0
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
html,
|
|
2
|
-
body {
|
|
3
|
-
margin: 0;
|
|
4
|
-
width: 100%;
|
|
5
|
-
height: 99vh;
|
|
6
|
-
display: flex;
|
|
7
|
-
overflow: hidden;
|
|
8
|
-
flex-direction: column;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/* Prevent text selection */
|
|
12
|
-
* {
|
|
13
|
-
user-select: none !important;
|
|
14
|
-
-webkit-user-select: none !important;
|
|
15
|
-
-webkit-user-drag: none !important;
|
|
16
|
-
-webkit-touch-callout: none !important;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.column {
|
|
20
|
-
display: flex;
|
|
21
|
-
flex-direction: column;
|
|
22
|
-
align-items: center;
|
|
23
|
-
justify-content: center;
|
|
24
|
-
width: 100%;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.row {
|
|
28
|
-
display: flex;
|
|
29
|
-
flex-direction: row;
|
|
30
|
-
align-items: center;
|
|
31
|
-
justify-content: center;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.header {
|
|
35
|
-
text-align: center;
|
|
36
|
-
padding-top: 80px;
|
|
37
|
-
margin-top: -10px;
|
|
38
|
-
background-color: rgba(0, 0, 0, 0.03);
|
|
39
|
-
font-weight: 600;
|
|
40
|
-
font-size: 18px;
|
|
41
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.sub-header {
|
|
45
|
-
background-color: rgba(0, 0, 0, 0.03);
|
|
46
|
-
width: 100%;
|
|
47
|
-
padding-top: 13px;
|
|
48
|
-
text-align: center;
|
|
49
|
-
font-weight: 550;
|
|
50
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.divider {
|
|
54
|
-
height: 1px;
|
|
55
|
-
background-color: rgba(0, 0, 0, 0.075);
|
|
56
|
-
margin-top: 13px;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.scroll {
|
|
60
|
-
flex-grow: 1;
|
|
61
|
-
overflow-y: auto;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.no-scroll {
|
|
65
|
-
flex-grow: 1;
|
|
66
|
-
overflow-y: hidden;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.button {
|
|
70
|
-
width: 175px;
|
|
71
|
-
height: 40px;
|
|
72
|
-
margin: 5px;
|
|
73
|
-
margin-top: 10px;
|
|
74
|
-
background-color: #4285F4;
|
|
75
|
-
color: white;
|
|
76
|
-
border: none;
|
|
77
|
-
padding: 10px 20px;
|
|
78
|
-
justify-content: center;
|
|
79
|
-
font-size: 16px;
|
|
80
|
-
border-radius: 100px;
|
|
81
|
-
cursor: pointer;
|
|
82
|
-
transition: all 0.3s ease;
|
|
83
|
-
user-select: none;
|
|
84
|
-
-webkit-user-select: none;
|
|
85
|
-
-moz-user-select: none;
|
|
86
|
-
-ms-user-select: none;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.button:active {
|
|
90
|
-
position: relative;
|
|
91
|
-
top: 1px;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.text-button {
|
|
95
|
-
background: none;
|
|
96
|
-
border: none;
|
|
97
|
-
color: #2196f3;
|
|
98
|
-
font-size: 20px;
|
|
99
|
-
font-weight: bold;
|
|
100
|
-
padding: 5px;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.text-button:active {
|
|
104
|
-
position: relative;
|
|
105
|
-
top: 1px;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.radio {
|
|
109
|
-
align-items: baseline;
|
|
110
|
-
padding: 15px;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
input[type="checkbox"] {
|
|
114
|
-
width: 20px;
|
|
115
|
-
height: 20px;
|
|
116
|
-
border: 2px solid black;
|
|
117
|
-
background-color: white;
|
|
118
|
-
display: inline-block;
|
|
119
|
-
position: relative;
|
|
120
|
-
cursor: pointer;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
input[type="text"] {
|
|
124
|
-
width: 173px;
|
|
125
|
-
height: 40px;
|
|
126
|
-
font-size: 15px;
|
|
127
|
-
margin: 5px;
|
|
128
|
-
border-radius: 100px;
|
|
129
|
-
padding-left: 10px;
|
|
130
|
-
padding-right: 10px;
|
|
131
|
-
margin-top: 10px;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.progress-bar {
|
|
135
|
-
width: 75%;
|
|
136
|
-
padding: 3px;
|
|
137
|
-
margin-top: 40px;
|
|
138
|
-
background-color: #eee;
|
|
139
|
-
border-radius: 8px;
|
|
140
|
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
#progress {
|
|
144
|
-
width: 0%;
|
|
145
|
-
height: 20px;
|
|
146
|
-
background-color: #4285F4;
|
|
147
|
-
border-radius: 5px;
|
|
148
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<div class="column" style="height: 100%">
|
|
2
|
-
<div class="column header">
|
|
3
|
-
<span id="status">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="scenario-container" class="column no-scroll" style="margin-top: 15px; background-color: rgba(0, 0, 0, 0.03);">
|
|
18
|
-
<div id="scenarios" class="scroll"></div>
|
|
19
|
-
</div>
|
|
20
|
-
<div class="row" style="width: 360px; padding-top: 15px;">
|
|
21
|
-
<span id="rfid-checkbox-description" style="font-size: 18px;width: 100%;">Process rfid reading(unavailable)</span>
|
|
22
|
-
<input id="rfid-checkbox" type="checkbox" style="margin-left: auto;" disabled />
|
|
23
|
-
</div>
|
|
24
|
-
<div class="row">
|
|
25
|
-
<button id="scan" class="button">Scan document</button>
|
|
26
|
-
<button id="recognize" class="button">Scan image</button>
|
|
27
|
-
</div>
|
|
28
|
-
<button id="connect" class="button" style="width: 360px; display: none;">Connect</button>
|
|
29
|
-
<div style="padding-top: 20px;"></div>
|
|
30
|
-
</div>
|
|
31
|
-
<div id="custom-rfid" class="column no-scroll" style="display: none;">
|
|
32
|
-
<span id="rfid-description" style="font-size: 22px">Place your phone on top of the NFC tag</span>
|
|
33
|
-
<div class="progress-bar">
|
|
34
|
-
<div id="progress"></div>
|
|
35
|
-
</div>
|
|
36
|
-
<button id="cancel-rfid" class="text-button" style="margin-top: 50px; padding-bottom: 100px;">X</button>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario, Results, DocReaderException, DocReaderScenario } from '@regulaforensics/document-reader'
|
|
2
|
-
import { loadAsset, pickImage } from '../index'
|
|
3
|
-
import { initializeWithBTDevice, setupBTDevice, useBtDevice } from './extra/bt_device'
|
|
4
|
-
import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid'
|
|
5
|
-
|
|
6
|
-
var documentReader = DocumentReader.instance
|
|
7
|
-
var selectedScenario = Scenario.MRZ
|
|
8
|
-
var doRfid = false
|
|
9
|
-
var isReadingRfid = false
|
|
10
|
-
|
|
11
|
-
export async function init() {
|
|
12
|
-
if (!await initialize()) return
|
|
13
|
-
setScenarios(documentReader.availableScenarios)
|
|
14
|
-
setCanRfid(await documentReader.isRFIDAvailableForUse())
|
|
15
|
-
setStatus("Ready")
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async function scan() {
|
|
19
|
-
if (!await documentReader.isReady()) return
|
|
20
|
-
clearResults()
|
|
21
|
-
documentReader.startScanner(
|
|
22
|
-
ScannerConfig.withScenario(selectedScenario),
|
|
23
|
-
handleCompletion,
|
|
24
|
-
)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async function recognize() {
|
|
28
|
-
if (!await documentReader.isReady()) return
|
|
29
|
-
var image = await pickImage()
|
|
30
|
-
if (image == null) return
|
|
31
|
-
|
|
32
|
-
clearResults()
|
|
33
|
-
documentReader.recognize(
|
|
34
|
-
RecognizeConfig.withScenario(selectedScenario, { image: image }),
|
|
35
|
-
handleCompletion,
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function handleCompletion(action: DocReaderAction, results: Results | null, error: DocReaderException | null) {
|
|
40
|
-
handleException(error)
|
|
41
|
-
if (DocReaderAction.stopped(action) && !shouldRfid(results)) {
|
|
42
|
-
displayResults(results)
|
|
43
|
-
} else if (DocReaderAction.finished(action) && shouldRfid(results)) {
|
|
44
|
-
isReadingRfid = true
|
|
45
|
-
readRfid()
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export async function displayResults(results: Results | null) {
|
|
50
|
-
isReadingRfid = false
|
|
51
|
-
clearResults()
|
|
52
|
-
if (results == null) return
|
|
53
|
-
|
|
54
|
-
var name = await results.textFieldValueByType(FieldType.SURNAME_AND_GIVEN_NAMES)
|
|
55
|
-
var docImage = await results.graphicFieldImageByType(GraphicFieldType.DOCUMENT_IMAGE)
|
|
56
|
-
var portrait = await results.graphicFieldImageByType(GraphicFieldType.PORTRAIT)
|
|
57
|
-
portrait = await results.graphicFieldImageByTypeSource(GraphicFieldType.PORTRAIT, ResultType.RFID_IMAGE_DATA) ?? portrait
|
|
58
|
-
|
|
59
|
-
setStatus(name)
|
|
60
|
-
setPortrait(portrait)
|
|
61
|
-
setDocImage(docImage)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
var readRfid = () => {
|
|
65
|
-
documentReader.rfid(new RFIDConfig(handleCompletion))
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function shouldRfid(results: Results | null) {
|
|
69
|
-
return doRfid &&
|
|
70
|
-
!isReadingRfid &&
|
|
71
|
-
results != null && results.chipPage != 0
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
var initialize = async () => {
|
|
75
|
-
setStatus("Initializing...")
|
|
76
|
-
|
|
77
|
-
var license = await loadAsset("regula.license")
|
|
78
|
-
var initConfig = new InitConfig(license)
|
|
79
|
-
initConfig.delayedNNLoad = true
|
|
80
|
-
var [success, error] = await documentReader.initialize(initConfig)
|
|
81
|
-
|
|
82
|
-
handleException(error)
|
|
83
|
-
return success
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function handleException(error: DocReaderException | null) {
|
|
87
|
-
if (error != null) {
|
|
88
|
-
setStatus(error.message)
|
|
89
|
-
console.log(error.code + ": " + error.message)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// --------------------------------------------------------------------------------------------------------------------
|
|
94
|
-
|
|
95
|
-
export function main() {
|
|
96
|
-
documentUIImage = document.getElementById("document-image") as HTMLImageElement
|
|
97
|
-
portraitUIImage = document.getElementById("portrait-image") as HTMLImageElement
|
|
98
|
-
document.getElementById("scan")!.onclick = () => scan()
|
|
99
|
-
document.getElementById("recognize")!.onclick = () => recognize()
|
|
100
|
-
|
|
101
|
-
// custom rfid
|
|
102
|
-
if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
|
|
103
|
-
|
|
104
|
-
// bt device
|
|
105
|
-
if (!useBtDevice) init()
|
|
106
|
-
else {
|
|
107
|
-
setupBTDevice()
|
|
108
|
-
initialize = initializeWithBTDevice
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function setStatus(data: string | null) {
|
|
113
|
-
if (data != null)
|
|
114
|
-
document.getElementById("status")!.innerHTML = data
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
var portraitUIImage: HTMLImageElement
|
|
118
|
-
function setPortrait(data: string | null) {
|
|
119
|
-
if (data != null)
|
|
120
|
-
portraitUIImage.src = "data:image/png;base64," + data
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
var documentUIImage: HTMLImageElement
|
|
124
|
-
function setDocImage(data: string | null) {
|
|
125
|
-
if (data != null)
|
|
126
|
-
documentUIImage.src = "data:image/png;base64," + data
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function clearResults() {
|
|
130
|
-
setStatus("Ready")
|
|
131
|
-
portraitUIImage.src = "images/portrait.png"
|
|
132
|
-
documentUIImage.src = "images/document.png"
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function setCanRfid(data: boolean) {
|
|
136
|
-
var checkbox = document.getElementById('rfid-checkbox') as HTMLInputElement
|
|
137
|
-
var checkboxDescription = document.getElementById("rfid-checkbox-description")!
|
|
138
|
-
if (data) {
|
|
139
|
-
checkbox.disabled = false
|
|
140
|
-
checkboxDescription.innerHTML = "Process rfid reading"
|
|
141
|
-
var onclick = () => {
|
|
142
|
-
doRfid = !doRfid
|
|
143
|
-
checkbox.checked = doRfid
|
|
144
|
-
}
|
|
145
|
-
checkbox.onclick = onclick
|
|
146
|
-
checkboxDescription.onclick = onclick
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function setScenarios(data: DocReaderScenario[]) {
|
|
151
|
-
var scenariosContainer = document.getElementById("scenarios")!
|
|
152
|
-
|
|
153
|
-
data.forEach(scenario => {
|
|
154
|
-
var checked = selectedScenario == scenario.name ? "checked" : ""
|
|
155
|
-
var scenarioElement = `<div class="row radio">
|
|
156
|
-
<input type="radio" name="scenario" id="${scenario.name}" value="${scenario.name}" ${checked}>
|
|
157
|
-
<span id="${scenario.name}-caption" style="width: 200px; padding-left: 5px;">${scenario.caption}</span>
|
|
158
|
-
</div>`
|
|
159
|
-
scenariosContainer.insertAdjacentHTML("beforeend", scenarioElement)
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
data.forEach(scenario => {
|
|
163
|
-
var element = document.getElementById(scenario.name) as HTMLInputElement
|
|
164
|
-
var elementCaption = document.getElementById(scenario.name + "-caption")!
|
|
165
|
-
var onclick = () => {
|
|
166
|
-
selectedScenario = scenario.name as Scenario
|
|
167
|
-
element.checked = true
|
|
168
|
-
}
|
|
169
|
-
element.onclick = onclick
|
|
170
|
-
elementCaption.onclick = onclick
|
|
171
|
-
})
|
|
172
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import react from '@vitejs/plugin-react'
|
|
2
|
-
import { defineConfig } from 'vite'
|
|
3
|
-
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
plugins: [
|
|
7
|
-
react(),
|
|
8
|
-
viteStaticCopy({
|
|
9
|
-
targets: [
|
|
10
|
-
{
|
|
11
|
-
src: 'src/main.html',
|
|
12
|
-
dest: '.'
|
|
13
|
-
}
|
|
14
|
-
]
|
|
15
|
-
})],
|
|
16
|
-
build: { outDir: 'www' }
|
|
17
|
-
})
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Regula Document Reader Ionic demo application
|
|
2
|
-
|
|
3
|
-
## How to build demo application
|
|
4
|
-
1. Download or the clone current repository using the command `git clone https://github.com/regulaforensics/npm-document-reader.git`.
|
|
5
|
-
2. Put `regula.license` file at `assets/` (you can get a trial license [here](https://client.regulaforensics.com)).
|
|
6
|
-
3. Put `db.dat` file at `assets/` (you can get a trial database [here](https://client.regulaforensics.com/customer/databases))
|
|
7
|
-
4. Execute `npm run setup` within this directory.
|
|
8
|
-
5. Run the app:
|
|
9
|
-
* IOS: `npm run ios`.
|
|
10
|
-
* Android: `npm run android`.
|
|
11
|
-
|
|
12
|
-
**Note**: this is just one way of running the app. You can also pass `-o` or `--open` argument to the command, and this will open Xcode/Android Studio, then run the app directly from the IDE. Overall, this is a more consistent way, so if you're having troubles running the app from terminal, try running it from the IDE.
|
|
13
|
-
|
|
14
|
-
## Additional examples
|
|
15
|
-
|
|
16
|
-
### Bluetooth device
|
|
17
|
-
|
|
18
|
-
In order to connect to an external scanning device, change the `useBtDevice` constant to true in `src/extra/bt_device`, and set `btDeviceName` to the name of your device. After running the app, click `Connect`.
|
|
19
|
-
|
|
20
|
-
### RFID self hosted UI
|
|
21
|
-
|
|
22
|
-
This app also demonstraits how you can implement your own UI for the RFID reading process. To enable it, change the `useRfidSelfHostedUI` constant to true in `src/extra/custom_rfid`. Run the app and initiate RFID reading.
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 1,
|
|
3
|
-
"projects": {
|
|
4
|
-
"app": {
|
|
5
|
-
"root": "",
|
|
6
|
-
"sourceRoot": "src",
|
|
7
|
-
"projectType": "application",
|
|
8
|
-
"architect": {
|
|
9
|
-
"build": {
|
|
10
|
-
"builder": "@angular-devkit/build-angular:browser",
|
|
11
|
-
"options": {
|
|
12
|
-
"outputPath": "www",
|
|
13
|
-
"index": "index.html",
|
|
14
|
-
"main": "index.tsx",
|
|
15
|
-
"tsConfig": "tsconfig.json",
|
|
16
|
-
"assets": [
|
|
17
|
-
{
|
|
18
|
-
"glob": "**/*",
|
|
19
|
-
"input": "assets",
|
|
20
|
-
"output": "assets"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"glob": "**/*",
|
|
24
|
-
"input": "images",
|
|
25
|
-
"output": "images"
|
|
26
|
-
}
|
|
27
|
-
]
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"ionic-cordova-build": {
|
|
31
|
-
"builder": "@ionic/cordova-builders:cordova-build",
|
|
32
|
-
"options": {
|
|
33
|
-
"browserTarget": "app:build"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
File without changes
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<widget android-packageName="com.regula.example.dr.ionic" ios-CFBundleIdentifier="com.regula.example.dr.ionic" version="1.0.0"
|
|
3
|
-
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
4
|
-
<name>Document</name>
|
|
5
|
-
<icon src="images/icon.png" />
|
|
6
|
-
<platform name="android">
|
|
7
|
-
<resource-file src="assets/db.dat" target="app/src/main/assets/Regula/db.dat" />
|
|
8
|
-
<preference name="orientation" value="portrait" />
|
|
9
|
-
<preference name="AndroidEdgeToEdge" value="true" />
|
|
10
|
-
<preference name="android-minSdkVersion" value="24" />
|
|
11
|
-
<preference name="android-targetSdkVersion" value="36" />
|
|
12
|
-
<preference name="GradlePluginKotlinEnabled" value="true" />
|
|
13
|
-
<config-file parent="/*" target="AndroidManifest.xml">
|
|
14
|
-
<uses-permission android:name="android.permission.NFC" />
|
|
15
|
-
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
16
|
-
</config-file>
|
|
17
|
-
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
|
|
18
|
-
<application android:usesCleartextTraffic="true" />
|
|
19
|
-
</edit-config>
|
|
20
|
-
</platform>
|
|
21
|
-
<platform name="ios">
|
|
22
|
-
<resource-file src="assets/db.dat" />
|
|
23
|
-
<preference name="deployment-target" value="15.0" />
|
|
24
|
-
<preference name="orientation" value="portrait" />
|
|
25
|
-
<allow-intent href="itms:*" />
|
|
26
|
-
<allow-intent href="itms-apps:*" />
|
|
27
|
-
<config-file parent="NSCameraUsageDescription" target="*-Info.plist">
|
|
28
|
-
<string>To use camera</string>
|
|
29
|
-
</config-file>
|
|
30
|
-
<config-file parent="NSPhotoLibraryUsageDescription" target="*-Info.plist">
|
|
31
|
-
<string>To pick images</string>
|
|
32
|
-
</config-file>
|
|
33
|
-
<config-file parent="NSBluetoothAlwaysUsageDescription" target="*-Info.plist">
|
|
34
|
-
<string>To use btdevice</string>
|
|
35
|
-
</config-file>
|
|
36
|
-
<config-file parent="NFCReaderUsageDescription" target="*-Info.plist">
|
|
37
|
-
<string>To use NFC</string>
|
|
38
|
-
</config-file>
|
|
39
|
-
<config-file parent="com.apple.developer.nfc.readersession.iso7816.select-identifiers" target="*-Info.plist">
|
|
40
|
-
<array>
|
|
41
|
-
<string>A0000002471001</string>
|
|
42
|
-
<string>E80704007F00070302</string>
|
|
43
|
-
<string>A000000167455349474E</string>
|
|
44
|
-
<string>A0000002480100</string>
|
|
45
|
-
<string>A0000002480200</string>
|
|
46
|
-
<string>A0000002480300</string>
|
|
47
|
-
<string>A0000002480400</string>
|
|
48
|
-
<string>A00000045645444C2D3031</string>
|
|
49
|
-
<string>D2760000850101</string>
|
|
50
|
-
</array>
|
|
51
|
-
</config-file>
|
|
52
|
-
<config-file parent="com.apple.developer.nfc.readersession.formats" target="*-Debug.plist">
|
|
53
|
-
<array>
|
|
54
|
-
<string>TAG</string>
|
|
55
|
-
</array>
|
|
56
|
-
</config-file>
|
|
57
|
-
<config-file parent="com.apple.developer.nfc.readersession.formats" target="*-Release.plist">
|
|
58
|
-
<array>
|
|
59
|
-
<string>TAG</string>
|
|
60
|
-
</array>
|
|
61
|
-
</config-file>
|
|
62
|
-
</platform>
|
|
63
|
-
</widget>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<head>
|
|
2
|
-
<meta name="viewport"
|
|
3
|
-
content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
4
|
-
<base href="/" />
|
|
5
|
-
</head>
|
|
6
|
-
|
|
7
|
-
<body>
|
|
8
|
-
<ion-app>
|
|
9
|
-
<app-root></app-root>
|
|
10
|
-
</ion-app>
|
|
11
|
-
</body>
|
|
12
|
-
|
|
13
|
-
<style>
|
|
14
|
-
html,
|
|
15
|
-
body {
|
|
16
|
-
height: 100%;
|
|
17
|
-
margin: 0;
|
|
18
|
-
}
|
|
19
|
-
</style>
|
|
@@ -1,58 +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 { NgModule } from '@angular/core'
|
|
6
|
-
|
|
7
|
-
import { Component } from '@angular/core'
|
|
8
|
-
import { File } from '@awesome-cordova-plugins/file'
|
|
9
|
-
import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera/ngx'
|
|
10
|
-
|
|
11
|
-
import { main } from './src/main'
|
|
12
|
-
|
|
13
|
-
export async function loadAsset(path: string): Promise<string> {
|
|
14
|
-
var dir = await File.resolveDirectoryUrl(File.applicationDirectory + "www/assets")
|
|
15
|
-
var fileEntry = await File.getFile(dir, path, null)
|
|
16
|
-
var result = await new Promise<string>((resolve, _) => {
|
|
17
|
-
fileEntry.file(file => {
|
|
18
|
-
var reader = new FileReader()
|
|
19
|
-
reader.onloadend = (_) => resolve(reader.result as string)
|
|
20
|
-
reader.readAsDataURL(file)
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
return result
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function pickImage(): Promise<string | null> {
|
|
27
|
-
return await cameraInstance.getPicture({
|
|
28
|
-
destinationType: DestinationType.DATA_URL,
|
|
29
|
-
mediaType: MediaType.PICTURE,
|
|
30
|
-
sourceType: PictureSourceType.PHOTOLIBRARY
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var cameraInstance: Camera
|
|
35
|
-
@Component({
|
|
36
|
-
selector: 'app-root',
|
|
37
|
-
templateUrl: 'src/main.html',
|
|
38
|
-
styleUrl: 'src/main.css'
|
|
39
|
-
})
|
|
40
|
-
class Main {
|
|
41
|
-
constructor(platform: Platform, camera: Camera) {
|
|
42
|
-
(async () => {
|
|
43
|
-
cameraInstance = camera
|
|
44
|
-
await platform.ready()
|
|
45
|
-
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))
|
|
46
|
-
main()
|
|
47
|
-
})()
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@NgModule({
|
|
52
|
-
bootstrap: [Main],
|
|
53
|
-
providers: [Platform, Camera],
|
|
54
|
-
imports: [BrowserModule, IonicModule.forRoot()]
|
|
55
|
-
})
|
|
56
|
-
class MainModule { }
|
|
57
|
-
|
|
58
|
-
platformBrowserDynamic().bootstrapModule(MainModule)
|