@regulaforensics/face-sdk 7.2.429-beta → 7.2.433-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.
Files changed (173) hide show
  1. package/README.md +3 -2
  2. package/RNFaceSDK.podspec +2 -2
  3. package/android/build.gradle +2 -2
  4. package/android/cordova.gradle +2 -2
  5. package/android/src/main/java/com/regula/plugin/facesdk/JSONConstructor.kt +0 -2
  6. package/android/src/main/java/com/regula/plugin/facesdk/Main.kt +0 -18
  7. package/examples/capacitor/android/app/src/main/AndroidManifest.xml +2 -2
  8. package/examples/capacitor/index.html +7 -2
  9. package/examples/capacitor/package-lock.json +162 -12
  10. package/examples/capacitor/package.json +4 -4
  11. package/examples/capacitor/scripts/setup.sh +2 -4
  12. package/examples/capacitor/src/main.css +6 -60
  13. package/examples/capacitor/src/main.html +1 -1
  14. package/examples/capacitor/src/main.tsx +87 -51
  15. package/examples/cordova/.vscode/launch.json +28 -0
  16. package/examples/cordova/README.md +25 -0
  17. package/examples/cordova/config.xml +26 -0
  18. package/examples/cordova/package-lock.json +1327 -0
  19. package/examples/cordova/package.json +30 -0
  20. package/examples/cordova/scripts/android.sh +8 -0
  21. package/examples/cordova/scripts/ios.sh +8 -0
  22. package/examples/cordova/scripts/setup.sh +8 -0
  23. package/examples/cordova/www/images/logo.png +0 -0
  24. package/examples/cordova/www/index.html +21 -0
  25. package/examples/cordova/www/src/main.css +83 -0
  26. package/examples/cordova/www/src/main.html +25 -0
  27. package/examples/cordova/www/src/main.js +152 -0
  28. package/examples/ionic/README.md +1 -1
  29. package/examples/ionic/angular.json +3 -3
  30. package/examples/ionic/config.xml +2 -4
  31. package/examples/ionic/index.ts +17 -0
  32. package/examples/ionic/package-lock.json +68 -42
  33. package/examples/ionic/package.json +2 -2
  34. package/examples/ionic/src/images/portrait.png +0 -0
  35. package/examples/ionic/src/main.css +6 -60
  36. package/examples/ionic/src/main.html +1 -1
  37. package/examples/ionic/src/{main.tsx → main.ts} +97 -52
  38. package/examples/ionic/tsconfig.json +2 -3
  39. package/examples/react_native/README.md +0 -1
  40. package/examples/react_native/app.config.ts +1 -1
  41. package/examples/react_native/index.tsx +7 -49
  42. package/examples/react_native/package-lock.json +597 -594
  43. package/examples/react_native/package.json +9 -9
  44. package/examples/react_native/src/main.css +6 -60
  45. package/examples/react_native/src/main.html +1 -1
  46. package/examples/react_native/src/main.tsx +77 -54
  47. package/ios/RFSWJSONConstructor.h +1 -0
  48. package/ios/RFSWJSONConstructor.m +14 -5
  49. package/ios/RFSWMain.m +0 -30
  50. package/package.json +1 -1
  51. package/plugin.xml +2 -2
  52. package/www/capacitor/customization/customization_fonts.js +1 -1
  53. package/www/capacitor/customization/customization_images.js +1 -1
  54. package/www/capacitor/customization/font.js +0 -8
  55. package/www/capacitor/detect_faces/detect_face_result.js +0 -12
  56. package/www/capacitor/detect_faces/detect_faces_attribute_result.js +0 -9
  57. package/www/capacitor/detect_faces/detect_faces_backend_exception.js +0 -7
  58. package/www/capacitor/detect_faces/detect_faces_config.js +0 -34
  59. package/www/capacitor/detect_faces/detect_faces_exception.js +0 -8
  60. package/www/capacitor/detect_faces/detect_faces_request.js +0 -22
  61. package/www/capacitor/detect_faces/detect_faces_response.js +0 -9
  62. package/www/capacitor/face_capture/face_capture_config.js +0 -37
  63. package/www/capacitor/face_capture/face_capture_exception.js +0 -7
  64. package/www/capacitor/face_capture/face_capture_image.js +0 -8
  65. package/www/capacitor/face_capture/face_capture_response.js +0 -7
  66. package/www/capacitor/image_params/output_image_crop.js +0 -23
  67. package/www/capacitor/image_params/output_image_params.js +0 -19
  68. package/www/capacitor/image_params/point.js +0 -7
  69. package/www/capacitor/image_params/rect.js +0 -9
  70. package/www/capacitor/image_params/size.js +0 -12
  71. package/www/capacitor/image_quality/image_quality_characteristic.js +0 -22
  72. package/www/capacitor/image_quality/image_quality_range.js +0 -7
  73. package/www/capacitor/image_quality/image_quality_result.js +0 -10
  74. package/www/capacitor/index.js +0 -48
  75. package/www/capacitor/init/face_sdk_version.js +0 -8
  76. package/www/capacitor/init/init_config.js +0 -19
  77. package/www/capacitor/init/init_exception.js +0 -8
  78. package/www/capacitor/init/license_exception.js +0 -7
  79. package/www/capacitor/internal/bridge.js +1 -20
  80. package/www/capacitor/liveness/liveness_backend_exception.js +0 -7
  81. package/www/capacitor/liveness/liveness_config.js +0 -43
  82. package/www/capacitor/liveness/liveness_exception.js +0 -8
  83. package/www/capacitor/liveness/liveness_notification.js +0 -7
  84. package/www/capacitor/liveness/liveness_response.js +0 -11
  85. package/www/capacitor/match_faces/compared_face.js +0 -9
  86. package/www/capacitor/match_faces/compared_faces_pair.js +0 -10
  87. package/www/capacitor/match_faces/compared_faces_split.js +0 -7
  88. package/www/capacitor/match_faces/match_faces_backend_exception.js +0 -7
  89. package/www/capacitor/match_faces/match_faces_config.js +0 -19
  90. package/www/capacitor/match_faces/match_faces_detection.js +0 -9
  91. package/www/capacitor/match_faces/match_faces_detection_face.js +0 -11
  92. package/www/capacitor/match_faces/match_faces_exception.js +0 -8
  93. package/www/capacitor/match_faces/match_faces_image.js +0 -9
  94. package/www/capacitor/match_faces/match_faces_request.js +0 -27
  95. package/www/capacitor/match_faces/match_faces_response.js +0 -9
  96. package/www/capacitor/person_database/edit_group_persons_request.js +0 -15
  97. package/www/capacitor/person_database/image_upload.js +0 -17
  98. package/www/capacitor/person_database/pageable_item_list.js +0 -8
  99. package/www/capacitor/person_database/person.js +0 -13
  100. package/www/capacitor/person_database/person_group.js +0 -11
  101. package/www/capacitor/person_database/person_image.js +0 -13
  102. package/www/capacitor/person_database/search_person.js +0 -14
  103. package/www/capacitor/person_database/search_person_detection.js +0 -9
  104. package/www/capacitor/person_database/search_person_image.js +0 -15
  105. package/www/capacitor/person_database/search_person_request.js +0 -29
  106. package/www/cordova.js +6 -753
  107. package/www/react-native/customization/customization_fonts.js +1 -1
  108. package/www/react-native/customization/customization_images.js +1 -1
  109. package/www/react-native/customization/font.js +0 -8
  110. package/www/react-native/detect_faces/detect_face_result.js +0 -12
  111. package/www/react-native/detect_faces/detect_faces_attribute_result.js +0 -9
  112. package/www/react-native/detect_faces/detect_faces_backend_exception.js +0 -7
  113. package/www/react-native/detect_faces/detect_faces_config.js +0 -34
  114. package/www/react-native/detect_faces/detect_faces_exception.js +0 -8
  115. package/www/react-native/detect_faces/detect_faces_request.js +0 -22
  116. package/www/react-native/detect_faces/detect_faces_response.js +0 -9
  117. package/www/react-native/face_capture/face_capture_config.js +0 -37
  118. package/www/react-native/face_capture/face_capture_exception.js +0 -7
  119. package/www/react-native/face_capture/face_capture_image.js +0 -8
  120. package/www/react-native/face_capture/face_capture_response.js +0 -7
  121. package/www/react-native/image_params/output_image_crop.js +0 -23
  122. package/www/react-native/image_params/output_image_params.js +0 -19
  123. package/www/react-native/image_params/point.js +0 -7
  124. package/www/react-native/image_params/rect.js +0 -9
  125. package/www/react-native/image_params/size.js +0 -12
  126. package/www/react-native/image_quality/image_quality_characteristic.js +0 -22
  127. package/www/react-native/image_quality/image_quality_range.js +0 -7
  128. package/www/react-native/image_quality/image_quality_result.js +0 -10
  129. package/www/react-native/index.js +0 -48
  130. package/www/react-native/init/face_sdk_version.js +0 -8
  131. package/www/react-native/init/init_config.js +0 -19
  132. package/www/react-native/init/init_exception.js +0 -8
  133. package/www/react-native/init/license_exception.js +0 -7
  134. package/www/react-native/internal/bridge.js +1 -20
  135. package/www/react-native/liveness/liveness_backend_exception.js +0 -7
  136. package/www/react-native/liveness/liveness_config.js +0 -43
  137. package/www/react-native/liveness/liveness_exception.js +0 -8
  138. package/www/react-native/liveness/liveness_notification.js +0 -7
  139. package/www/react-native/liveness/liveness_response.js +0 -11
  140. package/www/react-native/match_faces/compared_face.js +0 -9
  141. package/www/react-native/match_faces/compared_faces_pair.js +0 -10
  142. package/www/react-native/match_faces/compared_faces_split.js +0 -7
  143. package/www/react-native/match_faces/match_faces_backend_exception.js +0 -7
  144. package/www/react-native/match_faces/match_faces_config.js +0 -19
  145. package/www/react-native/match_faces/match_faces_detection.js +0 -9
  146. package/www/react-native/match_faces/match_faces_detection_face.js +0 -11
  147. package/www/react-native/match_faces/match_faces_exception.js +0 -8
  148. package/www/react-native/match_faces/match_faces_image.js +0 -9
  149. package/www/react-native/match_faces/match_faces_request.js +0 -27
  150. package/www/react-native/match_faces/match_faces_response.js +0 -9
  151. package/www/react-native/person_database/edit_group_persons_request.js +0 -15
  152. package/www/react-native/person_database/image_upload.js +0 -17
  153. package/www/react-native/person_database/pageable_item_list.js +0 -8
  154. package/www/react-native/person_database/person.js +0 -13
  155. package/www/react-native/person_database/person_group.js +0 -11
  156. package/www/react-native/person_database/person_image.js +0 -13
  157. package/www/react-native/person_database/search_person.js +0 -14
  158. package/www/react-native/person_database/search_person_detection.js +0 -9
  159. package/www/react-native/person_database/search_person_image.js +0 -15
  160. package/www/react-native/person_database/search_person_request.js +0 -29
  161. package/www/types/index.d.ts +0 -12
  162. package/www/types/match_faces/match_faces_config.d.ts +0 -2
  163. package/www/types/person_database/search_person_request.d.ts +0 -4
  164. package/examples/capacitor/index.tsx +0 -53
  165. package/examples/ionic/index.tsx +0 -68
  166. package/test/json.tsx +0 -375
  167. package/test/package-lock.json +0 -584
  168. package/test/package.json +0 -9
  169. package/test/test.tsx +0 -61
  170. package/test/utils.tsx +0 -38
  171. /package/examples/{ionic → cordova/www}/images/portrait.png +0 -0
  172. /package/examples/ionic/{assets → src/assets}/.gitkeep +0 -0
  173. /package/examples/ionic/{images → src/images}/icon.png +0 -0
@@ -1,19 +1,15 @@
1
1
  html,
2
2
  body {
3
- margin: 0;
4
- width: 100%;
3
+ width: 99%;
5
4
  height: 99vh;
6
5
  display: flex;
7
- overflow: hidden;
8
6
  flex-direction: column;
9
7
  }
10
8
 
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;
9
+ .page {
10
+ height: 100%;
11
+ display: flex;
12
+ flex-direction: column;
17
13
  }
18
14
 
19
15
  .column {
@@ -56,14 +52,10 @@ body {
56
52
  margin-top: 13px;
57
53
  }
58
54
 
59
- .scroll {
60
- flex-grow: 1;
61
- overflow-y: auto;
62
- }
63
-
64
55
  .no-scroll {
65
56
  flex-grow: 1;
66
57
  overflow-y: hidden;
58
+ overflow-x: hidden;
67
59
  }
68
60
 
69
61
  .button {
@@ -75,7 +67,6 @@ body {
75
67
  color: white;
76
68
  border: none;
77
69
  padding: 10px 20px;
78
- justify-content: center;
79
70
  font-size: 16px;
80
71
  border-radius: 100px;
81
72
  cursor: pointer;
@@ -89,49 +80,4 @@ body {
89
80
  .button:active {
90
81
  position: relative;
91
82
  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
- .progress-bar {
124
- width: 75%;
125
- padding: 3px;
126
- margin-top: 40px;
127
- background-color: #eee;
128
- border-radius: 8px;
129
- box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
130
- }
131
-
132
- #progress {
133
- width: 0%;
134
- height: 20px;
135
- background-color: #4285F4;
136
- border-radius: 5px;
137
83
  }
@@ -1,4 +1,4 @@
1
- <div class="column" style="height: 100%">
1
+ <div class="page">
2
2
  <div class="column header">
3
3
  <span id="status">Loading...</span>
4
4
  <div class="column divider"></div>
@@ -1,21 +1,15 @@
1
+ import { Component } from '@angular/core'
2
+ import { Dialogs } from '@awesome-cordova-plugins/dialogs/ngx'
3
+ import { File } from '@awesome-cordova-plugins/file'
4
+ import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera/ngx'
5
+ import { Platform } from '@ionic/angular'
1
6
  import { FaceSDK, MatchFacesRequest, MatchFacesImage, InitConfig, LivenessSkipStep, ImageType, LivenessStatus, LivenessConfig } from '@regulaforensics/face-sdk'
2
- import { loadAssetIfExists, chooseOption, pickImage } from '../index'
3
-
4
- var faceSdk = FaceSDK.instance
5
- var image1: MatchFacesImage | null
6
- var image2: MatchFacesImage | null
7
7
 
8
8
  async function init() {
9
- if (!await initializeReader()) return
9
+ if (!await initialize()) return
10
10
  setStatus("Ready")
11
11
  }
12
12
 
13
- async function startFaceCapture(position: number) {
14
- var image = (await faceSdk.startFaceCapture()).image
15
- if (image == null) return
16
- setImage("data:image/png;base64," + image.image, image.imageType, position)
17
- }
18
-
19
13
  async function startLiveness() {
20
14
  var response = await faceSdk.startLiveness({
21
15
  config: new LivenessConfig({
@@ -46,15 +40,30 @@ async function matchFaces() {
46
40
  setStatus("Ready")
47
41
  }
48
42
 
49
- async function getImage(position: number) {
50
- var source = await chooseOption()
51
- if (source == null) return
52
- if (source) startFaceCapture(position)
53
- else {
54
- var image = await pickImage()
55
- if (image == null) return
56
- setImage(image, ImageType.PRINTED, position)
43
+ function clearResults() {
44
+ setStatus("Ready")
45
+ setSimilarityStatus("null")
46
+ setLivenessStatus("null")
47
+ resetImages()
48
+ image1 = null
49
+ image2 = null
50
+ }
51
+
52
+ // If 'regula.license' exists, init using license(enables offline match)
53
+ // otherwise init without license.
54
+ async function initialize() {
55
+ setStatus("Initializing...")
56
+
57
+ var license = await loadAssetIfExists("regula.license")
58
+ var config: InitConfig | undefined
59
+ if (license != null) config = new InitConfig(license)
60
+ var [success, error] = await faceSdk.initialize({ config: config })
61
+
62
+ if (!success && error != null) {
63
+ setStatus(error.message)
64
+ console.log(error.code + ": " + error.message)
57
65
  }
66
+ return success
58
67
  }
59
68
 
60
69
  function setImage(base64: string, type: number, position: number) {
@@ -71,46 +80,82 @@ function setImage(base64: string, type: number, position: number) {
71
80
  }
72
81
  }
73
82
 
74
- // If 'regula.license' exists, init using license(enables offline match)
75
- // otherwise init without license.
76
- async function initializeReader() {
77
- setStatus("Initializing...")
78
-
79
- var license = await loadAssetIfExists("regula.license")
80
- var config: InitConfig | undefined
81
- if (license != null) config = new InitConfig(license)
82
- var [success, error] = await faceSdk.initialize({ config: config })
83
-
84
- if (error != null) {
85
- setStatus(error.message)
86
- console.log(error.code + ": " + error.message)
87
- }
88
- return success
83
+ async function useCamera(position: number) {
84
+ var response = await faceSdk.startFaceCapture()
85
+ if (response.image == null) return
86
+ var image = response.image
87
+ setImage("data:image/png;base64," + image.image, image.imageType, position)
89
88
  }
90
89
 
91
- // --------------------------------------------------------------------------------------------------------------------
90
+ async function useGallery(position: number) {
91
+ var image = await app.camera.getPicture({
92
+ destinationType: DestinationType.DATA_URL,
93
+ mediaType: MediaType.PICTURE,
94
+ sourceType: PictureSourceType.PHOTOLIBRARY
95
+ })
96
+ setImage(image, ImageType.PRINTED, position)
97
+ }
92
98
 
93
- export function main() {
94
- document.getElementById("first-image")!.onclick = () => getImage(1)
95
- document.getElementById("second-image")!.onclick = () => getImage(2)
96
- document.getElementById("match-faces")!.onclick = () => matchFaces()
97
- document.getElementById("start-liveness")!.onclick = () => startLiveness()
98
- document.getElementById("clear-results")!.onclick = () => clearResults()
99
+ async function pickImage(position: number) {
100
+ var option = await app.dialogs.confirm("", "Select option", ["Use gallery", "Use camera"])
101
+ if (option == 1) useGallery(position)
102
+ else useCamera(position)
103
+ }
99
104
 
100
- init()
105
+ async function loadAssetIfExists(path: string): Promise<string | null> {
106
+ try {
107
+ var dir = await File.resolveDirectoryUrl(File.applicationDirectory + "www/assets")
108
+ var fileEntry = await File.getFile(dir, path, null)
109
+ var result = await new Promise<string | null>((resolve, _) => {
110
+ fileEntry.file(file => {
111
+ var reader = new FileReader()
112
+ reader.onloadend = (_) => resolve(reader.result as string)
113
+ reader.readAsDataURL(file)
114
+ }, _ => resolve(null))
115
+ })
116
+ return result
117
+ } catch (_) {
118
+ return null
119
+ }
101
120
  }
102
121
 
103
- var setStatus = (data: string) => document.getElementById("status")!.innerHTML = data
104
- var setLivenessStatus = (data: string) => document.getElementById("liveness-status")!.innerHTML = data
105
- var setSimilarityStatus = (data: string) => document.getElementById("similarity-status")!.innerHTML = data
122
+ var app: Main
123
+ var faceSdk = FaceSDK.instance
124
+ var image1: MatchFacesImage | null
125
+ var image2: MatchFacesImage | null
126
+
127
+ var setStatus = (data: string) => document.getElementById("status").innerHTML = data
128
+ var setLivenessStatus = (data: string) => document.getElementById("liveness-status").innerHTML = data
129
+ var setSimilarityStatus = (data: string) => document.getElementById("similarity-status").innerHTML = data
106
130
  var setUiImage1 = (data: string) => (document.getElementById("first-image") as HTMLImageElement).src = data
107
131
  var setUiImage2 = (data: string) => (document.getElementById("second-image") as HTMLImageElement).src = data
108
- var clearResults = () => {
109
- setStatus("Ready")
110
- setSimilarityStatus("null")
111
- setLivenessStatus("null")
132
+ var resetImages = () => {
112
133
  setUiImage1("images/portrait.png")
113
134
  setUiImage2("images/portrait.png")
114
- image1 = null
115
- image2 = null
135
+ }
136
+
137
+ @Component({
138
+ selector: 'app-root',
139
+ templateUrl: 'main.html',
140
+ styleUrl: 'main.css'
141
+ })
142
+ export class Main {
143
+ dialogs: Dialogs
144
+ camera: Camera
145
+
146
+ constructor(platform: Platform, dialogs: Dialogs, camera: Camera) {
147
+ platform.ready().then(() => {
148
+ this.dialogs = dialogs
149
+ this.camera = camera
150
+ app = this
151
+
152
+ document.getElementById("first-image").onclick = () => pickImage(1)
153
+ document.getElementById("second-image").onclick = () => pickImage(2)
154
+ document.getElementById("match-faces").onclick = () => matchFaces()
155
+ document.getElementById("start-liveness").onclick = () => startLiveness()
156
+ document.getElementById("clear-results").onclick = () => clearResults()
157
+
158
+ init()
159
+ });
160
+ }
116
161
  }
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "include": [
3
- "*.tsx"
3
+ "*.ts"
4
4
  ],
5
5
  "compilerOptions": {
6
6
  "types": [],
7
7
  "module": "esnext",
8
8
  "moduleResolution": "node",
9
9
  "experimentalDecorators": true,
10
- "target": "es2022",
11
- "jsx": "react-jsx"
10
+ "target": "es2022"
12
11
  }
13
12
  }
@@ -19,7 +19,6 @@
19
19
  ```bash
20
20
  npm uninstall @regulaforensics/face-core-basic
21
21
  npm install @regulaforensics/face-core-match
22
- (cd ios && pod install)
23
22
  npm run setup
24
23
  ```
25
24
 
@@ -33,7 +33,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
33
33
  { url: 'https://maven.regulaforensics.com/RegulaDocumentReader/Stage' }
34
34
  ]
35
35
  },
36
- // This fixes a bug in expo v53. https://github.com/expo/expo/issues/36908
36
+ // This fixes a bug in expo v53. https://github.com/expo/expo/issues/36908
37
37
  ios: { networkInspector: false }
38
38
  }]
39
39
  ]
@@ -1,22 +1,18 @@
1
1
  import { registerRootComponent } from 'expo'
2
2
  import WebView from 'react-native-webview'
3
- import React from 'react'
4
- import * as RNFS from 'react-native-fs'
5
- import { Alert, Platform } from 'react-native'
6
- import { launchImageLibrary } from 'react-native-image-picker'
7
- import { main } from './src/main'
3
+ import { onload } from './src/main'
8
4
 
9
5
  var webViewRef: any
10
6
  const onclicks: any = {}
11
7
  const onMessage = (json: any) => {
12
8
  const event = JSON.parse(json.nativeEvent.data)
13
- if (event.id === "ready") main()
9
+ if (event.id === "ready") onload()
14
10
  if (event.id === "onclick") {
15
11
  onclicks[event.value]()
16
12
  }
17
13
  }
18
14
 
19
- const document = {
15
+ export const document = {
20
16
  getElementById(id: string): any {
21
17
  return new Proxy({}, {
22
18
  set(_, prop: string, value) {
@@ -28,67 +24,29 @@ const document = {
28
24
  }; true
29
25
  `)
30
26
  } else
31
- webViewRef.injectJavaScript(`document.getElementById("${id}").${prop} = ${parseValue(value)}; true`)
27
+ webViewRef.injectJavaScript(`document.getElementById("${id}").${prop} = "${value}"; true`)
32
28
  return true
33
29
  },
34
30
  get(_, prop: string) {
35
31
  if (prop === "style") return new Proxy({}, {
36
32
  set(_, styleProp: string, value) {
37
- webViewRef.injectJavaScript(`document.getElementById("${id}").style.${styleProp} = ${parseValue(value)}; true`)
33
+ webViewRef.injectJavaScript(`document.getElementById("${id}").style.${styleProp} = "${value}"; true`)
38
34
  return true
39
35
  }
40
36
  })
41
- if (prop === "insertAdjacentHTML") return (position: string, html: string) => {
42
- webViewRef.injectJavaScript(`document.getElementById("${id}").insertAdjacentHTML('${position}', \`${html}\`); true`)
43
- return true
44
- }
45
37
  return undefined
46
- }
38
+ },
47
39
  }
48
40
  )
49
41
  }
50
42
  }
51
43
 
52
- function parseValue(value: any) {
53
- if (value !== true && value !== false) return `"${value}"`
54
- return value
55
- }
56
-
57
- (globalThis as any).document = document;
58
44
  registerRootComponent(() =>
59
45
  <WebView
60
46
  ref={ref => { webViewRef = ref }}
61
47
  onMessage={onMessage}
62
48
  source={require("./index.html")}
63
49
  scrollEnabled={false}
64
- overScrollMode={'content'}
50
+ injectedJavaScript="document.body.addEventListener('touchmove', function(e) { e.preventDefault() }, { passive: false })"
65
51
  />
66
52
  )
67
-
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
75
- }
76
- }
77
-
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!
85
- }
86
-
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
- }