@regulaforensics/document-reader 8.2.204-beta → 8.3.242-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.
Files changed (51) hide show
  1. package/RNDocumentReader.podspec +2 -2
  2. package/android/build.gradle +2 -2
  3. package/android/cordova.gradle +2 -2
  4. package/android/src/main/java/com/regula/plugin/documentreader/Config.kt +3 -1
  5. package/examples/capacitor/README.md +10 -0
  6. package/examples/capacitor/index.html +2 -7
  7. package/examples/capacitor/index.tsx +39 -0
  8. package/examples/capacitor/package.json +3 -3
  9. package/examples/capacitor/scripts/setup.sh +4 -0
  10. package/examples/capacitor/src/extra/bt_device.tsx +7 -6
  11. package/examples/capacitor/src/main.css +4 -1
  12. package/examples/capacitor/src/main.html +1 -4
  13. package/examples/capacitor/src/main.tsx +48 -81
  14. package/examples/cordova/README.md +10 -0
  15. package/examples/cordova/config.xml +3 -0
  16. package/examples/cordova/package-lock.json +459 -1
  17. package/examples/cordova/package.json +5 -4
  18. package/examples/cordova/scripts/bundle.sh +4 -0
  19. package/examples/cordova/www/bootstrap.js +30 -0
  20. package/examples/cordova/www/index.html +1 -1
  21. package/examples/cordova/www/index.js +26 -36
  22. package/examples/cordova/www/src/extra/bt_device.js +7 -6
  23. package/examples/cordova/www/src/main.css +4 -1
  24. package/examples/cordova/www/src/main.html +1 -4
  25. package/examples/cordova/www/src/main.js +48 -77
  26. package/examples/ionic/README.md +10 -0
  27. package/examples/ionic/config.xml +2 -0
  28. package/examples/ionic/index.ts +40 -2
  29. package/examples/ionic/package.json +3 -3
  30. package/examples/ionic/src/extra/bt_device.ts +7 -6
  31. package/examples/ionic/src/main.css +4 -1
  32. package/examples/ionic/src/main.html +1 -4
  33. package/examples/ionic/src/main.ts +48 -87
  34. package/examples/react_native/README.md +10 -0
  35. package/examples/react_native/index.tsx +26 -4
  36. package/examples/react_native/package-lock.json +476 -421
  37. package/examples/react_native/package.json +10 -10
  38. package/examples/react_native/src/extra/bt_device.tsx +7 -6
  39. package/examples/react_native/src/main.css +4 -1
  40. package/examples/react_native/src/main.html +1 -4
  41. package/examples/react_native/src/main.tsx +48 -69
  42. package/ios/RGLWConfig.m +2 -0
  43. package/package.json +1 -1
  44. package/plugin.xml +2 -2
  45. package/www/capacitor/index.js +16 -16
  46. package/www/capacitor/params/process_params/ProcessParams.js +7 -0
  47. package/www/cordova.js +23 -16
  48. package/www/react-native/index.js +16 -16
  49. package/www/react-native/params/process_params/ProcessParams.js +7 -0
  50. package/www/types/index.d.ts +8 -8
  51. package/www/types/params/process_params/ProcessParams.d.ts +4 -0
@@ -1,4 +1,5 @@
1
- import { setupBTDevice, useBtDevice } from './extra/bt_device.js'
1
+ import { loadAsset, pickImage } from '../index.js'
2
+ import { initializeWithBTDevice, setupBTDevice, useBtDevice } from './extra/bt_device.js'
2
3
  import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid.js'
3
4
 
4
5
  var documentReader = DocumentReader.instance
@@ -6,7 +7,7 @@ var selectedScenario
6
7
  var doRfid = false
7
8
  var isReadingRfid = false
8
9
 
9
- async function init() {
10
+ export async function init() {
10
11
  if (!await initialize()) return
11
12
  setScenarios(documentReader.availableScenarios)
12
13
  setCanRfid(await documentReader.isRFIDAvailableForUse())
@@ -69,7 +70,7 @@ function shouldRfid(results) {
69
70
  results != null && results.chipPage != 0
70
71
  }
71
72
 
72
- async function initialize() {
73
+ var initialize = async () => {
73
74
  setStatus("Initializing...")
74
75
 
75
76
  var license = await loadAsset("regula.license")
@@ -87,7 +88,26 @@ export function handleException(error) {
87
88
  }
88
89
  }
89
90
 
90
- // ui --------------------------------------------------------------------------------------------------------------------
91
+ // --------------------------------------------------------------------------------------------------------------------
92
+
93
+ var documentUIImage
94
+ var portraitUIImage
95
+ export function main() {
96
+ documentUIImage = document.getElementById("document-image")
97
+ portraitUIImage = document.getElementById("portrait-image")
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
+ }
91
111
 
92
112
  export function setStatus(data) {
93
113
  if (data != null)
@@ -117,86 +137,37 @@ function setCanRfid(data) {
117
137
  if (data) {
118
138
  checkbox.disabled = false
119
139
  checkboxDescription.innerHTML = "Process rfid reading"
120
- checkboxDescription.onclick = () => {
140
+ var onclick = () => {
121
141
  doRfid = !doRfid
122
142
  checkbox.checked = doRfid
123
143
  }
144
+ checkbox.onclick = onclick
145
+ checkboxDescription.onclick = onclick
124
146
  }
125
147
  }
126
148
 
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
149
  function setScenarios(data) {
175
150
  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)
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
+ })
200
161
 
201
- return div
162
+ data.forEach(scenario => {
163
+ var element
164
+ element = document.getElementById(scenario.name)
165
+ var elementCaption = document.getElementById(scenario.name + "-caption")
166
+ var onclick = () => {
167
+ selectedScenario = scenario.name
168
+ element.checked = true
169
+ }
170
+ element.onclick = onclick
171
+ elementCaption.onclick = onclick
172
+ })
202
173
  }
@@ -10,3 +10,13 @@
10
10
  * Android: `npm run android`.
11
11
 
12
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 you device. After running the app, click `Connect`.
19
+
20
+ ### RFID self hosted UI
21
+
22
+ This app also demonstraits how you can implement you 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.
@@ -4,6 +4,7 @@
4
4
  <name>DocumentReader</name>
5
5
  <icon src="src/images/icon.png" />
6
6
  <platform name="android">
7
+ <resource-file src="src/assets/db.dat" target="app/src/main/assets/Regula/db.dat"/>
7
8
  <preference name="orientation" value="portrait" />
8
9
  <preference name="android-minSdkVersion" value="24" />
9
10
  <preference name="android-targetSdkVersion" value="35" />
@@ -17,6 +18,7 @@
17
18
  </edit-config>
18
19
  </platform>
19
20
  <platform name="ios">
21
+ <resource-file src="src/assets/db.dat" />
20
22
  <preference name="orientation" value="portrait" />
21
23
  <allow-intent href="itms:*" />
22
24
  <allow-intent href="itms-apps:*" />
@@ -2,10 +2,48 @@ import 'zone.js';
2
2
  import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
3
3
  import { BrowserModule } from '@angular/platform-browser'
4
4
  import { IonicModule, Platform } from '@ionic/angular'
5
- import { Camera } from '@awesome-cordova-plugins/camera/ngx'
6
- import { Main } from './src/main'
7
5
  import { NgModule } from '@angular/core'
8
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
+ cameraInstance = camera
43
+ platform.ready().then(main)
44
+ }
45
+ }
46
+
9
47
  @NgModule({
10
48
  bootstrap: [Main],
11
49
  providers: [Platform, Camera],
@@ -6,9 +6,9 @@
6
6
  "android": "scripts/android.sh"
7
7
  },
8
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",
9
+ "@regulaforensics/document-reader": "8.3.242-beta",
10
+ "@regulaforensics/document-reader-core-fullauthrfid": "8.3.9-beta",
11
+ "@regulaforensics/document-reader-btdevice": "8.3.10-beta",
12
12
  "@awesome-cordova-plugins/file": "6.14.0",
13
13
  "@awesome-cordova-plugins/camera": "6.14.0",
14
14
  "cordova-ios": "7.1.1",
@@ -1,26 +1,27 @@
1
1
  import { DocumentReader, InitConfig } from "@regulaforensics/document-reader"
2
- import { handleException, setStatus } from "../main"
2
+ import { handleException, init, setStatus } from "../main"
3
3
 
4
4
  export const useBtDevice = false
5
- const btDeviceName = "Regula 0000"
5
+ export const btDeviceName = "Regula 0000"
6
6
 
7
7
  export function setupBTDevice() {
8
- document.getElementById("bt-device").style.display = "flex"
9
- document.getElementById("connect").onclick = () => connect()
8
+ var connectButton = document.getElementById("connect")
9
+ connectButton.style.display = "flex"
10
+ connectButton.onclick = () => connect()
10
11
  setStatus("Connect to a bluetooth device")
11
12
  }
12
13
 
13
14
  async function connect() {
14
15
  setStatus("Searching for devices...")
15
16
  if (await DocumentReader.instance.connectBluetoothDevice(btDeviceName)) {
16
- await initialize()
17
+ await init()
17
18
  DocumentReader.instance.functionality.useAuthenticator = true
18
19
  document.getElementById("bt-device").style.display = "none"
19
20
  } else
20
21
  setStatus("Failed to connect")
21
22
  }
22
23
 
23
- async function initialize() {
24
+ export async function initializeWithBTDevice() {
24
25
  setStatus("Initializing...")
25
26
 
26
27
  var initConfig = InitConfig.withBleDevice()
@@ -1,8 +1,10 @@
1
1
  html,
2
2
  body {
3
- width: 99%;
3
+ margin: 0;
4
+ width: 100%;
4
5
  height: 99vh;
5
6
  display: flex;
7
+ overflow: hidden;
6
8
  flex-direction: column;
7
9
  }
8
10
 
@@ -59,6 +61,7 @@ body {
59
61
  color: white;
60
62
  border: none;
61
63
  padding: 10px 20px;
64
+ justify-content: center;
62
65
  font-size: 16px;
63
66
  border-radius: 100px;
64
67
  cursor: pointer;
@@ -14,10 +14,6 @@
14
14
  <img id="document-image" src="images/document.png" height="160px" width="200px">
15
15
  </div>
16
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
17
  <div id="scenario-container" class="column no-scroll" style="margin-top: 15px; background-color: rgba(0, 0, 0, 0.03);">
22
18
  <div id="scenarios" class="scroll"></div>
23
19
  </div>
@@ -29,6 +25,7 @@
29
25
  <button id="scan" class="button">Scan document</button>
30
26
  <button id="recognize" class="button">Scan image</button>
31
27
  </div>
28
+ <button id="connect" class="button" style="width: 360px; display: none;">Connect</button>
32
29
  <div style="padding-top: 20px;"></div>
33
30
  </div>
34
31
  <div id="custom-rfid" class="column no-scroll" style="display: none;">
@@ -1,10 +1,6 @@
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
1
  import { DocumentReader, DocReaderAction, FieldType, GraphicFieldType, InitConfig, RecognizeConfig, ResultType, RFIDConfig, ScannerConfig, Scenario } from '@regulaforensics/document-reader'
7
- import { setupBTDevice, useBtDevice } from './extra/bt_device'
2
+ import { loadAsset, pickImage } from '../index'
3
+ import { initializeWithBTDevice, setupBTDevice, useBtDevice } from './extra/bt_device'
8
4
  import { useRfidSelfHostedUI, rfidSelfHostedUI } from './extra/custom_rfid'
9
5
 
10
6
  var documentReader = DocumentReader.instance
@@ -12,7 +8,7 @@ var selectedScenario
12
8
  var doRfid = false
13
9
  var isReadingRfid = false
14
10
 
15
- async function init() {
11
+ export async function init() {
16
12
  if (!await initialize()) return
17
13
  setScenarios(documentReader.availableScenarios)
18
14
  setCanRfid(await documentReader.isRFIDAvailableForUse())
@@ -75,7 +71,7 @@ function shouldRfid(results) {
75
71
  results != null && results.chipPage != 0
76
72
  }
77
73
 
78
- async function initialize() {
74
+ var initialize = async () => {
79
75
  setStatus("Initializing...")
80
76
 
81
77
  var license = await loadAsset("regula.license")
@@ -93,7 +89,26 @@ export function handleException(error) {
93
89
  }
94
90
  }
95
91
 
96
- // ui --------------------------------------------------------------------------------------------------------------------
92
+ // --------------------------------------------------------------------------------------------------------------------
93
+
94
+ var documentUIImage
95
+ var portraitUIImage
96
+ export function main() {
97
+ documentUIImage = document.getElementById("document-image")
98
+ portraitUIImage = document.getElementById("portrait-image")
99
+ document.getElementById("scan").onclick = () => scan()
100
+ document.getElementById("recognize").onclick = () => recognize()
101
+
102
+ // custom rfid
103
+ if (useRfidSelfHostedUI) readRfid = () => rfidSelfHostedUI()
104
+
105
+ // bt device
106
+ if (!useBtDevice) init()
107
+ else {
108
+ setupBTDevice()
109
+ initialize = initializeWithBTDevice
110
+ }
111
+ }
97
112
 
98
113
  export function setStatus(data) {
99
114
  if (data != null)
@@ -123,91 +138,37 @@ function setCanRfid(data) {
123
138
  if (data) {
124
139
  checkbox.disabled = false
125
140
  checkboxDescription.innerHTML = "Process rfid reading"
126
- checkboxDescription.onclick = () => {
141
+ var onclick = () => {
127
142
  doRfid = !doRfid
128
143
  checkbox.checked = doRfid
129
144
  }
145
+ checkbox.onclick = onclick
146
+ checkboxDescription.onclick = onclick
130
147
  }
131
148
  }
132
149
 
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
150
  function setScenarios(data) {
186
151
  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)
152
+ var scenariosContainer = document.getElementById("scenarios")
153
+
154
+ data.forEach(scenario => {
155
+ var checked = selectedScenario == scenario.name ? "checked" : ""
156
+ var scenarioElement = `<div class="row radio">
157
+ <input type="radio" name="scenario" id="${scenario.name}" value="${scenario.name}" ${checked}>
158
+ <span id="${scenario.name}-caption" style="width: 200px; padding-left: 5px;">${scenario.caption}</span>
159
+ </div>`
160
+ scenariosContainer.insertAdjacentHTML("beforeend", scenarioElement)
161
+ })
211
162
 
212
- return div
163
+ data.forEach(scenario => {
164
+ var element
165
+ element = document.getElementById(scenario.name)
166
+ var elementCaption = document.getElementById(scenario.name + "-caption")
167
+ var onclick = () => {
168
+ selectedScenario = scenario.name
169
+ element.checked = true
170
+ }
171
+ element.onclick = onclick
172
+ elementCaption.onclick = onclick
173
+ })
213
174
  }
@@ -10,3 +10,13 @@
10
10
  * Android: `npm run android`.
11
11
 
12
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. Just don't forget to make sure that Metro Bundler is running(`npm start`).
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 you device. After running the app, click `Connect`.
19
+
20
+ ### RFID self hosted UI
21
+
22
+ This app also demonstraits how you can implement you 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,13 +1,16 @@
1
1
  import { registerRootComponent } from 'expo'
2
2
  import WebView from 'react-native-webview'
3
3
  import React from 'react'
4
- import { onload } from './src/main'
4
+ import * as RNFS from 'react-native-fs'
5
+ import { Platform } from 'react-native'
6
+ import { launchImageLibrary } from 'react-native-image-picker'
7
+ import { main } from './src/main'
5
8
 
6
9
  var webViewRef: any
7
10
  const onclicks: any = {}
8
11
  const onMessage = (json: any) => {
9
12
  const event = JSON.parse(json.nativeEvent.data)
10
- if (event.id === "ready") onload()
13
+ if (event.id === "ready") main()
11
14
  if (event.id === "onclick") {
12
15
  onclicks[event.value]()
13
16
  }
@@ -35,8 +38,12 @@ export const document = {
35
38
  return true
36
39
  }
37
40
  })
41
+ if (prop === "insertAdjacentHTML") return (position: string, html: string) => {
42
+ webViewRef.injectJavaScript(`document.getElementById("${id}").insertAdjacentHTML('${position}', \`${html}\`); true`)
43
+ return true
44
+ }
38
45
  return undefined
39
- },
46
+ }
40
47
  }
41
48
  )
42
49
  }
@@ -53,6 +60,21 @@ registerRootComponent(() =>
53
60
  onMessage={onMessage}
54
61
  source={require("./index.html")}
55
62
  scrollEnabled={false}
56
- injectedJavaScript="document.body.addEventListener('touchmove', function(e) { e.preventDefault() }, { passive: false })"
63
+ overScrollMode={'content'}
57
64
  />
58
65
  )
66
+
67
+ export async function loadAsset(path: string): Promise<string> {
68
+ if (Platform.OS === 'ios') path = RNFS.MainBundlePath + "/" + path
69
+ var readFile = Platform.OS === 'ios' ? RNFS.readFile : RNFS.readFileRes
70
+ return await readFile(path, 'base64')
71
+ }
72
+
73
+ export async function pickImage(): Promise<string | null> {
74
+ var response = await launchImageLibrary({
75
+ mediaType: 'photo',
76
+ selectionLimit: 1,
77
+ includeBase64: true
78
+ })
79
+ return response?.assets?.[0].base64!
80
+ }