@regulaforensics/face-sdk 8.5.1494-rc → 8.5.1496-nightly

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.
@@ -20,8 +20,8 @@
20
20
  "@awesome-cordova-plugins/camera": "^9.6.0",
21
21
  "@awesome-cordova-plugins/dialogs": "^9.6.0",
22
22
  "@awesome-cordova-plugins/file": "^9.6.0",
23
- "@regulaforensics/face-sdk": "8.5.1494-rc",
24
- "@regulaforensics/face-core-basic": "8.5.909-rc",
23
+ "@regulaforensics/face-sdk": "8.5.1496-nightly",
24
+ "@regulaforensics/face-core-basic": "8.5.912-nightly",
25
25
  "cordova-android": "^15.1.0",
26
26
  "cordova-ios": "^8.1.1",
27
27
  "cordova-plugin-camera": "^8.0.0",
@@ -35,7 +35,7 @@
35
35
  "typescript": "~6.0.3"
36
36
  },
37
37
  "overrides": {
38
- "serialize-javascript": "^7.1.1",
38
+ "serialize-javascript": "^7.1.2",
39
39
  "uuid": "^11.1.1",
40
40
  "source-map-js": "^1.2.2",
41
41
  "shell-quote": "^1.11.0"
@@ -19,9 +19,12 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
19
19
  },
20
20
  plugins: [
21
21
  '@regulaforensics/face-sdk',
22
+ './scripts/withoutMetroServer',
22
23
  ['expo-custom-assets', { assetsPaths: ['./assets'] }],
23
24
  ['expo-build-properties', {
25
+ ios: { networkInspector: false },
24
26
  android: {
27
+ networkInspector: false,
25
28
  extraMavenRepos: [
26
29
  { url: 'https://maven.regulaforensics.com/RegulaDocumentReader' },
27
30
  { url: 'https://maven.regulaforensics.com/RegulaDocumentReader/Beta' },
@@ -6,6 +6,36 @@ import { Alert, 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 loadAssetIfExists(path: string): Promise<string | null> {
10
+ if (Platform.OS === 'ios') path = RNFS.MainBundlePath + "/" + path
11
+ var readFile = Platform.OS === 'ios' ? RNFS.readFile : RNFS.readFileRes
12
+ try {
13
+ return await readFile(path, 'base64')
14
+ } catch {
15
+ return null
16
+ }
17
+ }
18
+
19
+ export async function pickImage(): Promise<string | null> {
20
+ var response = await launchImageLibrary({
21
+ mediaType: 'photo',
22
+ selectionLimit: 1,
23
+ includeBase64: true
24
+ })
25
+ return "data:image/png;base64," + response?.assets?.[0].base64!
26
+ }
27
+
28
+ export async function chooseOption(): Promise<boolean | null> {
29
+ return new Promise<boolean | null>((resolve) => {
30
+ Alert.alert("Select option", "", [
31
+ { text: "Use gallery", onPress: () => { resolve(false) } },
32
+ { text: "Use camera", onPress: () => { resolve(true) } }
33
+ ], { cancelable: true, onDismiss: () => resolve(null) })
34
+ })
35
+ }
36
+
37
+ // --------------------------------------------------------------------------------------------------------------------
38
+
9
39
  var webViewRef: any
10
40
  const onclicks: any = {}
11
41
  const onMessage = (json: any) => {
@@ -50,45 +80,45 @@ const document = {
50
80
  }
51
81
 
52
82
  function parseValue(value: any) {
53
- if (value !== true && value !== false) return `"${value}"`
54
- return value
83
+ const json = JSON.stringify(value)
84
+ return typeof value === 'string' ? `(window.webImages[${json}] ?? ${json})` : json
55
85
  }
56
86
 
57
- (globalThis as any).document = document;
58
- registerRootComponent(() =>
59
- <WebView
60
- ref={ref => { webViewRef = ref }}
61
- onMessage={onMessage}
62
- source={require("./index.html")}
63
- scrollEnabled={false}
64
- overScrollMode={'content'}
65
- />
66
- )
87
+ async function loadWebUI() {
88
+ const webRoot = Platform.OS === 'ios' ? RNFS.MainBundlePath + '/web/' : 'web/'
89
+ const readWebFile = Platform.OS === 'ios' ? RNFS.readFile : RNFS.readFileAssets
90
+ const readWebDir = Platform.OS === 'ios' ? RNFS.readDir : RNFS.readDirAssets
91
+ const webImages: Record<string, string> = {}
92
+ const [styles, content] = await Promise.all(['src/main.css', 'src/main.html'].map(path => readWebFile(webRoot + path, 'utf8')))
67
93
 
68
- export async function loadAssetIfExists(path: string): Promise<string | null> {
69
- if (Platform.OS === 'ios') path = RNFS.MainBundlePath + "/" + path
70
- var readFile = Platform.OS === 'ios' ? RNFS.readFile : RNFS.readFileRes
71
- try {
72
- return await readFile(path, 'base64')
73
- } catch {
74
- return null
94
+ for (const file of (await readWebDir(webRoot + 'images')).filter(file => file.isFile())) {
95
+ const extension = file.name.split('.').pop()!.toLowerCase()
96
+ const type = ({ jpg: 'jpeg', svg: 'svg+xml' } as Record<string, string>)[extension] ?? extension
97
+ webImages['images/' + file.name] = `data:image/${type};base64,${await readWebFile(file.path, 'base64')}`
75
98
  }
76
- }
77
99
 
78
- export async function pickImage(): Promise<string | null> {
79
- var response = await launchImageLibrary({
80
- mediaType: 'photo',
81
- selectionLimit: 1,
82
- includeBase64: true
83
- })
84
- return "data:image/png;base64," + response?.assets?.[0].base64!
100
+ const html = content.replace(/src="([^"]+)"/g, (match, path) => webImages[path] ? `src="${webImages[path]}"` : match)
101
+ return `<meta name="viewport" content="initial-scale=1, user-scalable=no, viewport-fit=cover">
102
+ <style>${styles}</style>
103
+ <div id="content" style="height: 100%">${html}</div>
104
+ <script>
105
+ window.webImages = ${JSON.stringify(webImages)};
106
+ requestAnimationFrame(() => requestAnimationFrame(() => {
107
+ window.ReactNativeWebView.postMessage(JSON.stringify({ id: "ready" }))
108
+ }))
109
+ </script>`
85
110
  }
86
111
 
87
- export async function chooseOption(): Promise<boolean | null> {
88
- return new Promise<boolean | null>((resolve) => {
89
- Alert.alert("Select option", "", [
90
- { text: "Use gallery", onPress: () => { resolve(false) } },
91
- { text: "Use camera", onPress: () => { resolve(true) } }
92
- ], { cancelable: true, onDismiss: () => resolve(null) })
93
- })
94
- }
112
+ (globalThis as any).document = document;
113
+ registerRootComponent(() => {
114
+ const [html, setHtml] = React.useState('')
115
+ React.useEffect(() => { loadWebUI().then(setHtml).catch(console.error) }, [])
116
+ return html ? <WebView
117
+ ref={ref => { webViewRef = ref }}
118
+ onMessage={onMessage}
119
+ originWhitelist={['*']}
120
+ source={{ html }}
121
+ scrollEnabled={false}
122
+ overScrollMode={'content'}
123
+ /> : null
124
+ })
@@ -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 = config.watchFolders
6
- config.resolver.assetExts.push('css')
4
+ config.resolver.nodeModulesPaths = [__dirname + '/node_modules']
7
5
  module.exports = config