@regulaforensics/react-native-document-reader-api 8.1.136-nightly → 8.1.138-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.
Files changed (36) hide show
  1. package/RNDocumentReaderApi.podspec +1 -1
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/AndroidManifest.xml +1 -1
  4. package/android/src/main/java/com/regula/{documentreader → plugin/documentreader}/BluetoothUtil.kt +7 -16
  5. package/android/src/main/java/com/regula/{documentreader → plugin/documentreader}/Config.kt +154 -120
  6. package/android/src/main/java/com/regula/plugin/documentreader/JSONConstructor.kt +1778 -0
  7. package/android/src/main/java/com/regula/plugin/documentreader/Main.kt +553 -0
  8. package/android/src/main/java/com/regula/plugin/documentreader/RNRegulaDocumentReaderModule.kt +103 -0
  9. package/android/src/main/java/com/regula/plugin/documentreader/Utils.kt +181 -0
  10. package/example/android/app/build.gradle +7 -4
  11. package/example/android/app/src/debug/java/com/regula/dr/fullrfid/ReactNativeFlipper.java +1 -1
  12. package/example/android/app/src/main/java/com/regula/dr/{fullrfid → fullauthrfid}/MainActivity.java +1 -1
  13. package/example/android/app/src/main/java/com/regula/dr/{fullrfid → fullauthrfid}/MainApplication.java +10 -3
  14. package/example/android/app/src/release/java/com/regula/dr/fullrfid/ReactNativeFlipper.java +1 -1
  15. package/example/android/build.gradle +5 -5
  16. package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  17. package/example/android/settings.gradle +4 -2
  18. package/example/ios/DocumentReader/AppDelegate.mm +5 -0
  19. package/example/ios/DocumentReader/Info.plist +22 -0
  20. package/example/ios/DocumentReader.xcodeproj/project.pbxproj +4 -14
  21. package/example/ios/Podfile +1 -6
  22. package/example/package-lock.json +2665 -1874
  23. package/example/package.json +25 -22
  24. package/ios/RGLWConfig.h +0 -8
  25. package/ios/RGLWConfig.m +44 -52
  26. package/ios/RGLWJSONConstructor.h +1 -8
  27. package/ios/RGLWJSONConstructor.m +12 -10
  28. package/ios/RGLWMain.h +36 -0
  29. package/ios/RGLWMain.m +591 -0
  30. package/ios/RNRegulaDocumentReader.h +4 -20
  31. package/ios/RNRegulaDocumentReader.m +18 -726
  32. package/package.json +1 -1
  33. package/android/src/main/java/com/regula/documentreader/JSONConstructor.kt +0 -2227
  34. package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderModule.kt +0 -560
  35. package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderPackage.kt +0 -11
  36. package/android/src/main/java/com/regula/documentreader/Utils.kt +0 -268
@@ -0,0 +1,181 @@
1
+ @file:SuppressLint("UseKtx")
2
+
3
+ package com.regula.plugin.documentreader
4
+
5
+ import android.annotation.SuppressLint
6
+ import android.graphics.Bitmap
7
+ import android.graphics.BitmapFactory
8
+ import android.graphics.Canvas
9
+ import android.graphics.drawable.BitmapDrawable
10
+ import android.graphics.drawable.Drawable
11
+ import android.util.Base64
12
+ import org.json.JSONArray
13
+ import org.json.JSONObject
14
+ import java.io.ByteArrayOutputStream
15
+ import kotlin.math.sqrt
16
+
17
+ fun List<*>.toJson(): JSONArray {
18
+ val result = JSONArray()
19
+ for (i in indices)
20
+ when (val v = this[i]) {
21
+ null -> result.put(null)
22
+ is Map<*, *> -> result.put(v.toJson())
23
+ is List<*> -> result.put(v.toJson())
24
+ else -> result.put(v)
25
+ }
26
+ return result
27
+ }
28
+
29
+ fun Map<*, *>.toJson(): JSONObject {
30
+ val result = JSONObject()
31
+ for ((k, v) in this) {
32
+ when (v) {
33
+ null -> result.put(k as String, null)
34
+ is Map<*, *> -> result.put(k as String, v.toJson())
35
+ is List<*> -> result.put(k as String, v.toJson())
36
+ else -> result.put(k as String, v)
37
+ }
38
+ }
39
+ return result
40
+ }
41
+
42
+ fun Any?.toSendable(): Any? = this?.let {
43
+ if (it is JSONObject || it is JSONArray) it.toString()
44
+ else it
45
+ }
46
+
47
+ fun <T> List<T>?.toJson(toJson: (T?) -> Any?) = this?.let {
48
+ val result = JSONArray()
49
+ for (item in it) result.put(toJson(item))
50
+ result
51
+ }
52
+
53
+ fun <T> List<T>?.toJsonNullable(toJson: (T?) -> Any?) = this?.let {
54
+ val result = JSONArray()
55
+ for (item in it) result.put(toJson(item))
56
+ result
57
+ }
58
+
59
+ fun <T> JSONArray?.toList(fromJson: (JSONObject) -> T) = this?.let {
60
+ val result: MutableList<T> = ArrayList()
61
+ for (i in 0 until it.length()) result.add(fromJson(it.getJSONObject(i)))
62
+ result
63
+ }
64
+
65
+ fun <T> JSONArray.toList() = this.let {
66
+ val result = mutableListOf<T>()
67
+ @Suppress("UNCHECKED_CAST")
68
+ for (i in 0 until length()) result.add(get(i) as T)
69
+ result
70
+ }
71
+
72
+ inline fun <reified T> JSONArray?.toArray() = this?.let {
73
+ val result = arrayOfNulls<T>(length())
74
+ for (i in 0 until length()) result[i] = get(i) as T
75
+ result
76
+ }
77
+
78
+ inline fun <reified T> JSONArray?.toArray(fromJson: (JSONObject?) -> T) = this?.let {
79
+ val result = arrayOfNulls<T>(length())
80
+ for (i in 0 until length()) result[i] = fromJson(getJSONObject(i))
81
+ result
82
+ }
83
+
84
+ fun <T> Array<T>?.toJson() = this?.let {
85
+ val result = JSONArray()
86
+ for (i in it.indices) result.put(i, it[i])
87
+ result
88
+ }
89
+
90
+ fun <T> Array<T>?.toJson(toJson: (T?) -> JSONObject?) = this?.let {
91
+ val result = JSONArray()
92
+ for (i in indices) result.put(i, toJson(this[i]))
93
+ result
94
+ }
95
+
96
+ fun Any?.toIntArray() = (this as JSONArray?)?.let {
97
+ val result = IntArray(it.length())
98
+ for (i in 0 until it.length()) result[i] = it.getInt(i)
99
+ result
100
+ }
101
+
102
+ fun IntArray?.toJson() = this?.let {
103
+ val result = JSONArray()
104
+ for (i in it.indices) result.put(i, it[i])
105
+ result
106
+ }
107
+
108
+ fun JSONObject.forEach(action: (String, Any) -> Unit) {
109
+ val keys: Iterator<String> = keys()
110
+ while (keys.hasNext()) {
111
+ val key = keys.next()
112
+ action(key, get(key))
113
+ }
114
+ }
115
+
116
+ fun JSONObject.getJSONObjectOrNull(name: String): JSONObject? {
117
+ if (has(name) && get(name).toString() != "null") return getJSONObject(name)
118
+ return null
119
+ }
120
+
121
+ fun JSONObject.getIntOrNull(name: String): Int? {
122
+ if (has(name) && get(name).toString() != "null") return getInt(name)
123
+ return null
124
+ }
125
+
126
+ fun JSONObject.getDoubleOrNull(name: String): Double? {
127
+ if (has(name) && get(name).toString() != "null") return getDouble(name)
128
+ return null
129
+ }
130
+
131
+ fun JSONObject.getBooleanOrNull(name: String): Boolean? {
132
+ if (has(name) && get(name).toString() != "null") return getBoolean(name)
133
+ return null
134
+ }
135
+
136
+ fun JSONObject.getStringOrNull(name: String): String? {
137
+ if (has(name) && get(name).toString() != "null") return getString(name)
138
+ return null
139
+ }
140
+
141
+ internal object Convert {
142
+ fun String?.toByteArray(): ByteArray? {
143
+ var str = this ?: return null
144
+ if (str.startsWith("data")) str = str.substring(str.indexOf(",") + 1)
145
+ return Base64.decode(str, Base64.NO_WRAP)
146
+ }
147
+
148
+ fun ByteArray?.toBase64() = this?.let { Base64.encodeToString(it, Base64.NO_WRAP) }
149
+
150
+ fun Bitmap?.toBase64() = this?.let {
151
+ val byteArrayOutputStream = ByteArrayOutputStream()
152
+ it.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream)
153
+ byteArrayOutputStream.toByteArray().toBase64()
154
+ }
155
+
156
+ fun String?.toBitmap() = this?.let {
157
+ val decodedString = toByteArray()!!
158
+ var result = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.size)
159
+ val sizeMultiplier = result.byteCount / 5000000
160
+ if (result.byteCount > 5000000) result = Bitmap.createScaledBitmap(result, result.width / sqrt(sizeMultiplier.toDouble()).toInt(), result.height / sqrt(sizeMultiplier.toDouble()).toInt(), false)
161
+ result
162
+ }
163
+
164
+ fun Any?.toDrawable() = (this as String?)?.let {
165
+ val decodedByte = it.toByteArray()!!
166
+ val bitmap = BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.size)
167
+ val density = context.resources.displayMetrics.density
168
+ val width = (bitmap.width * density).toInt()
169
+ val height = (bitmap.height * density).toInt()
170
+ BitmapDrawable(context.resources, Bitmap.createScaledBitmap(bitmap, width, height, false))
171
+ }
172
+
173
+ fun Drawable?.toBase64() = this?.let {
174
+ if (this is BitmapDrawable) if (bitmap != null) return bitmap.toBase64()
175
+ val bitmap: Bitmap = if (intrinsicWidth <= 0 || intrinsicHeight <= 0) Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888) else Bitmap.createBitmap(intrinsicWidth, intrinsicHeight, Bitmap.Config.ARGB_8888)
176
+ val canvas = Canvas(bitmap)
177
+ setBounds(0, 0, canvas.width, canvas.height)
178
+ draw(canvas)
179
+ bitmap.toBase64()
180
+ }
181
+ }
@@ -1,6 +1,7 @@
1
1
  apply plugin: "com.android.application"
2
2
  apply plugin: "com.facebook.react"
3
3
 
4
+
4
5
  /**
5
6
  * This is the configuration block to customize your React Native Android app.
6
7
  * By default you don't need to apply any configuration, just uncomment the lines you need.
@@ -48,6 +49,9 @@ react {
48
49
  //
49
50
  // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
50
51
  // hermesFlags = ["-O", "-output-source-map"]
52
+
53
+ /* Autolinking */
54
+ autolinkLibrariesWithApp()
51
55
  }
52
56
 
53
57
  /**
@@ -73,9 +77,9 @@ android {
73
77
 
74
78
  compileSdk rootProject.ext.compileSdkVersion
75
79
 
76
- namespace "com.regula.dr.fullrfid"
80
+ namespace "com.regula.dr.fullauthrfid"
77
81
  defaultConfig {
78
- applicationId "com.regula.dr.fullrfid"
82
+ applicationId "com.regula.dr.fullauthrfid"
79
83
  minSdkVersion rootProject.ext.minSdkVersion
80
84
  targetSdkVersion rootProject.ext.targetSdkVersion
81
85
  versionCode 1
@@ -120,5 +124,4 @@ dependencies {
120
124
  }
121
125
  }
122
126
 
123
- apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
124
- apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
127
+ apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
@@ -4,7 +4,7 @@
4
4
  * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5
5
  * directory of this source tree.
6
6
  */
7
- package com.regula.dr.fullrfid;
7
+ package com.regula.dr.fullauthrfid;
8
8
 
9
9
  import android.content.Context;
10
10
  import com.facebook.flipper.android.AndroidFlipperClient;
@@ -1,4 +1,4 @@
1
- package com.regula.dr.fullrfid;
1
+ package com.regula.dr.fullauthrfid;
2
2
 
3
3
  import com.facebook.react.ReactActivity;
4
4
  import com.facebook.react.ReactActivityDelegate;
@@ -1,4 +1,4 @@
1
- package com.regula.dr.fullrfid;
1
+ package com.regula.dr.fullauthrfid;
2
2
 
3
3
  import android.app.Application;
4
4
  import com.facebook.react.PackageList;
@@ -8,7 +8,10 @@ import com.facebook.react.ReactPackage;
8
8
  import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
9
9
  import com.facebook.react.defaults.DefaultReactNativeHost;
10
10
  import com.facebook.soloader.SoLoader;
11
+
12
+ import java.io.IOException;
11
13
  import java.util.List;
14
+ import com.facebook.react.soloader.OpenSourceMergedSoMapping;
12
15
 
13
16
  public class MainApplication extends Application implements ReactApplication {
14
17
 
@@ -52,8 +55,12 @@ public class MainApplication extends Application implements ReactApplication {
52
55
  @Override
53
56
  public void onCreate() {
54
57
  super.onCreate();
55
- SoLoader.init(this, /* native exopackage */ false);
56
- if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
58
+ try {
59
+ SoLoader.init(this, OpenSourceMergedSoMapping.INSTANCE);
60
+ } catch (IOException e) {
61
+ throw new RuntimeException(e);
62
+ }
63
+ if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
57
64
  // If you opted-in for the New Architecture, we load the native entry point for this app.
58
65
  DefaultNewArchitectureEntryPoint.load();
59
66
  }
@@ -4,7 +4,7 @@
4
4
  * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5
5
  * directory of this source tree.
6
6
  */
7
- package com.regula.dr.fullrfid;
7
+ package com.regula.dr.fullauthrfid;
8
8
 
9
9
  import android.content.Context;
10
10
  import com.facebook.react.ReactInstanceManager;
@@ -1,12 +1,12 @@
1
1
  buildscript {
2
2
  ext {
3
- buildToolsVersion = "33.0.0"
4
- minSdkVersion = 21
5
- compileSdkVersion = 34
3
+ buildToolsVersion = "35.0.0"
4
+ minSdkVersion = 24
5
+ compileSdkVersion = 35
6
6
  targetSdkVersion = 34
7
7
 
8
- // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
9
- ndkVersion = "23.1.7779620"
8
+ ndkVersion = "26.1.10909125"
9
+ kotlinVersion = "1.9.25"
10
10
  }
11
11
  repositories {
12
12
  google()
@@ -1,6 +1,6 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
4
4
  networkTimeout=10000
5
5
  zipStoreBase=GRADLE_USER_HOME
6
6
  zipStorePath=wrapper/dists
@@ -1,4 +1,6 @@
1
- rootProject.name = 'com.regula.dr.fullrfid'
2
- apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
1
+ pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
2
+ plugins { id("com.facebook.react.settings") }
3
+ extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
4
+ rootProject.name = 'com.regula.dr.fullauthrfid'
3
5
  include ':app'
4
6
  includeBuild('../node_modules/@react-native/gradle-plugin')
@@ -15,6 +15,11 @@
15
15
  }
16
16
 
17
17
  - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
18
+ {
19
+ return [self bundleURL];
20
+ }
21
+
22
+ - (NSURL *)bundleURL
18
23
  {
19
24
  #if DEBUG
20
25
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
@@ -69,5 +69,27 @@
69
69
  <string>A0000002480300</string>
70
70
  <string>A00000045645444C2D3031</string>
71
71
  </array>
72
+ <key>UIAppFonts</key>
73
+ <array>
74
+ <string>AntDesign.ttf</string>
75
+ <string>Entypo.ttf</string>
76
+ <string>EvilIcons.ttf</string>
77
+ <string>Feather.ttf</string>
78
+ <string>FontAwesome.ttf</string>
79
+ <string>FontAwesome5_Brands.ttf</string>
80
+ <string>FontAwesome5_Regular.ttf</string>
81
+ <string>FontAwesome5_Solid.ttf</string>
82
+ <string>FontAwesome6_Brands.ttf</string>
83
+ <string>FontAwesome6_Regular.ttf</string>
84
+ <string>FontAwesome6_Solid.ttf</string>
85
+ <string>Foundation.ttf</string>
86
+ <string>Ionicons.ttf</string>
87
+ <string>MaterialIcons.ttf</string>
88
+ <string>MaterialCommunityIcons.ttf</string>
89
+ <string>SimpleLineIcons.ttf</string>
90
+ <string>Octicons.ttf</string>
91
+ <string>Zocial.ttf</string>
92
+ <string>Fontisto.ttf</string>
93
+ </array>
72
94
  </dict>
73
95
  </plist>
@@ -448,7 +448,7 @@
448
448
  "$(inherited)",
449
449
  );
450
450
  INFOPLIST_FILE = DocumentReaderTests/Info.plist;
451
- IPHONEOS_DEPLOYMENT_TARGET = 15.6;
451
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
452
452
  LD_RUNPATH_SEARCH_PATHS = (
453
453
  "$(inherited)",
454
454
  "@executable_path/Frameworks",
@@ -461,11 +461,6 @@
461
461
  );
462
462
  PRODUCT_BUNDLE_IDENTIFIER = com.regula.dr.fullrfid;
463
463
  PRODUCT_NAME = "$(TARGET_NAME)";
464
- SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
465
- SUPPORTS_MACCATALYST = NO;
466
- SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
467
- SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
468
- TARGETED_DEVICE_FAMILY = 1;
469
464
  TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DocumentReader.app/DocumentReader";
470
465
  };
471
466
  name = Debug;
@@ -477,7 +472,7 @@
477
472
  BUNDLE_LOADER = "$(TEST_HOST)";
478
473
  COPY_PHASE_STRIP = NO;
479
474
  INFOPLIST_FILE = DocumentReaderTests/Info.plist;
480
- IPHONEOS_DEPLOYMENT_TARGET = 15.6;
475
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
481
476
  LD_RUNPATH_SEARCH_PATHS = (
482
477
  "$(inherited)",
483
478
  "@executable_path/Frameworks",
@@ -490,11 +485,6 @@
490
485
  );
491
486
  PRODUCT_BUNDLE_IDENTIFIER = com.regula.dr.fullrfid;
492
487
  PRODUCT_NAME = "$(TARGET_NAME)";
493
- SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
494
- SUPPORTS_MACCATALYST = NO;
495
- SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
496
- SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
497
- TARGETED_DEVICE_FAMILY = 1;
498
488
  TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DocumentReader.app/DocumentReader";
499
489
  };
500
490
  name = Release;
@@ -612,7 +602,7 @@
612
602
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
613
603
  GCC_WARN_UNUSED_FUNCTION = YES;
614
604
  GCC_WARN_UNUSED_VARIABLE = YES;
615
- IPHONEOS_DEPLOYMENT_TARGET = 15.6;
605
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
616
606
  LD_RUNPATH_SEARCH_PATHS = (
617
607
  /usr/lib/swift,
618
608
  "$(inherited)",
@@ -678,7 +668,7 @@
678
668
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
679
669
  GCC_WARN_UNUSED_FUNCTION = YES;
680
670
  GCC_WARN_UNUSED_VARIABLE = YES;
681
- IPHONEOS_DEPLOYMENT_TARGET = 15.6;
671
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
682
672
  LD_RUNPATH_SEARCH_PATHS = (
683
673
  /usr/lib/swift,
684
674
  "$(inherited)",
@@ -19,14 +19,9 @@ end
19
19
  target 'DocumentReader' do
20
20
  config = use_native_modules!
21
21
 
22
- # Flags change depending on the env values.
23
- flags = get_default_flags()
24
-
25
22
  use_react_native!(
26
23
  :path => config[:reactNativePath],
27
- :hermes_enabled => false,
28
- :fabric_enabled => flags[:fabric_enabled],
29
- :flipper_configuration => FlipperConfiguration.disabled,
24
+ # An absolute path to your application root.
30
25
  :app_path => "#{Pod::Config.instance.installation_root}/.."
31
26
  )
32
27