@regulaforensics/document-reader 9.10.1227-nightly → 9.10.1235-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 +1 -1
- package/android/build.gradle.kts +1 -1
- package/android/cordova.gradle.kts +1 -1
- package/examples/capacitor/package-lock.json +3 -558
- package/examples/capacitor/package.json +4 -3
- package/examples/ionic/package-lock.json +297 -829
- package/examples/ionic/package.json +5 -3
- package/examples/react_native/app.config.ts +3 -0
- package/examples/react_native/index.tsx +52 -22
- package/examples/react_native/metro.config.js +1 -3
- package/examples/react_native/package-lock.json +1216 -1137
- package/examples/react_native/package.json +11 -17
- package/examples/react_native/scripts/android.sh +1 -8
- package/examples/react_native/scripts/ios.sh +1 -7
- package/examples/react_native/scripts/setup.sh +0 -4
- package/examples/react_native/scripts/withoutMetroServer.js +86 -0
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/react-native-document-reader.podspec +2 -2
- package/test/package-lock.json +5 -2
- package/examples/react_native/index.html +0 -12
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@ionic/cordova-builders": "^13.0.0",
|
|
20
20
|
"@awesome-cordova-plugins/camera": "^9.6.0",
|
|
21
21
|
"@awesome-cordova-plugins/file": "^9.6.0",
|
|
22
|
-
"@regulaforensics/document-reader": "9.10.
|
|
22
|
+
"@regulaforensics/document-reader": "9.10.1235-beta",
|
|
23
23
|
"@regulaforensics/document-reader-core-fullauthrfid": "9.9.3305",
|
|
24
24
|
"@regulaforensics/document-reader-btdevice": "9.9.140",
|
|
25
25
|
"cordova-android": "^15.1.0",
|
|
@@ -34,8 +34,10 @@
|
|
|
34
34
|
"typescript": "~6.0.3"
|
|
35
35
|
},
|
|
36
36
|
"overrides": {
|
|
37
|
-
"serialize-javascript": "^7.1.
|
|
38
|
-
"uuid": "^11.1.1"
|
|
37
|
+
"serialize-javascript": "^7.1.2",
|
|
38
|
+
"uuid": "^11.1.1",
|
|
39
|
+
"source-map-js": "^1.2.2",
|
|
40
|
+
"shell-quote": "^1.11.0"
|
|
39
41
|
},
|
|
40
42
|
"cordova": {
|
|
41
43
|
"plugins": {
|
|
@@ -36,9 +36,12 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
|
|
|
36
36
|
},
|
|
37
37
|
plugins: [
|
|
38
38
|
'@regulaforensics/document-reader',
|
|
39
|
+
'./scripts/withoutMetroServer',
|
|
39
40
|
['expo-custom-assets', { assetsPaths: ['./assets'] }],
|
|
40
41
|
['expo-build-properties', {
|
|
42
|
+
ios: { networkInspector: false },
|
|
41
43
|
android: {
|
|
44
|
+
networkInspector: false,
|
|
42
45
|
extraMavenRepos: [
|
|
43
46
|
{ url: 'https://maven.regulaforensics.com/RegulaDocumentReader' },
|
|
44
47
|
{ url: 'https://maven.regulaforensics.com/RegulaDocumentReader/Beta' },
|
|
@@ -6,6 +6,23 @@ import { Platform } from 'react-native'
|
|
|
6
6
|
import { launchImageLibrary } from 'react-native-image-picker'
|
|
7
7
|
import { main } from './src/main'
|
|
8
8
|
|
|
9
|
+
export async function loadAsset(path: string): Promise<string> {
|
|
10
|
+
if (Platform.OS === 'ios') path = RNFS.MainBundlePath + "/" + path
|
|
11
|
+
var readFile = Platform.OS === 'ios' ? RNFS.readFile : RNFS.readFileRes
|
|
12
|
+
return await readFile(path, 'base64')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function pickImage(): Promise<string | null> {
|
|
16
|
+
var response = await launchImageLibrary({
|
|
17
|
+
mediaType: 'photo',
|
|
18
|
+
selectionLimit: 1,
|
|
19
|
+
includeBase64: true
|
|
20
|
+
})
|
|
21
|
+
return response?.assets?.[0].base64!
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// --------------------------------------------------------------------------------------------------------------------
|
|
25
|
+
|
|
9
26
|
var webViewRef: any
|
|
10
27
|
const onclicks: any = {}
|
|
11
28
|
const onMessage = (json: any) => {
|
|
@@ -50,32 +67,45 @@ const document = {
|
|
|
50
67
|
}
|
|
51
68
|
|
|
52
69
|
function parseValue(value: any) {
|
|
53
|
-
|
|
54
|
-
return value
|
|
70
|
+
const json = JSON.stringify(value)
|
|
71
|
+
return typeof value === 'string' ? `(window.webImages[${json}] ?? ${json})` : json
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function loadWebUI() {
|
|
75
|
+
const webRoot = Platform.OS === 'ios' ? RNFS.MainBundlePath + '/web/' : 'web/'
|
|
76
|
+
const readWebFile = Platform.OS === 'ios' ? RNFS.readFile : RNFS.readFileAssets
|
|
77
|
+
const readWebDir = Platform.OS === 'ios' ? RNFS.readDir : RNFS.readDirAssets
|
|
78
|
+
const webImages: Record<string, string> = {}
|
|
79
|
+
const [styles, content] = await Promise.all(['src/main.css', 'src/main.html'].map(path => readWebFile(webRoot + path, 'utf8')))
|
|
80
|
+
|
|
81
|
+
for (const file of (await readWebDir(webRoot + 'images')).filter(file => file.isFile())) {
|
|
82
|
+
const extension = file.name.split('.').pop()!.toLowerCase()
|
|
83
|
+
const type = ({ jpg: 'jpeg', svg: 'svg+xml' } as Record<string, string>)[extension] ?? extension
|
|
84
|
+
webImages['images/' + file.name] = `data:image/${type};base64,${await readWebFile(file.path, 'base64')}`
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const html = content.replace(/src="([^"]+)"/g, (match, path) => webImages[path] ? `src="${webImages[path]}"` : match)
|
|
88
|
+
return `<meta name="viewport" content="initial-scale=1, user-scalable=no, viewport-fit=cover">
|
|
89
|
+
<style>${styles}</style>
|
|
90
|
+
<div id="content" style="height: 100%">${html}</div>
|
|
91
|
+
<script>
|
|
92
|
+
window.webImages = ${JSON.stringify(webImages)};
|
|
93
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
94
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({ id: "ready" }))
|
|
95
|
+
}))
|
|
96
|
+
</script>`
|
|
55
97
|
}
|
|
56
98
|
|
|
57
99
|
(globalThis as any).document = document;
|
|
58
|
-
registerRootComponent(() =>
|
|
59
|
-
|
|
100
|
+
registerRootComponent(() => {
|
|
101
|
+
const [html, setHtml] = React.useState('')
|
|
102
|
+
React.useEffect(() => { loadWebUI().then(setHtml).catch(console.error) }, [])
|
|
103
|
+
return html ? <WebView
|
|
60
104
|
ref={ref => { webViewRef = ref }}
|
|
61
105
|
onMessage={onMessage}
|
|
62
|
-
|
|
106
|
+
originWhitelist={['*']}
|
|
107
|
+
source={{ html }}
|
|
63
108
|
scrollEnabled={false}
|
|
64
109
|
overScrollMode={'content'}
|
|
65
|
-
/>
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
export async function loadAsset(path: string): Promise<string> {
|
|
69
|
-
if (Platform.OS === 'ios') path = RNFS.MainBundlePath + "/" + path
|
|
70
|
-
var readFile = Platform.OS === 'ios' ? RNFS.readFile : RNFS.readFileRes
|
|
71
|
-
return await readFile(path, 'base64')
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export async function pickImage(): Promise<string | null> {
|
|
75
|
-
var response = await launchImageLibrary({
|
|
76
|
-
mediaType: 'photo',
|
|
77
|
-
selectionLimit: 1,
|
|
78
|
-
includeBase64: true
|
|
79
|
-
})
|
|
80
|
-
return response?.assets?.[0].base64!
|
|
81
|
-
}
|
|
110
|
+
/> : null
|
|
111
|
+
})
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
const config = require('expo/metro-config').getDefaultConfig(__dirname)
|
|
2
2
|
config.watchFolders = [
|
|
3
|
-
__dirname + '/node_modules'
|
|
4
3
|
]
|
|
5
|
-
config.resolver.nodeModulesPaths =
|
|
6
|
-
config.resolver.assetExts.push('css')
|
|
4
|
+
config.resolver.nodeModulesPaths = [__dirname + '/node_modules']
|
|
7
5
|
module.exports = config
|