@regulaforensics/document-reader 9.9.1148-rc → 9.9.1155-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/Package.swift +28 -0
- package/README.md +3 -1
- package/android/CVDDocumentReader.kt +4 -3
- package/android/build.gradle.kts +37 -0
- package/android/cordova.gradle.kts +13 -0
- package/android/src/main/kotlin/com/regula/plugin/{documentreader → document/reader}/BluetoothUtil.kt +1 -1
- package/android/src/main/kotlin/com/regula/plugin/{documentreader → document/reader}/Config.kt +3 -3
- package/android/src/main/kotlin/com/regula/plugin/{documentreader → document/reader}/JSONConstructor.kt +4 -4
- package/android/src/main/kotlin/com/regula/plugin/{documentreader → document/reader}/Main.kt +3 -3
- package/android/src/main/kotlin/com/regula/plugin/{documentreader → document/reader}/RNDocumentReaderModule.kt +4 -3
- package/android/src/main/kotlin/com/regula/plugin/{documentreader → document/reader}/Utils.kt +1 -1
- package/app.plugin.js +10 -7
- package/examples/capacitor/README.md +2 -0
- package/examples/capacitor/android/app/build.gradle +1 -10
- package/examples/capacitor/android/app/src/main/AndroidManifest.xml +9 -0
- package/examples/capacitor/android/app/src/main/res/xml/file_paths.xml +5 -0
- package/examples/capacitor/android/build.gradle +12 -3
- 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 +4 -0
- package/examples/capacitor/android/gradlew +4 -7
- package/examples/capacitor/android/gradlew.bat +12 -24
- package/examples/capacitor/android/variables.gradle +13 -9
- package/examples/capacitor/capacitor.config.json +15 -0
- package/examples/capacitor/index.tsx +15 -23
- package/examples/capacitor/ios/App/App/AppDelegate.swift +5 -40
- package/examples/capacitor/ios/App/App/Info.plist +19 -2
- package/examples/capacitor/ios/App/App/SceneDelegate.swift +23 -0
- package/examples/capacitor/ios/App/App.xcodeproj/project.pbxproj +30 -86
- package/examples/capacitor/ios/App/CapApp-SPM/Sources/CapApp-SPM/CapApp-SPM.swift +1 -0
- package/examples/capacitor/package.json +13 -18
- package/examples/capacitor/scripts/android.sh +5 -8
- package/examples/capacitor/scripts/ios.sh +5 -7
- package/examples/capacitor/scripts/setup.sh +2 -7
- package/examples/capacitor/src/main.css +5 -0
- package/examples/capacitor/vite.config.ts +0 -12
- package/examples/capacitor-cocoapods/README.md +22 -0
- package/examples/capacitor-cocoapods/android/app/build.gradle +50 -0
- package/examples/capacitor-cocoapods/android/app/proguard-rules.pro +21 -0
- package/examples/capacitor-cocoapods/android/app/src/main/AndroidManifest.xml +27 -0
- 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 +5 -0
- 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 +4 -0
- package/examples/capacitor-cocoapods/android/app/src/main/res/drawable/launcher_round.xml +4 -0
- 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 +12 -0
- package/examples/capacitor-cocoapods/android/app/src/main/res/values/styles.xml +22 -0
- package/examples/capacitor-cocoapods/android/build.gradle +30 -0
- package/examples/capacitor-cocoapods/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/examples/capacitor-cocoapods/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/examples/capacitor-cocoapods/android/gradle.properties +22 -0
- package/examples/capacitor-cocoapods/android/gradlew +251 -0
- package/examples/capacitor-cocoapods/android/gradlew.bat +94 -0
- package/examples/capacitor-cocoapods/android/settings.gradle +5 -0
- package/examples/capacitor-cocoapods/android/variables.gradle +16 -0
- package/examples/capacitor-cocoapods/index.html +5 -0
- package/examples/capacitor-cocoapods/index.tsx +39 -0
- package/examples/capacitor-cocoapods/ios/App/App/App.entitlements +10 -0
- package/examples/capacitor-cocoapods/ios/App/App/AppDelegate.swift +49 -0
- 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 +14 -0
- package/examples/capacitor-cocoapods/ios/App/App/Assets.xcassets/Contents.json +6 -0
- package/examples/capacitor-cocoapods/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json +23 -0
- 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 +32 -0
- package/examples/capacitor-cocoapods/ios/App/App/Info.plist +69 -0
- package/examples/capacitor-cocoapods/ios/App/App.xcodeproj/project.pbxproj +430 -0
- package/examples/capacitor-cocoapods/ios/App/App.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/examples/capacitor-cocoapods/package.json +30 -0
- 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 +11 -0
- package/examples/capacitor-cocoapods/scripts/ios.sh +10 -0
- package/examples/capacitor-cocoapods/scripts/setup.sh +14 -0
- package/examples/capacitor-cocoapods/src/extra/bt_device.tsx +33 -0
- package/examples/capacitor-cocoapods/src/extra/custom_rfid.tsx +61 -0
- package/examples/capacitor-cocoapods/src/main.css +148 -0
- package/examples/capacitor-cocoapods/src/main.html +38 -0
- package/examples/capacitor-cocoapods/src/main.tsx +172 -0
- package/examples/capacitor-cocoapods/tsconfig.json +5 -0
- package/examples/capacitor-cocoapods/vite.config.ts +17 -0
- package/examples/ionic/README.md +2 -0
- package/examples/ionic/config.xml +1 -1
- package/examples/ionic/index.tsx +8 -3
- package/examples/ionic/package-lock.json +6014 -7521
- package/examples/ionic/package.json +24 -33
- package/examples/ionic/scripts/android.sh +0 -2
- package/examples/ionic/scripts/ios.sh +0 -2
- package/examples/ionic/scripts/setup.sh +0 -2
- package/examples/ionic/tsconfig.json +0 -1
- package/examples/ionic-cocoapods/README.md +22 -0
- package/examples/ionic-cocoapods/angular.json +39 -0
- package/examples/ionic-cocoapods/assets/.gitkeep +0 -0
- package/examples/ionic-cocoapods/config.xml +63 -0
- 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 +19 -0
- package/examples/ionic-cocoapods/index.tsx +58 -0
- package/examples/ionic-cocoapods/ionic.config.json +7 -0
- package/examples/ionic-cocoapods/package-lock.json +16579 -0
- package/examples/ionic-cocoapods/package.json +58 -0
- package/examples/ionic-cocoapods/scripts/android.sh +8 -0
- package/examples/ionic-cocoapods/scripts/ios.sh +8 -0
- package/examples/ionic-cocoapods/scripts/setup.sh +8 -0
- package/examples/ionic-cocoapods/src/extra/bt_device.tsx +33 -0
- package/examples/ionic-cocoapods/src/extra/custom_rfid.tsx +61 -0
- package/examples/ionic-cocoapods/src/main.css +148 -0
- package/examples/ionic-cocoapods/src/main.html +38 -0
- package/examples/ionic-cocoapods/src/main.tsx +172 -0
- package/examples/ionic-cocoapods/tsconfig.json +14 -0
- package/examples/react_native/README.md +2 -0
- package/examples/react_native/app.config.ts +1 -2
- package/examples/react_native/package-lock.json +2018 -4031
- package/examples/react_native/package.json +14 -19
- 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 +4 -3
- package/ios/module.modulemap +7 -0
- package/package.json +1 -1
- package/plugin.xml +12 -12
- package/react-native-document-reader.podspec +14 -0
- package/test/package-lock.json +1 -1
- package/RNDocumentReader.podspec +0 -21
- package/android/build.gradle +0 -36
- package/android/cordova.gradle +0 -12
- package/examples/react_native/vendor/image-size-metro-compat/index.cjs +0 -16
- package/examples/react_native/vendor/image-size-metro-compat/package.json +0 -8
- /package/examples/{capacitor → capacitor-cocoapods}/android/app/capacitor.build.gradle +0 -0
- /package/examples/{capacitor → capacitor-cocoapods}/android/capacitor.settings.gradle +0 -0
- /package/examples/{capacitor → capacitor-cocoapods}/ionic.config.json +0 -0
- /package/examples/{capacitor → capacitor-cocoapods}/ios/App/App/Base.lproj/Main.storyboard +0 -0
- /package/examples/{capacitor → capacitor-cocoapods}/ios/App/App.xcworkspace/contents.xcworkspacedata +0 -0
- /package/examples/{capacitor → capacitor-cocoapods}/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- /package/examples/{capacitor → capacitor-cocoapods}/ios/App/Podfile +0 -0
- /package/examples/{capacitor → capacitor-cocoapods}/ios/App/Podfile.lock +0 -0
- /package/examples/{capacitor → capacitor-cocoapods}/package-lock.json +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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>
|
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
})
|
package/examples/ionic/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Regula Document Reader Ionic demo application
|
|
2
2
|
|
|
3
|
+
Requires Node.js 22+, Xcode 26+, Android Studio with JDK 17 and Android SDK 36.
|
|
4
|
+
|
|
3
5
|
## How to build demo application
|
|
4
6
|
1. Download or the clone current repository using the command `git clone https://github.com/regulaforensics/npm-document-reader.git`.
|
|
5
7
|
2. Put `regula.license` file at `assets/` (you can get a trial license [here](https://client.regulaforensics.com)).
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
</platform>
|
|
19
19
|
<platform name="ios">
|
|
20
20
|
<resource-file src="assets/db.dat" />
|
|
21
|
-
<preference name="deployment-target" value="
|
|
21
|
+
<preference name="deployment-target" value="15.0" />
|
|
22
22
|
<preference name="orientation" value="portrait" />
|
|
23
23
|
<allow-intent href="itms:*" />
|
|
24
24
|
<allow-intent href="itms-apps:*" />
|
package/examples/ionic/index.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import 'zone.js';
|
|
2
2
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
|
3
3
|
import { BrowserModule } from '@angular/platform-browser'
|
|
4
|
-
import { IonicModule
|
|
5
|
-
import {
|
|
4
|
+
import { IonicModule } from '@ionic/angular/lazy'
|
|
5
|
+
import { Platform } from '@ionic/angular'
|
|
6
|
+
import { NgModule, provideZoneChangeDetection } from '@angular/core'
|
|
6
7
|
|
|
7
8
|
import { Component } from '@angular/core'
|
|
8
9
|
import { File } from '@awesome-cordova-plugins/file'
|
|
@@ -34,6 +35,7 @@ export async function pickImage(): Promise<string | null> {
|
|
|
34
35
|
var cameraInstance: Camera
|
|
35
36
|
@Component({
|
|
36
37
|
selector: 'app-root',
|
|
38
|
+
standalone: false,
|
|
37
39
|
templateUrl: 'src/main.html',
|
|
38
40
|
styleUrl: 'src/main.css'
|
|
39
41
|
})
|
|
@@ -50,9 +52,12 @@ class Main {
|
|
|
50
52
|
|
|
51
53
|
@NgModule({
|
|
52
54
|
bootstrap: [Main],
|
|
55
|
+
declarations: [Main],
|
|
53
56
|
providers: [Platform, Camera],
|
|
54
57
|
imports: [BrowserModule, IonicModule.forRoot()]
|
|
55
58
|
})
|
|
56
59
|
class MainModule { }
|
|
57
60
|
|
|
58
|
-
platformBrowserDynamic().bootstrapModule(MainModule
|
|
61
|
+
platformBrowserDynamic().bootstrapModule(MainModule, {
|
|
62
|
+
applicationProviders: [provideZoneChangeDetection()]
|
|
63
|
+
})
|