dynamsoft-capture-vision-react-native 2.6.1012 → 2.6.1013

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 (119) hide show
  1. package/README.md +7 -5
  2. package/android/.gitignore +4 -0
  3. package/android/build.gradle +29 -28
  4. package/android/src/main/java/com/dynamsoft/reactnativelib/ReactNativeDcvPackage.kt +15 -1
  5. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +0 -1
  6. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraLifeCycleOwner.java +14 -0
  7. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewModuleImpl.kt +3 -2
  8. package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/BarcodeScannerModuleImpl.kt +80 -0
  9. package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/MRZScannerModuleImpl.kt +77 -0
  10. package/android/src/main/java/com/dynamsoft/reactnativelib/rtu/ScannerInterface.kt +47 -0
  11. package/android/src/main/jniLibs/arm64-v8a/librn_dys.so +0 -0
  12. package/android/src/main/jniLibs/armeabi-v7a/librn_dys.so +0 -0
  13. package/android/src/main/jniLibs/x86/librn_dys.so +0 -0
  14. package/android/src/main/jniLibs/x86_64/librn_dys.so +0 -0
  15. package/android/src/newarch/com/dynamsoft/reactnativelib/BarcodeScannerModule.kt +22 -0
  16. package/android/src/newarch/com/dynamsoft/reactnativelib/MRZScannerModule.kt +22 -0
  17. package/android/src/oldarch/com/dynamsoft/reactnativelib/BarcodeScannerModule.kt +24 -0
  18. package/android/src/oldarch/com/dynamsoft/reactnativelib/MRZScannerModule.kt +24 -0
  19. package/dynamsoft-capture-vision-react-native.podspec +4 -2
  20. package/ios/CPP/RNDynamsoft+Json.h +2 -0
  21. package/ios/CPP/RNDynamsoft+Json.m +9 -0
  22. package/ios/RNDynamsoftBarcodeScanner.h +14 -0
  23. package/ios/RNDynamsoftBarcodeScanner.m +169 -0
  24. package/ios/RNDynamsoftCaptureVisionRouter.mm +14 -6
  25. package/ios/RNDynamsoftMRZScanner.h +14 -0
  26. package/ios/RNDynamsoftMRZScanner.m +140 -0
  27. package/package.json +4 -4
  28. package/src/core/CoreModule.tsx +1 -0
  29. package/src/core/DSRect.tsx +3 -4
  30. package/src/core/EnumCaptureResultItemType.tsx +12 -5
  31. package/src/core/EnumColourChannelUsageType.tsx +2 -2
  32. package/src/core/EnumCrossVerificationStatus.tsx +8 -5
  33. package/src/core/EnumGrayscaleEnhancementMode.tsx +5 -1
  34. package/src/core/EnumGrayscaleTransformationMode.tsx +6 -2
  35. package/src/core/EnumPixelFormat.tsx +1 -1
  36. package/src/core/ImageData.tsx +9 -8
  37. package/src/core/ImageSourceAdapter.tsx +5 -2
  38. package/src/core/Point.tsx +1 -1
  39. package/src/core/index.tsx +1 -2
  40. package/src/cvr/CaptureVisionRouter.tsx +40 -36
  41. package/src/cvr/CaptureVisionRouterModule.tsx +1 -0
  42. package/src/cvr/CapturedResult.tsx +2 -2
  43. package/src/cvr/CapturedResultFilter.tsx +3 -1
  44. package/src/cvr/CapturedResultReceiver.tsx +9 -9
  45. package/src/cvr/SimplifiedCaptureVisionSettings.tsx +2 -2
  46. package/src/dbr/BarcodeReaderModule.tsx +1 -0
  47. package/src/dbr/BarcodeResultItem.tsx +5 -6
  48. package/src/dbr/DecodedBarcodesResult.tsx +3 -2
  49. package/src/dbr/EnumBarcodeFormat.tsx +10 -9
  50. package/src/dbr/EnumDeblurMode.tsx +1 -1
  51. package/src/dbr/EnumLocalizationMode.tsx +1 -1
  52. package/src/dbr/SimplifiedBarcodeReaderSettings.tsx +5 -5
  53. package/src/dce/CameraEnhancer.tsx +18 -17
  54. package/src/dce/CameraEnhancerModule.tsx +1 -0
  55. package/src/dce/CameraView.tsx +3 -3
  56. package/src/dce/DynamsoftCameraViewNativeComponent.ts +4 -1
  57. package/src/dce/EnumCameraPosition.tsx +1 -1
  58. package/src/dce/FeedBack.tsx +1 -0
  59. package/src/dce/ImageEditorView.tsx +3 -2
  60. package/src/dce/index.tsx +2 -1
  61. package/src/dcp/CodeParserDedicatorModule.tsx +1 -0
  62. package/src/dcp/CodeParserModule.tsx +1 -0
  63. package/src/dcp/EnumMappingStatus.tsx +1 -1
  64. package/src/dcp/EnumValidationStatus.tsx +1 -1
  65. package/src/dcp/ParsedResult.tsx +4 -3
  66. package/src/dcp/ParsedResultItem.tsx +4 -4
  67. package/src/ddn/DetectedQuadResultItem.tsx +9 -10
  68. package/src/ddn/DetectedQuadsResult.tsx +4 -1
  69. package/src/ddn/DocumentNormalizerModule.tsx +1 -0
  70. package/src/ddn/EnumImageColourMode.tsx +1 -1
  71. package/src/ddn/NormalizedImageResultItem.tsx +10 -11
  72. package/src/ddn/NormalizedImagesResult.tsx +4 -1
  73. package/src/ddn/SimplifiedDocumentNormalizerSettings.tsx +6 -6
  74. package/src/dip/ImageProcessingModule.tsx +1 -0
  75. package/src/dlr/LabelRecognizerModule.tsx +1 -0
  76. package/src/dlr/RecognizedTextLinesResult.tsx +5 -3
  77. package/src/dlr/SimplifiedLabelRecognizerSettings.tsx +1 -2
  78. package/src/dlr/TextLineResultItem.tsx +4 -5
  79. package/src/index.tsx +1 -0
  80. package/src/license/LicenseManager.tsx +3 -2
  81. package/src/license/LicenseModule.tsx +1 -0
  82. package/src/rtu/BarcodeScanConfig.tsx +104 -0
  83. package/src/rtu/BarcodeScanResult.tsx +31 -0
  84. package/src/rtu/BarcodeScanner.tsx +112 -0
  85. package/src/rtu/EnumResultState.tsx +21 -0
  86. package/src/rtu/MRZScanConfig.tsx +67 -0
  87. package/src/rtu/MRZScanResult.tsx +84 -0
  88. package/src/rtu/MRZScanner.tsx +90 -0
  89. package/src/rtu/NativeDynamsoftBarcodeScannerModule.tsx +6 -0
  90. package/src/rtu/NativeDynamsoftMRZScannerModule.tsx +6 -0
  91. package/src/rtu/index.tsx +7 -0
  92. package/src/utility/MultiFrameResultCrossFilter.tsx +12 -12
  93. package/src/utility/UtilityModule.tsx +1 -0
  94. package/android/CMakeLists.txt +0 -14
  95. package/android/src/main/cpp/MutableRawBuffer.cpp +0 -24
  96. package/android/src/main/cpp/MutableRawBuffer.h +0 -24
  97. package/android/src/main/cpp/android_log.h +0 -14
  98. package/android/src/main/cpp/core/ImageDataHostObject.cpp +0 -95
  99. package/android/src/main/cpp/core/ImageDataHostObject.h +0 -34
  100. package/android/src/main/cpp/core/JsiCore.cpp +0 -284
  101. package/android/src/main/cpp/core/JsiCore.h +0 -51
  102. package/android/src/main/cpp/cvr/JsiCvr.cpp +0 -263
  103. package/android/src/main/cpp/cvr/JsiCvr.h +0 -51
  104. package/android/src/main/cpp/dbr/JsiDbr.cpp +0 -38
  105. package/android/src/main/cpp/dbr/JsiDbr.h +0 -26
  106. package/android/src/main/cpp/dce/JsiDce.cpp +0 -59
  107. package/android/src/main/cpp/dce/JsiDce.h +0 -17
  108. package/android/src/main/cpp/dcp/JsiDcp.cpp +0 -51
  109. package/android/src/main/cpp/dcp/JsiDcp.h +0 -31
  110. package/android/src/main/cpp/ddn/JsiDdn.cpp +0 -34
  111. package/android/src/main/cpp/ddn/JsiDdn.h +0 -27
  112. package/android/src/main/cpp/dlr/JsiDlr.cpp +0 -51
  113. package/android/src/main/cpp/dlr/JsiDlr.h +0 -26
  114. package/android/src/main/cpp/utility/JsiUtility.cpp +0 -151
  115. package/android/src/main/cpp/utility/JsiUtility.h +0 -15
  116. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraLifeCycleOwner.kt +0 -9
  117. package/src/core/CompletionListener.tsx +0 -5
  118. package/src/core/Rect.tsx +0 -21
  119. package/src/dce/TorchButton.tsx +0 -23
@@ -0,0 +1,169 @@
1
+ /*
2
+ * Copyright © Dynamsoft Corporation. All rights reserved.
3
+ */
4
+
5
+ #import "RNDynamsoftBarcodeScanner.h"
6
+ #import <DynamsoftBarcodeReaderBundle/DynamsoftBarcodeReaderBundle-Swift.h>
7
+ #import <DynamsoftBarcodeReaderBundle/DynamsoftBarcodeReaderBundle.h>
8
+ #import <React/RCTUtils.h>
9
+ #import "RNDynamsoft+Json.h"
10
+
11
+ @implementation DSBarcodeScanResult (json)
12
+
13
+ - (NSDictionary *)toJson {
14
+ id barcodes = [NSNull null];
15
+ if (self.barcodes != nil && self.barcodes.count > 0) {
16
+ barcodes = [NSMutableArray array];
17
+ for (DSBarcodeResultItem *item in self.barcodes) {
18
+ NSDictionary *dic = [item toJson];
19
+ if (dic) {
20
+ [barcodes addObject:dic];
21
+ }
22
+ }
23
+ }
24
+ id errorString = self.errorString ? self.errorString : [NSNull null];
25
+ NSDictionary *dictionary = @{ @"resultStatus":@(self.resultStatus), @"barcodes":barcodes, @"errorCode":@(self.errorCode), @"errorString":errorString };
26
+ return dictionary;
27
+ }
28
+
29
+ @end
30
+
31
+ @interface RNDynamsoftBarcodeScanner ()
32
+
33
+ @end
34
+
35
+ @implementation RNDynamsoftBarcodeScanner
36
+ RCT_EXPORT_MODULE(DynamsoftBarcodeScannerModule)
37
+
38
+ RCT_EXPORT_METHOD(startBarcodeScanner:(NSDictionary*)configuration
39
+ withResolver:(RCTPromiseResolveBlock)resolve
40
+ withRejecter:(RCTPromiseRejectBlock)reject) {
41
+
42
+ runOnMainThread(^{
43
+ UIViewController *presentedViewController = [self presentedViewController:reject];
44
+ if (presentedViewController == NULL) {
45
+ return;
46
+ }
47
+ DSBarcodeScannerViewController *viewController = [[DSBarcodeScannerViewController alloc] init];
48
+ viewController.modalPresentationStyle = UIModalPresentationFullScreen;
49
+ DSBarcodeScannerConfig *config = [self configWithDictionary:configuration];
50
+ if (config) {
51
+ viewController.config = config;
52
+ }
53
+ viewController.onScannedResult = ^(DSBarcodeScanResult *result) {
54
+ resolve([result toJson]);
55
+ };
56
+ [presentedViewController presentViewController:viewController animated:true completion:NULL];
57
+ });
58
+ }
59
+
60
+ RCT_EXPORT_METHOD(closeBarcodeScanner:
61
+ (RCTPromiseResolveBlock)resolve
62
+ withRejecter:(RCTPromiseRejectBlock)reject) {
63
+ runOnMainThread(^{
64
+ UIViewController *presentedViewController = [self presentedViewController:reject];
65
+ if (presentedViewController == NULL) {
66
+ return;
67
+ }
68
+ [presentedViewController dismissViewControllerAnimated:true completion:nil];
69
+ resolve(@(true));
70
+ });
71
+ }
72
+
73
+ - (nullable UIViewController *) presentedViewController:(RCTPromiseRejectBlock)reject {
74
+ UIViewController *presentedViewController = RCTPresentedViewController();
75
+ if (presentedViewController == NULL) {
76
+ reject(@"RTUUI_ERROR", @"No active view controller", nil);
77
+ return NULL;
78
+ }
79
+ return presentedViewController;
80
+ }
81
+
82
+ - (nullable DSBarcodeScannerConfig *)configWithDictionary:(NSDictionary*)configuration {
83
+ if (configuration) {
84
+ DSBarcodeScannerConfig *config = [[DSBarcodeScannerConfig alloc] init];
85
+
86
+ NSString *license = [configuration valueForKey:@"license"];
87
+ if (license) {
88
+ config.license = license;
89
+ }
90
+
91
+ NSString *templateFile = [configuration valueForKey:@"templateFile"];
92
+ if (templateFile) {
93
+ config.templateFile = templateFile;
94
+ }
95
+
96
+ NSNumber *isTorchButtonVisible = [configuration valueForKey:@"isTorchButtonVisible"];
97
+ if (isTorchButtonVisible) {
98
+ config.isTorchButtonVisible = isTorchButtonVisible.boolValue;
99
+ }
100
+
101
+ NSDictionary *region = [configuration valueForKey:@"scanRegion"];
102
+ if (region) {
103
+ NSNumber *top = [region valueForKey:@"top"];
104
+ NSNumber *left = [region valueForKey:@"left"];
105
+ NSNumber *right = [region valueForKey:@"right"];
106
+ NSNumber *bottom = [region valueForKey:@"bottom"];
107
+ NSNumber *measuredInPercentage = [region valueForKey:@"measuredInPercentage"];
108
+ if (top && left && right && bottom && measuredInPercentage) {
109
+ DSRect *rect = [[DSRect alloc] init];
110
+ rect.top = top.floatValue;
111
+ rect.left = left.floatValue;
112
+ rect.right = right.floatValue;
113
+ rect.bottom = bottom.floatValue;
114
+ rect.measuredInPercentage = measuredInPercentage.boolValue;
115
+ config.scanRegion = rect;
116
+ }
117
+ }
118
+
119
+ NSNumber *isBeepEnabled = [configuration valueForKey:@"isBeepEnabled"];
120
+ if (isBeepEnabled) {
121
+ config.isBeepEnabled = isBeepEnabled.boolValue;
122
+ }
123
+
124
+ NSNumber *isScanLaserVisible = [configuration valueForKey:@"isScanLaserVisible"];
125
+ if (isScanLaserVisible) {
126
+ config.isScanLaserVisible = isScanLaserVisible.boolValue;
127
+ }
128
+
129
+ NSNumber *isAutoZoomEnabled = [configuration valueForKey:@"isAutoZoomEnabled"];
130
+ if (isAutoZoomEnabled) {
131
+ config.isAutoZoomEnabled = isAutoZoomEnabled.boolValue;
132
+ }
133
+
134
+ NSNumber *isCloseButtonVisible = [configuration valueForKey:@"isCloseButtonVisible"];
135
+ if (isCloseButtonVisible) {
136
+ config.isCloseButtonVisible = isCloseButtonVisible.boolValue;
137
+ }
138
+
139
+ NSString *_barcodeFormatNumberString = [configuration valueForKey:@"_barcodeFormatNumberString"];
140
+ if (_barcodeFormatNumberString) {
141
+ config.barcodeFormats = _barcodeFormatNumberString.integerValue;
142
+ }
143
+
144
+ NSNumber *scanningMode = [configuration valueForKey:@"scanningMode"];
145
+ if (scanningMode) {
146
+ config.scanningMode = scanningMode.integerValue;
147
+ }
148
+
149
+ NSNumber *maxConsecutiveStableFramesToExit = [configuration valueForKey:@"maxConsecutiveStableFramesToExit"];
150
+ if (maxConsecutiveStableFramesToExit) {
151
+ config.maxConsecutiveStableFramesToExit = maxConsecutiveStableFramesToExit.integerValue;
152
+ }
153
+
154
+ NSNumber *expectedBarcodesCount = [configuration valueForKey:@"expectedBarcodesCount"];
155
+ if (expectedBarcodesCount) {
156
+ config.expectedBarcodesCount = expectedBarcodesCount.integerValue;
157
+ }
158
+
159
+ NSNumber *isCameraToggleButtonVisible = [configuration valueForKey:@"isCameraToggleButtonVisible"];
160
+ if (isCameraToggleButtonVisible) {
161
+ config.isCameraToggleButtonVisible = isCameraToggleButtonVisible.boolValue;
162
+ }
163
+
164
+ return config;
165
+ }
166
+ return nil;
167
+ }
168
+
169
+ @end
@@ -62,6 +62,7 @@ RCT_EXPORT_METHOD(startCapturing:(NSString *)templateName
62
62
  NSString *code = [NSString stringWithFormat:@"%ld",(long)error.code];
63
63
  reject(code, error.localizedDescription, error);
64
64
  } else {
65
+ self->semaphore = dispatch_semaphore_create(0);
65
66
  resolve(@(true));
66
67
  }
67
68
  }];
@@ -70,6 +71,7 @@ RCT_EXPORT_METHOD(startCapturing:(NSString *)templateName
70
71
  RCT_EXPORT_METHOD(stopCapturing:(RCTPromiseResolveBlock)resolve
71
72
  rejecter:(RCTPromiseRejectBlock)reject)
72
73
  {
74
+ [self continueCRR];
73
75
  [self.cvr stopCapturing];
74
76
  resolve(@(true));
75
77
  }
@@ -241,21 +243,24 @@ RCT_EXPORT_METHOD(removeFilter:(NSString *)key) {
241
243
  }
242
244
  }
243
245
  [self sendEventWithName:@"onCapturedResultReceived" body:[result toJson]];
244
- dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
246
+ dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC);
247
+ __unused long result = dispatch_semaphore_wait(semaphore, timeout);
245
248
  }
246
249
  }
247
250
 
248
251
  - (void)onDecodedBarcodesReceived:(DSDecodedBarcodesResult *)result {
249
252
  if (hasListeners && [self.receiveDictionary valueForKey:@"onDecodedBarcodesReceived"].boolValue) {
250
253
  [self sendEventWithName:@"onDecodedBarcodesReceived" body:[result toJson]];
251
- dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
254
+ dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC);
255
+ __unused long result = dispatch_semaphore_wait(semaphore, timeout);
252
256
  }
253
257
  }
254
258
 
255
259
  - (void)onDetectedQuadsReceived:(DSDetectedQuadsResult *)result {
256
260
  if (hasListeners && [self.receiveDictionary valueForKey:@"onDetectedQuadsReceived"].boolValue) {
257
261
  [self sendEventWithName:@"onDetectedQuadsReceived" body:[result toJson]];
258
- dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
262
+ dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC);
263
+ __unused long result = dispatch_semaphore_wait(semaphore, timeout);
259
264
  }
260
265
  }
261
266
 
@@ -269,21 +274,24 @@ RCT_EXPORT_METHOD(removeFilter:(NSString *)key) {
269
274
  }
270
275
  }
271
276
  [self sendEventWithName:@"onNormalizedImagesReceived" body:[result toJson]];
272
- dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
277
+ dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC);
278
+ __unused long result = dispatch_semaphore_wait(semaphore, timeout);
273
279
  }
274
280
  }
275
281
 
276
282
  - (void)onRecognizedTextLinesReceived:(DSRecognizedTextLinesResult *)result {
277
283
  if (hasListeners && [self.receiveDictionary valueForKey:@"onRecognizedTextLinesReceived"].boolValue) {
278
284
  [self sendEventWithName:@"onRecognizedTextLinesReceived" body:[result toJson]];
279
- dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
285
+ dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC);
286
+ __unused long result = dispatch_semaphore_wait(semaphore, timeout);
280
287
  }
281
288
  }
282
289
 
283
290
  - (void)onParsedResultsReceived:(DSParsedResult *)result {
284
291
  if (hasListeners && [self.receiveDictionary valueForKey:@"onParsedResultsReceived"].boolValue) {
285
292
  [self sendEventWithName:@"onParsedResultsReceived" body:[result toJson]];
286
- dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
293
+ dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC);
294
+ __unused long result = dispatch_semaphore_wait(semaphore, timeout);
287
295
  }
288
296
  }
289
297
 
@@ -0,0 +1,14 @@
1
+ /*
2
+ * Copyright © Dynamsoft Corporation. All rights reserved.
3
+ */
4
+
5
+ #import "RCTEventEmitter.h"
6
+ #import <React/RCTBridgeModule.h>
7
+
8
+ NS_ASSUME_NONNULL_BEGIN
9
+
10
+ @interface RNDynamsoftMRZScanner : RCTEventEmitter <RCTBridgeModule>
11
+
12
+ @end
13
+
14
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,140 @@
1
+ /*
2
+ * Copyright © Dynamsoft Corporation. All rights reserved.
3
+ */
4
+
5
+ #import "RNDynamsoftMRZScanner.h"
6
+ #import <DynamsoftMRZScannerBundle/DynamsoftMRZScannerBundle-Swift.h>
7
+ #import <DynamsoftMRZScannerBundle/DynamsoftMRZScannerBundle.h>
8
+ #import <React/RCTUtils.h>
9
+ #import "RNDynamsoft+Json.h"
10
+
11
+ @implementation DSMRZScanResult (json)
12
+
13
+ - (NSDictionary *)toJson {
14
+ id data = [NSNull null];
15
+ if (self.data != nil ) {
16
+ DSMRZData *mrzData = self.data;
17
+ data = @{
18
+ @"firstName":mrzData.firstName,
19
+ @"lastName":mrzData.lastName,
20
+ @"sex":mrzData.sex,
21
+ @"issuingState":mrzData.issuingState,
22
+ @"nationality":mrzData.nationality,
23
+ @"dateOfBirth":mrzData.dateOfBirth,
24
+ @"dateOfExpire":mrzData.dateOfExpire,
25
+ @"documentType":mrzData.documentType,
26
+ @"documentNumber":mrzData.documentNumber,
27
+ @"age":@(mrzData.age),
28
+ @"mrzText":mrzData.mrzText
29
+ };
30
+ }
31
+ id errorString = self.errorString ? self.errorString : [NSNull null];
32
+ NSDictionary *dictionary = @{
33
+ @"resultStatus":@(self.resultStatus),
34
+ @"data":data,
35
+ @"errorCode":@(self.errorCode),
36
+ @"errorString":errorString
37
+ };
38
+ return dictionary;
39
+ }
40
+
41
+ @end
42
+
43
+ @implementation RNDynamsoftMRZScanner
44
+
45
+ RCT_EXPORT_MODULE(DynamsoftMRZScannerModule)
46
+
47
+ RCT_EXPORT_METHOD(startMRZScanner:(NSDictionary*)configuration
48
+ withResolver:(RCTPromiseResolveBlock)resolve
49
+ withRejecter:(RCTPromiseRejectBlock)reject) {
50
+
51
+ runOnMainThread(^{
52
+ UIViewController *presentedViewController = [self presentedViewController:reject];
53
+ if (presentedViewController == NULL) {
54
+ return;
55
+ }
56
+ DSMRZScannerViewController *viewController = [[DSMRZScannerViewController alloc] init];
57
+ viewController.modalPresentationStyle = UIModalPresentationFullScreen;
58
+ DSMRZScannerConfig *config = [self configWithDictionary:configuration];
59
+ if (config) {
60
+ viewController.config = config;
61
+ }
62
+ viewController.onScannedResult = ^(DSMRZScanResult *result) {
63
+ resolve([result toJson]);
64
+ };
65
+ [presentedViewController presentViewController:viewController animated:true completion:NULL];
66
+ });
67
+ }
68
+
69
+ RCT_EXPORT_METHOD(closeMRZScanner:
70
+ (RCTPromiseResolveBlock)resolve
71
+ withRejecter:(RCTPromiseRejectBlock)reject) {
72
+ runOnMainThread(^{
73
+ UIViewController *presentedViewController = [self presentedViewController:reject];
74
+ if (presentedViewController == NULL) {
75
+ return;
76
+ }
77
+ [presentedViewController dismissViewControllerAnimated:true completion:nil];
78
+ resolve(@(true));
79
+ });
80
+ }
81
+
82
+ - (nullable UIViewController *) presentedViewController:(RCTPromiseRejectBlock)reject {
83
+ UIViewController *presentedViewController = RCTPresentedViewController();
84
+ if (presentedViewController == NULL) {
85
+ reject(@"RTUUI_ERROR", @"No active view controller", nil);
86
+ return NULL;
87
+ }
88
+ return presentedViewController;
89
+ }
90
+
91
+ - (nullable DSMRZScannerConfig *)configWithDictionary:(NSDictionary*)configuration {
92
+ if (configuration) {
93
+ DSMRZScannerConfig *config = [[DSMRZScannerConfig alloc] init];
94
+
95
+ NSString *license = [configuration valueForKey:@"license"];
96
+ if (license) {
97
+ config.license = license;
98
+ }
99
+
100
+ // NSString *templateFile = [configuration valueForKey:@"templateFile"];
101
+ // if (templateFile) {
102
+ // config.templateFile = templateFile;
103
+ // }
104
+
105
+ NSNumber *isTorchButtonVisible = [configuration valueForKey:@"isTorchButtonVisible"];
106
+ if (isTorchButtonVisible) {
107
+ config.isTorchButtonVisible = isTorchButtonVisible.boolValue;
108
+ }
109
+
110
+ NSNumber *isBeepEnabled = [configuration valueForKey:@"isBeepEnabled"];
111
+ if (isBeepEnabled) {
112
+ config.isBeepEnabled = isBeepEnabled.boolValue;
113
+ }
114
+
115
+ NSNumber *isCloseButtonVisible = [configuration valueForKey:@"isCloseButtonVisible"];
116
+ if (isCloseButtonVisible) {
117
+ config.isCloseButtonVisible = isCloseButtonVisible.boolValue;
118
+ }
119
+
120
+ NSNumber *documentType = [configuration valueForKey:@"documentType"];
121
+ if (documentType) {
122
+ config.documentType = documentType.integerValue;
123
+ }
124
+
125
+ NSNumber *isGuideFrameVisible = [configuration valueForKey:@"isGuideFrameVisible"];
126
+ if (isGuideFrameVisible) {
127
+ config.isGuideFrameVisible = isGuideFrameVisible.boolValue;
128
+ }
129
+
130
+ NSNumber *isCameraToggleButtonVisible = [configuration valueForKey:@"isCameraToggleButtonVisible"];
131
+ if (isCameraToggleButtonVisible) {
132
+ config.isCameraToggleButtonVisible = isCameraToggleButtonVisible.boolValue;
133
+ }
134
+
135
+ return config;
136
+ }
137
+ return nil;
138
+ }
139
+
140
+ @end
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dynamsoft-capture-vision-react-native",
3
3
  "title": "Dynamsoft Capture Vision React Native",
4
- "version": "2.6.1012",
4
+ "version": "2.6.1013",
5
5
  "description": "Dynamsoft Capture Vision React Native SDK. The SDK supports barcode decoding, document scanning and MRZ reading.",
6
6
  "homepage": "https://github.com/Dynamsoft/capture-vision-react-native-samples",
7
7
  "main": "src/index.tsx",
@@ -45,6 +45,7 @@
45
45
  "react-native": ">=0.71.0-rc.0 <1.0.x"
46
46
  },
47
47
  "devDependencies": {
48
+ "@babel/preset-env": "^7.1.6",
48
49
  "@react-native-community/cli": "13.6.4",
49
50
  "@react-native/typescript-config": "0.75.2",
50
51
  "@tsconfig/react-native": "3.0.0",
@@ -55,10 +56,9 @@
55
56
  "prettier": "3.0.3",
56
57
  "react": "18.3.1",
57
58
  "react-native": "0.75.2",
58
- "typescript": "5.2.2",
59
- "@babel/preset-env" :"^7.1.6"
59
+ "typedoc": "^0.27.7",
60
+ "typescript": "5.2.2"
60
61
  },
61
- "dependencies": {},
62
62
  "codegenConfig": {
63
63
  "name": "DynamsoftSpecs",
64
64
  "type": "all",
@@ -1,6 +1,7 @@
1
1
  import {DynamsoftVersions} from '../VersionsModule'
2
2
  import {Platform} from "react-native";
3
3
 
4
+ /** @hideconstructor */
4
5
  export class CoreModule {
5
6
  static getVersion(): string {
6
7
  return '[' + Platform.OS + ']: ' + DynamsoftVersions.core
@@ -1,13 +1,12 @@
1
+ import {CameraEnhancer} from "../dce";
1
2
  /**
2
3
  * The DSRect class represents a rectangle in 2D space,
3
4
  * which contains four integer values that specify the top, left, right, and bottom edges of the rectangle.
4
- * @see CameraEnhancer.setScanRegion
5
+ * @see {@link CameraEnhancer.setScanRegion}
5
6
  * */
6
7
  export interface DSRect {
7
8
  /**
8
- * The distance between the top of the rect and the x-axis.
9
- * If {@link measuredInPercentage} = 1/true, the value specifies the percentage comparing with the height of the parent.
10
- * If {@link measuredInPercentage} = 0/false, the value specifies a pixel length.
9
+ * Y coordinate of the top border of the region.
11
10
  */
12
11
  top: number;
13
12
  /**
@@ -1,3 +1,10 @@
1
+ import type {BarcodeResultItem} from "../dbr";
2
+ import type {TextLineResultItem} from "../dlr";
3
+ import type {DetectedQuadResultItem, NormalizedImageResultItem} from "../ddn";
4
+ import type {ParsedResultItem} from "../dcp";
5
+
6
+ /**{@link BarcodeResultItem} {@link TextLineResultItem} {@link DetectedQuadResultItem} {@link NormalizedImageResultItem} {@link ParsedResultItem}* */
7
+
1
8
  /**
2
9
  * Defines the various categories of items that can be recognized and captured.
3
10
  * */
@@ -9,31 +16,31 @@ export enum EnumCapturedResultItemType {
9
16
 
10
17
  /**
11
18
  * The type of the CapturedResultItem is "barcode".
12
- * @see BarcodeResultItem
19
+ * @see {@link BarcodeResultItem}
13
20
  * */
14
21
  CRIT_BARCODE = 0x2,
15
22
 
16
23
  /**
17
24
  * The type of the CapturedResultItem is "text line".
18
- * @see TextLineResultItem
25
+ * @see {@link TextLineResultItem}
19
26
  * */
20
27
  CRIT_TEXT_LINE = 0x4,
21
28
 
22
29
  /**
23
30
  * The type of the CapturedResultItem is "detected quad".
24
- * @see DetectedQuadResultItem
31
+ * @see {@link DetectedQuadResultItem}
25
32
  * */
26
33
  CRIT_DETECTED_QUAD = 0x8,
27
34
 
28
35
  /**
29
36
  * The type of the CapturedResultItem is "normalized image".
30
- * @see NormalizedImageResultItem
37
+ * @see {@link NormalizedImageResultItem}
31
38
  * */
32
39
  CRIT_NORMALIZED_IMAGE = 0x10,
33
40
 
34
41
  /**
35
42
  * The type of the CapturedResultItem is "parsed result".
36
- * @see ParsedResultItem
43
+ * @see {@link ParsedResultItem}
37
44
  * */
38
45
  CRIT_PARSED_RESULT = 0x20
39
46
  }
@@ -2,8 +2,8 @@
2
2
  * Enumerates the different ways color channels can be utilized in image processing.
3
3
  * This allows for flexible image analysis and manipulation by specifying how color data should be handled.
4
4
  *
5
- * @see ImageSourceAdapter.getColourChannelUsageType
6
- * @see ImageSourceAdapter.setColourChannelUsageType
5
+ * @see {@link ImageSourceAdapter.getColourChannelUsageType}
6
+ * @see {@link ImageSourceAdapter.setColourChannelUsageType}
7
7
  * */
8
8
  export enum EnumColourChannelUsageType {
9
9
  /** Automatic color channel usage determination based on image pixel format and scene. */
@@ -1,7 +1,10 @@
1
+ import type {DetectedQuadResultItem, NormalizedImageResultItem} from "../ddn";
2
+ import {CaptureVisionRouter} from "../cvr";
3
+ import {MultiFrameResultCrossFilter} from "../utility";
1
4
  /**
2
5
  * CrossVerificationStatus describes the status of the captured results.
3
- * <p>
4
- * Code Snippet:
6
+ * <p>Code Snippet:</p>
7
+ *
5
8
  * ```
6
9
  * let router = CaptureVisionRouter.getInstance()
7
10
  * let filter = new MultiFrameResultCrossFilter()
@@ -27,9 +30,9 @@
27
30
  * <p>
28
31
  * Currently, only {@link DetectedQuadResultItem} and {@link NormalizedImageResultItem} have the crossVerificationStatus property.
29
32
  *
30
- * @see MultiFrameResultCrossFilter.enableResultCrossVerification
31
- * @see DetectedQuadResultItem.crossVerificationStatus
32
- * @see NormalizedImageResultItem.crossVerificationStatus
33
+ * @see {@link MultiFrameResultCrossFilter.enableResultCrossVerification}
34
+ * @see {@link DetectedQuadResultItem.crossVerificationStatus}
35
+ * @see {@link NormalizedImageResultItem.crossVerificationStatus}
33
36
  * */
34
37
  export enum EnumCrossVerificationStatus {
35
38
  /** The cross verification has not been performed yet. */
@@ -1,6 +1,10 @@
1
+ import type {SimplifiedBarcodeReaderSettings} from "../dbr";
2
+ import type {SimplifiedLabelRecognizerSettings} from "../dlr";
3
+
1
4
  /**
2
5
  * Specifies the method employed to enhance images in grayscale.
3
- * @see SimplifiedBarcodeReaderSettings.grayscaleEnhancementModes
6
+ * @see {@link SimplifiedBarcodeReaderSettings.grayscaleEnhancementModes}
7
+ * @see {@link SimplifiedLabelRecognizerSettings.grayscaleEnhancementModes}
4
8
  */
5
9
  export enum EnumGrayscaleEnhancementMode {
6
10
  /**
@@ -1,7 +1,11 @@
1
+ import type {SimplifiedBarcodeReaderSettings} from "../dbr";
2
+ import type {SimplifiedLabelRecognizerSettings} from "../dlr";
3
+
1
4
  /**
2
5
  * Specifies the method employed to transform images in grayscale.
3
- * @see SimplifiedBarcodeReaderSettings.grayscaleTransformationModes
4
- */
6
+ * @see {@link SimplifiedBarcodeReaderSettings.grayscaleEnhancementModes}
7
+ * @see {@link SimplifiedLabelRecognizerSettings.grayscaleEnhancementModes}
8
+ * */
5
9
  export enum EnumGrayscaleTransformationMode {
6
10
  /**
7
11
  * Bypasses grayscale transformation, leaving the image in its current state without any modification to its grayscale values.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Defines the range of pixel formats that an image can have, specifying how color and transparency data are represented in each pixel of the image.
3
- * @see ImageData.format
3
+ * @see {@link ImageData.format}
4
4
  * */
5
5
  export enum EnumPixelFormat {
6
6
  /** 0:Black, 1:White. */
@@ -1,5 +1,8 @@
1
1
  import {EnumPixelFormat} from "./EnumPixelFormat";
2
2
  import {NativeModules} from "react-native";
3
+ import {ImageEditorView} from "../dce";
4
+ import {ImageManager} from "../utility";
5
+ import {IntermediateResultManager} from "../cvr";
3
6
 
4
7
  declare global {
5
8
  function imageDataToBase64(imageData: ImageData): string; //Installed in ImageSourceAdapterModule
@@ -11,15 +14,13 @@ declare global {
11
14
  * `Please release the imageData object when it is no longer needed. see` {@link ImageData.release}.
12
15
  *
13
16
  * If you want to display imagedata on react UI Element, you can use {@link imageDataToBase64}
14
- * @see ImageData.release
15
- * @see imageDataToBase64
16
- * @see EditorView.setOriginalImage
17
- * @see ImageManager.saveToFile
17
+ * @see {@link imageDataToBase64}
18
+ * @see {@link ImageEditorView.setOriginalImage}
19
+ * @see {@link ImageManager.saveToFile}
18
20
  * */
19
21
  export interface ImageData {
20
22
  /**
21
- * The raw bytes of the image, of type ArrayBuffer.
22
- * @see ArrayBuffer
23
+ * The raw bytes of the image, of type {@link ArrayBuffer}.
23
24
  * */
24
25
  buffer: ArrayBuffer;
25
26
 
@@ -39,8 +40,7 @@ export interface ImageData {
39
40
  stride: number;
40
41
 
41
42
  /**
42
- * The pixel format of the image.
43
- * @see EnumPixelFormat
43
+ * The pixel format of the image, of type {@link EnumPixelFormat}
44
44
  * */
45
45
  format: EnumPixelFormat | number;
46
46
 
@@ -76,6 +76,7 @@ const installMethods = () => {
76
76
  *
77
77
  * @param {ImageData} imageData - The ImageData object to convert.
78
78
  * @returns {string} - The Base64-encoded string representation of the image data.
79
+ * @see {@link IntermediateResultManager.getOriginalImage}
79
80
  */
80
81
  export function imageDataToBase64(imageData: ImageData): string {
81
82
  installMethods();
@@ -1,6 +1,8 @@
1
1
  import type {ImageData} from "./ImageData";
2
2
  import {NativeModules} from "react-native";
3
3
  import type {EnumColourChannelUsageType} from "./EnumColourChannelUsageType";
4
+ import {CameraEnhancer} from "../dce";
5
+ import {CaptureVisionRouter} from "../cvr";
4
6
 
5
7
  // @ts-ignore Check whether __turboModuleProxy exists, it may not
6
8
  const isTurboModuleEnabled = global.__turboModuleProxy != null;
@@ -29,8 +31,9 @@ declare global {
29
31
  * It is an abstract class that needs to be implemented by a concrete class to provide actual functionality.
30
32
  * `Each ImageSourceAdapter instance object will correspond to a native instance object.`
31
33
  *
32
- * @see CameraEnhancer
33
- * @see CaptureVisionRouter.setInput
34
+ * @see {@link CameraEnhancer}
35
+ * @see {@link CaptureVisionRouter.setInput}
36
+ * @hideconstructor
34
37
  * */
35
38
  export abstract class ImageSourceAdapter {
36
39
  protected isaId: string = "";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @see Quadrilateral.points
2
+ * @see {@link Quadrilateral.points}
3
3
  * */
4
4
  export interface Point {
5
5
  /**
@@ -1,17 +1,16 @@
1
1
  // main index.tsx
2
2
  export * from "./CapturedResultItem"
3
- export * from "./CompletionListener"
4
3
  export * from "./CoreModule"
5
4
  export * from "./DSRect"
6
5
  export * from "./EnumCaptureResultItemType"
7
6
  export * from "./EnumColourChannelUsageType"
8
7
  export * from "./EnumGrayscaleEnhancementMode"
9
8
  export * from "./EnumGrayscaleTransformationMode"
9
+ export * from "./EnumCrossVerificationStatus"
10
10
  export * from "./EnumPixelFormat"
11
11
  export * from "./ImageData"
12
12
  export * from "./ImageSourceAdapter"
13
13
  export * from "./Point"
14
14
  export * from "./Quadrilateral"
15
- export * from "./Rect"
16
15
 
17
16