dynamsoft-capture-vision-react-native 3.4.1300 → 3.4.3000

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 (222) hide show
  1. package/LICENSE +4 -4
  2. package/README.md +62 -62
  3. package/android/README.md +14 -14
  4. package/android/build.gradle +167 -163
  5. package/android/gradle.properties +20 -20
  6. package/android/settings.gradle +5 -5
  7. package/android/src/main/AndroidManifest.xml +6 -6
  8. package/android/src/main/AndroidManifest_noPackage.xml +5 -5
  9. package/android/src/main/cpp/CMakeLists.txt +21 -21
  10. package/android/src/main/cpp/ImgHO.cpp +94 -94
  11. package/android/src/main/cpp/ImgHO.h +34 -34
  12. package/android/src/main/cpp/JsiCore.cpp +296 -296
  13. package/android/src/main/cpp/JsiCore.h +51 -51
  14. package/android/src/main/cpp/JsiCvr.cpp +332 -332
  15. package/android/src/main/cpp/JsiCvr.h +54 -54
  16. package/android/src/main/cpp/JsiDbr.cpp +283 -283
  17. package/android/src/main/cpp/JsiDbr.h +26 -26
  18. package/android/src/main/cpp/JsiDce.cpp +59 -59
  19. package/android/src/main/cpp/JsiDce.h +17 -17
  20. package/android/src/main/cpp/JsiDcp.cpp +51 -51
  21. package/android/src/main/cpp/JsiDcp.h +31 -31
  22. package/android/src/main/cpp/JsiDdn.cpp +50 -50
  23. package/android/src/main/cpp/JsiDdn.h +28 -28
  24. package/android/src/main/cpp/JsiDlr.cpp +60 -60
  25. package/android/src/main/cpp/JsiDlr.h +26 -26
  26. package/android/src/main/cpp/JsiUtility.cpp +604 -604
  27. package/android/src/main/cpp/JsiUtility.h +26 -26
  28. package/android/src/main/cpp/RawBuffer.cpp +23 -23
  29. package/android/src/main/cpp/RawBuffer.h +24 -24
  30. package/android/src/main/cpp/android_log.h +14 -14
  31. package/android/src/main/dysJniLibs/debug/arm64-v8a/librn_dys.so +0 -0
  32. package/android/src/main/dysJniLibs/debug/armeabi-v7a/librn_dys.so +0 -0
  33. package/android/src/main/dysJniLibs/debug/x86/librn_dys.so +0 -0
  34. package/android/src/main/dysJniLibs/debug/x86_64/librn_dys.so +0 -0
  35. package/android/src/main/dysJniLibs/release/arm64-v8a/librn_dys.so +0 -0
  36. package/android/src/main/dysJniLibs/release/armeabi-v7a/librn_dys.so +0 -0
  37. package/android/src/main/dysJniLibs/release/x86/librn_dys.so +0 -0
  38. package/android/src/main/dysJniLibs/release/x86_64/librn_dys.so +0 -0
  39. package/android/src/main/dysJniLibsFor81/debug/arm64-v8a/librn_dys.so +0 -0
  40. package/android/src/main/dysJniLibsFor81/debug/armeabi-v7a/librn_dys.so +0 -0
  41. package/android/src/main/dysJniLibsFor81/debug/x86/librn_dys.so +0 -0
  42. package/android/src/main/dysJniLibsFor81/debug/x86_64/librn_dys.so +0 -0
  43. package/android/src/main/dysJniLibsFor81/release/arm64-v8a/librn_dys.so +0 -0
  44. package/android/src/main/dysJniLibsFor81/release/armeabi-v7a/librn_dys.so +0 -0
  45. package/android/src/main/dysJniLibsFor81/release/x86/librn_dys.so +0 -0
  46. package/android/src/main/dysJniLibsFor81/release/x86_64/librn_dys.so +0 -0
  47. package/android/src/main/dysJniLibsFor82/debug/arm64-v8a/librn_dys.so +0 -0
  48. package/android/src/main/dysJniLibsFor82/debug/armeabi-v7a/librn_dys.so +0 -0
  49. package/android/src/main/dysJniLibsFor82/debug/x86/librn_dys.so +0 -0
  50. package/android/src/main/dysJniLibsFor82/debug/x86_64/librn_dys.so +0 -0
  51. package/android/src/main/dysJniLibsFor82/release/arm64-v8a/librn_dys.so +0 -0
  52. package/android/src/main/dysJniLibsFor82/release/armeabi-v7a/librn_dys.so +0 -0
  53. package/android/src/main/dysJniLibsFor82/release/x86/librn_dys.so +0 -0
  54. package/android/src/main/dysJniLibsFor82/release/x86_64/librn_dys.so +0 -0
  55. package/android/src/main/dysJniLibsFor86/debug/arm64-v8a/librn_dys.so +3 -0
  56. package/android/src/main/dysJniLibsFor86/debug/armeabi-v7a/librn_dys.so +3 -0
  57. package/android/src/main/dysJniLibsFor86/debug/x86/librn_dys.so +3 -0
  58. package/android/src/main/dysJniLibsFor86/debug/x86_64/librn_dys.so +3 -0
  59. package/android/src/main/dysJniLibsFor86/release/arm64-v8a/librn_dys.so +3 -0
  60. package/android/src/main/dysJniLibsFor86/release/armeabi-v7a/librn_dys.so +3 -0
  61. package/android/src/main/dysJniLibsFor86/release/x86/librn_dys.so +3 -0
  62. package/android/src/main/dysJniLibsFor86/release/x86_64/librn_dys.so +3 -0
  63. package/android/src/main/java/com/dynamsoft/reactnativelib/CVRModule.kt +137 -137
  64. package/android/src/main/java/com/dynamsoft/reactnativelib/CameraViewManager.kt +62 -62
  65. package/android/src/main/java/com/dynamsoft/reactnativelib/DCEModule.kt +125 -125
  66. package/android/src/main/java/com/dynamsoft/reactnativelib/DynamsoftBaseModule.kt +8 -8
  67. package/android/src/main/java/com/dynamsoft/reactnativelib/ISAModule.kt +73 -73
  68. package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +14 -14
  69. package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewModule.kt +35 -35
  70. package/android/src/main/java/com/dynamsoft/reactnativelib/ImageManagerModule.kt +15 -15
  71. package/android/src/main/java/com/dynamsoft/reactnativelib/LicenseModule.kt +29 -29
  72. package/android/src/main/java/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +83 -83
  73. package/android/src/main/java/com/dynamsoft/reactnativelib/ReactNativeDcvPackage.kt +32 -32
  74. package/android/src/main/java/com/dynamsoft/reactnativelib/VersionsModule.kt +41 -41
  75. package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/Basic.kt +44 -44
  76. package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForCore.kt +50 -50
  77. package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForCvr.kt +129 -129
  78. package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDBR.kt +157 -157
  79. package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDCE.kt +110 -110
  80. package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDCP.kt +49 -49
  81. package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDDN.kt +85 -85
  82. package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDLR.kt +72 -72
  83. package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ImageUtil.kt +58 -58
  84. package/android/src/main/java/com/dynamsoft/reactnativelib/core/ImageSourceAdapterModuleImpl.kt +120 -120
  85. package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +306 -306
  86. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +247 -247
  87. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraLifeCycleOwner.java +14 -14
  88. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraViewManagerImpl.kt +77 -77
  89. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt +15 -15
  90. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewModuleImpl.kt +110 -110
  91. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNCameraView.kt +20 -20
  92. package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNImageEditorView.kt +19 -19
  93. package/android/src/main/java/com/dynamsoft/reactnativelib/license/LicenseModuleImpl.kt +39 -39
  94. package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt +120 -120
  95. package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt +111 -111
  96. package/app.plugin.js +21 -21
  97. package/dynamsoft-capture-vision-react-native.podspec +24 -24
  98. package/ios/CPP/DSImageData+HostObject.h +18 -18
  99. package/ios/CPP/DSImageData+HostObject.mm +38 -38
  100. package/ios/CPP/ImageDataHostObject.cpp +87 -87
  101. package/ios/CPP/ImageDataHostObject.hpp +35 -35
  102. package/ios/CPP/MutableRawBuffer.cpp +23 -23
  103. package/ios/CPP/MutableRawBuffer.hpp +23 -23
  104. package/ios/CPP/RNDynamsoft+JSI.h +22 -22
  105. package/ios/CPP/RNDynamsoft+JSI.mm +303 -303
  106. package/ios/CPP/RNDynamsoft+Json.h +93 -93
  107. package/ios/CPP/RNDynamsoft+Json.m +733 -733
  108. package/ios/CPP/YeetJSIUtils.h +56 -56
  109. package/ios/CPP/YeetJSIUtils.mm +208 -208
  110. package/ios/RNDynamsoftCameraView.h +31 -31
  111. package/ios/RNDynamsoftCameraView.m +108 -108
  112. package/ios/RNDynamsoftCameraViewManager.h +14 -14
  113. package/ios/RNDynamsoftCameraViewManager.m +195 -195
  114. package/ios/RNDynamsoftCaptureVisionRouter.h +18 -18
  115. package/ios/RNDynamsoftCaptureVisionRouter.mm +532 -532
  116. package/ios/RNDynamsoftImageEditorView.h +17 -17
  117. package/ios/RNDynamsoftImageEditorView.m +25 -25
  118. package/ios/RNDynamsoftImageEditorViewManager.h +14 -14
  119. package/ios/RNDynamsoftImageEditorViewManager.mm +183 -183
  120. package/ios/RNDynamsoftImageManager.h +14 -14
  121. package/ios/RNDynamsoftImageManager.mm +369 -369
  122. package/ios/RNDynamsoftImageSourceAdapter.h +19 -19
  123. package/ios/RNDynamsoftImageSourceAdapter.mm +255 -255
  124. package/ios/RNDynamsoftLicense.h +14 -14
  125. package/ios/RNDynamsoftLicense.m +62 -62
  126. package/ios/RNDynamsoftMultiCrossFilter.h +14 -14
  127. package/ios/RNDynamsoftMultiCrossFilter.m +145 -145
  128. package/ios/RNDynamsoftVersions.h +13 -13
  129. package/ios/RNDynamsoftVersions.m +27 -27
  130. package/package.json +48 -48
  131. package/src/NativeDynamsoftVersionsModule.tsx +20 -20
  132. package/src/VersionsModule.tsx +7 -7
  133. package/src/core/CapturedResultBase.tsx +18 -18
  134. package/src/core/CapturedResultItem.tsx +23 -23
  135. package/src/core/CoreModule.tsx +9 -9
  136. package/src/core/DSRect.tsx +29 -29
  137. package/src/core/EnumCaptureResultItemType.tsx +52 -52
  138. package/src/core/EnumColourChannelUsageType.tsx +26 -26
  139. package/src/core/EnumCrossVerificationStatus.tsx +46 -46
  140. package/src/core/EnumGrayscaleEnhancementMode.tsx +46 -46
  141. package/src/core/EnumGrayscaleTransformationMode.tsx +35 -35
  142. package/src/core/EnumImageFileFormat.tsx +6 -6
  143. package/src/core/EnumPixelFormat.tsx +53 -53
  144. package/src/core/ImageData.tsx +87 -87
  145. package/src/core/ImageSourceAdapter.tsx +160 -160
  146. package/src/core/NativeDynamsoftImageSourceAdapterModule.tsx +29 -29
  147. package/src/core/Point.tsx +13 -13
  148. package/src/core/Quadrilateral.tsx +12 -12
  149. package/src/core/index.tsx +18 -18
  150. package/src/cvr/CaptureVisionRouter.tsx +683 -683
  151. package/src/cvr/CaptureVisionRouterModule.tsx +9 -9
  152. package/src/cvr/CapturedResult.tsx +123 -123
  153. package/src/cvr/CapturedResultFilter.tsx +13 -13
  154. package/src/cvr/CapturedResultReceiver.tsx +71 -71
  155. package/src/cvr/EnumPresetTemplate.tsx +81 -81
  156. package/src/cvr/NativeDynamsoftCaptureVisionRouterModule.tsx +25 -25
  157. package/src/cvr/SimplifiedCaptureVisionSettings.tsx +61 -61
  158. package/src/cvr/index.tsx +11 -11
  159. package/src/dbr/BarcodeDetails.tsx +51 -51
  160. package/src/dbr/BarcodeReaderModule.tsx +9 -9
  161. package/src/dbr/BarcodeResultItem.tsx +65 -65
  162. package/src/dbr/DecodedBarcodesResult.tsx +14 -14
  163. package/src/dbr/ECISegment.tsx +23 -23
  164. package/src/dbr/EnumBarcodeFormat.tsx +112 -112
  165. package/src/dbr/EnumDeblurMode.tsx +29 -29
  166. package/src/dbr/EnumLocalizationMode.tsx +27 -27
  167. package/src/dbr/EnumQRCodeErrorCorrectionLevel.tsx +6 -6
  168. package/src/dbr/SimplifiedBarcodeReaderSettings.tsx +80 -80
  169. package/src/dbr/index.tsx +9 -9
  170. package/src/dce/CameraEnhancer.tsx +254 -254
  171. package/src/dce/CameraEnhancerModule.tsx +9 -9
  172. package/src/dce/CameraView.tsx +100 -100
  173. package/src/dce/DynamsoftCameraViewNativeComponent.ts +96 -96
  174. package/src/dce/DynamsoftImageEditorViewNativeComponent.ts +9 -9
  175. package/src/dce/EnumCameraPosition.tsx +25 -25
  176. package/src/dce/EnumDrawingLayerId.tsx +17 -17
  177. package/src/dce/EnumEnhancedFeatures.tsx +24 -24
  178. package/src/dce/EnumFocusMode.tsx +6 -6
  179. package/src/dce/EnumResolution.tsx +8 -8
  180. package/src/dce/EnumTorchState.tsx +10 -10
  181. package/src/dce/FeedBack.tsx +28 -28
  182. package/src/dce/ImageEditorView.tsx +131 -131
  183. package/src/dce/NativeDynamsoftCameraViewModule.tsx +47 -47
  184. package/src/dce/NativeDynamsoftImageEditorViewModule.ts +9 -9
  185. package/src/dce/index.tsx +13 -13
  186. package/src/dcp/CodeParserDedicatorModule.tsx +9 -9
  187. package/src/dcp/CodeParserModule.tsx +9 -9
  188. package/src/dcp/EnumMappingStatus.tsx +14 -14
  189. package/src/dcp/EnumValidationStatus.tsx +14 -14
  190. package/src/dcp/ParsedResult.tsx +14 -14
  191. package/src/dcp/ParsedResultItem.tsx +50 -50
  192. package/src/dcp/index.tsx +8 -8
  193. package/src/ddn/DeskewedImageResultItem.tsx +40 -40
  194. package/src/ddn/DetectedQuadResultItem.tsx +31 -31
  195. package/src/ddn/DocumentNormalizerModule.tsx +9 -9
  196. package/src/ddn/EnhancedImageResultItem.tsx +20 -20
  197. package/src/ddn/EnumImageColourMode.tsx +14 -14
  198. package/src/ddn/ProcessedDocumentResult.tsx +27 -27
  199. package/src/ddn/SimplifiedDocumentNormalizerSettings.tsx +65 -65
  200. package/src/ddn/index.tsx +11 -11
  201. package/src/dip/ImageProcessingModule.tsx +9 -9
  202. package/src/dip/index.tsx +1 -1
  203. package/src/dlr/CharacterResult.tsx +28 -28
  204. package/src/dlr/LabelRecognizerModule.tsx +9 -9
  205. package/src/dlr/RecognizedTextLinesResult.tsx +19 -19
  206. package/src/dlr/SimplifiedLabelRecognizerSettings.tsx +33 -33
  207. package/src/dlr/TextLineResultItem.tsx +41 -41
  208. package/src/dlr/index.tsx +8 -8
  209. package/src/index.tsx +13 -13
  210. package/src/license/LicenseManager.tsx +49 -49
  211. package/src/license/LicenseModule.tsx +9 -9
  212. package/src/license/NativeDynamsoftLicenseModule.tsx +7 -7
  213. package/src/license/index.tsx +7 -7
  214. package/src/utility/CrossVerificationCriteria.tsx +11 -11
  215. package/src/utility/EnumFilterType.tsx +5 -5
  216. package/src/utility/ImageManager.tsx +348 -348
  217. package/src/utility/MultiFrameResultCrossFilter.tsx +183 -183
  218. package/src/utility/NativeDynamsoftImageManagerModule.tsx +7 -7
  219. package/src/utility/NativeDynamsoftMultiCrossFilterModule.tsx +18 -18
  220. package/src/utility/UtilityModule.tsx +9 -9
  221. package/src/utility/index.tsx +4 -4
  222. package/android/.gitignore +0 -4
@@ -1,131 +1,131 @@
1
- // @ts-ignore
2
- import React, {Component, createElement} from "react";
3
- import {
4
- findNodeHandle,
5
- type HostComponent,
6
- type NativeMethods,
7
- NativeModules,
8
- requireNativeComponent,
9
- StyleSheet,
10
- View
11
- } from "react-native";
12
- import type {EnumDrawingLayerId} from "./EnumDrawingLayerId";
13
- import type {Quadrilateral, ImageData} from "../core";
14
- import type {ImageEditorViewNativeProps} from "./DynamsoftImageEditorViewNativeComponent";
15
- import type {CameraViewNativeProps} from "./DynamsoftCameraViewNativeComponent";
16
-
17
- const ComponentName = "DynamsoftImageEditorView";
18
-
19
- // @ts-ignore Check whether __turboModuleProxy exists, it may not
20
- const isTurboModuleEnabled = global.__turboModuleProxy != null;
21
-
22
- const NativeImageEditorView: HostComponent<CameraViewNativeProps> = isTurboModuleEnabled ?
23
- require("./DynamsoftImageEditorViewNativeComponent").default :
24
- requireNativeComponent(ComponentName)
25
-
26
- const ImageEditorViewModule = isTurboModuleEnabled ?
27
- require("./NativeDynamsoftImageEditorViewModule").default :
28
- NativeModules.DynamsoftImageEditorView;
29
-
30
- let isInstalled = false
31
- const installMethods = () => {
32
- if (!isInstalled) {
33
- ImageEditorViewModule.install()
34
- isInstalled = true
35
- }
36
- }
37
-
38
- declare var global: {
39
- editorView_setOriginalImage: (viewTag: number, imageData: ImageData) => void;
40
- };
41
-
42
- type RefType = React.Component<ImageEditorViewNativeProps> & Readonly<NativeMethods>;
43
-
44
- /**
45
- * The ImageEditorView class is a React Component for image editing that wraps the native ImageEditorView.
46
- * It encapsulates interactions with the native view and provides functionality
47
- * to set images and edit quadrilaterals.
48
- * @prop CameraViewNativeProps
49
- * @see {@link CameraViewNativeProps}
50
- * @see {@link CameraEnhancer.setCameraView}
51
- * @hideconstructor
52
- */
53
- export class ImageEditorView extends Component<ImageEditorViewNativeProps, any> {
54
- // A Ref object pointing to the native ImageEditorView
55
- private readonly nativeImageEditorViewRef: React.RefObject<RefType | null> = React.createRef<RefType>();
56
- private drawingQuads: Array<Quadrilateral> | null | undefined;
57
-
58
- /** @internal */
59
- public get nativeCameraViewHandle(): number | null {
60
- return findNodeHandle(this.nativeImageEditorViewRef.current);
61
- }
62
-
63
- /**
64
- * Sets the original image in the native image editor.
65
- * @param imageData The {@link ImageData} Object to be set as the original image.
66
- */
67
- public setOriginalImage(imageData: ImageData) {
68
- installMethods();
69
- if (typeof global.editorView_setOriginalImage !== 'function') {
70
- return;
71
- }
72
- if (this.nativeCameraViewHandle != null) {
73
- global.editorView_setOriginalImage(this.nativeCameraViewHandle!, imageData);
74
- }
75
- }
76
-
77
- /**
78
- * Updates the quadrilaterals in the editor for a specific drawing layer.
79
- * @param quads The quadrilaterals to set, or null/undefined to clear them. The coordinate base of the point is "image".
80
- * @param layerId The ID of the drawing layer to update.
81
- * @returns A promise that resolves once the operation completes.
82
- */
83
- public async setQuads(quads: Quadrilateral[] | null | undefined, layerId: EnumDrawingLayerId | number): Promise<void> {
84
- if (this.nativeCameraViewHandle != null) {
85
- this.drawingQuads = quads;
86
- await ImageEditorViewModule.setQuads(this.nativeCameraViewHandle!, quads, layerId);
87
- }
88
- }
89
-
90
- /**
91
- * Retrieves the currently selected quadrilateral from the editor.
92
- * @returns A promise that resolves to the selected quadrilateral, or first Quadrilateral if none is selected.
93
- */
94
- public async getSelectedQuad(): Promise<Quadrilateral | null> {
95
- if (this.nativeCameraViewHandle != null) {
96
- let selectedQuad = await ImageEditorViewModule.getSelectedQuad(this.nativeCameraViewHandle!);
97
- if(selectedQuad) {
98
- return selectedQuad;
99
- } else if(this.drawingQuads && this.drawingQuads.length > 0) {
100
- selectedQuad = this.drawingQuads[0]
101
- }
102
- return selectedQuad;
103
- } else {
104
- return null;
105
- }
106
- }
107
-
108
- public render(): React.ReactNode {
109
- return (
110
- <View style={[styles.blackBg, this.props?.style]}>
111
- <NativeImageEditorView
112
- collapsable={false}
113
- style={StyleSheet.absoluteFill}
114
- ref={this.nativeImageEditorViewRef}
115
- />
116
- {this.props?.children}
117
- </View>
118
- );
119
- }
120
- }
121
-
122
- const styles = StyleSheet.create({
123
- container: {
124
- flex: 1,
125
- alignItems: "center",
126
- justifyContent: "center"
127
- },
128
- blackBg: {
129
- backgroundColor: "black"
130
- }
131
- });
1
+ // @ts-ignore
2
+ import React, {Component, createElement} from "react";
3
+ import {
4
+ findNodeHandle,
5
+ type HostComponent,
6
+ type NativeMethods,
7
+ NativeModules,
8
+ requireNativeComponent,
9
+ StyleSheet,
10
+ View
11
+ } from "react-native";
12
+ import type {EnumDrawingLayerId} from "./EnumDrawingLayerId";
13
+ import type {Quadrilateral, ImageData} from "../core";
14
+ import type {ImageEditorViewNativeProps} from "./DynamsoftImageEditorViewNativeComponent";
15
+ import type {CameraViewNativeProps} from "./DynamsoftCameraViewNativeComponent";
16
+
17
+ const ComponentName = "DynamsoftImageEditorView";
18
+
19
+ // @ts-ignore Check whether __turboModuleProxy exists, it may not
20
+ const isTurboModuleEnabled = global.__turboModuleProxy != null;
21
+
22
+ const NativeImageEditorView: HostComponent<CameraViewNativeProps> = isTurboModuleEnabled ?
23
+ require("./DynamsoftImageEditorViewNativeComponent").default :
24
+ requireNativeComponent(ComponentName)
25
+
26
+ const ImageEditorViewModule = isTurboModuleEnabled ?
27
+ require("./NativeDynamsoftImageEditorViewModule").default :
28
+ NativeModules.DynamsoftImageEditorView;
29
+
30
+ let isInstalled = false
31
+ const installMethods = () => {
32
+ if (!isInstalled) {
33
+ ImageEditorViewModule.install()
34
+ isInstalled = true
35
+ }
36
+ }
37
+
38
+ declare var global: {
39
+ editorView_setOriginalImage: (viewTag: number, imageData: ImageData) => void;
40
+ };
41
+
42
+ type RefType = React.Component<ImageEditorViewNativeProps> & Readonly<NativeMethods>;
43
+
44
+ /**
45
+ * The ImageEditorView class is a React Component for image editing that wraps the native ImageEditorView.
46
+ * It encapsulates interactions with the native view and provides functionality
47
+ * to set images and edit quadrilaterals.
48
+ * @prop CameraViewNativeProps
49
+ * @see {@link CameraViewNativeProps}
50
+ * @see {@link CameraEnhancer.setCameraView}
51
+ * @hideconstructor
52
+ */
53
+ export class ImageEditorView extends Component<ImageEditorViewNativeProps, any> {
54
+ // A Ref object pointing to the native ImageEditorView
55
+ private readonly nativeImageEditorViewRef: React.RefObject<RefType | null> = React.createRef<RefType>();
56
+ private drawingQuads: Array<Quadrilateral> | null | undefined;
57
+
58
+ /** @internal */
59
+ public get nativeCameraViewHandle(): number | null {
60
+ return findNodeHandle(this.nativeImageEditorViewRef.current);
61
+ }
62
+
63
+ /**
64
+ * Sets the original image in the native image editor.
65
+ * @param imageData The {@link ImageData} Object to be set as the original image.
66
+ */
67
+ public setOriginalImage(imageData: ImageData) {
68
+ installMethods();
69
+ if (typeof global.editorView_setOriginalImage !== 'function') {
70
+ return;
71
+ }
72
+ if (this.nativeCameraViewHandle != null) {
73
+ global.editorView_setOriginalImage(this.nativeCameraViewHandle!, imageData);
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Updates the quadrilaterals in the editor for a specific drawing layer.
79
+ * @param quads The quadrilaterals to set, or null/undefined to clear them. The coordinate base of the point is "image".
80
+ * @param layerId The ID of the drawing layer to update.
81
+ * @returns A promise that resolves once the operation completes.
82
+ */
83
+ public async setQuads(quads: Quadrilateral[] | null | undefined, layerId: EnumDrawingLayerId | number): Promise<void> {
84
+ if (this.nativeCameraViewHandle != null) {
85
+ this.drawingQuads = quads;
86
+ await ImageEditorViewModule.setQuads(this.nativeCameraViewHandle!, quads, layerId);
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Retrieves the currently selected quadrilateral from the editor.
92
+ * @returns A promise that resolves to the selected quadrilateral, or first Quadrilateral if none is selected.
93
+ */
94
+ public async getSelectedQuad(): Promise<Quadrilateral | null> {
95
+ if (this.nativeCameraViewHandle != null) {
96
+ let selectedQuad = await ImageEditorViewModule.getSelectedQuad(this.nativeCameraViewHandle!);
97
+ if(selectedQuad) {
98
+ return selectedQuad;
99
+ } else if(this.drawingQuads && this.drawingQuads.length > 0) {
100
+ selectedQuad = this.drawingQuads[0]
101
+ }
102
+ return selectedQuad;
103
+ } else {
104
+ return null;
105
+ }
106
+ }
107
+
108
+ public render(): React.ReactNode {
109
+ return (
110
+ <View style={[styles.blackBg, this.props?.style]}>
111
+ <NativeImageEditorView
112
+ collapsable={false}
113
+ style={StyleSheet.absoluteFill}
114
+ ref={this.nativeImageEditorViewRef}
115
+ />
116
+ {this.props?.children}
117
+ </View>
118
+ );
119
+ }
120
+ }
121
+
122
+ const styles = StyleSheet.create({
123
+ container: {
124
+ flex: 1,
125
+ alignItems: "center",
126
+ justifyContent: "center"
127
+ },
128
+ blackBg: {
129
+ backgroundColor: "black"
130
+ }
131
+ });
@@ -1,47 +1,47 @@
1
- import {type TurboModule, TurboModuleRegistry} from "react-native";
2
-
3
- export interface Spec extends TurboModule {
4
- createInstance(): string;
5
-
6
- requestCameraPermission(): void;
7
-
8
- open(): void;
9
-
10
- close(): void;
11
-
12
- setCameraView(viewId: number): void;
13
-
14
- selectCamera(position: number): void;
15
-
16
- getCameraPosition(): Promise<number>;
17
-
18
- setFocus(floatX: number, floatY: number, focusMode: number): void;
19
-
20
- getFocusMode(): Promise<number>;
21
-
22
- setZoomFactor(factor: number): void;
23
-
24
- getZoomFactor(): Promise<number>;
25
-
26
- enableEnhancedFeatures(features: number): void;
27
-
28
- disableEnhancedFeatures(features: number): void;
29
-
30
- setScanRegion(region: unknown | null | undefined): void;
31
-
32
- getScanRegion(): Promise<unknown | null | undefined>;
33
-
34
- turnOnTorch(): void;
35
-
36
- turnOffTorch(): void;
37
-
38
- setResolution(resolution: number): void;
39
-
40
- getResolution(): Promise<unknown>;
41
-
42
- beep(): void;
43
-
44
- vibrate(): void;
45
- }
46
-
47
- export default TurboModuleRegistry.get<Spec>("DynamsoftCameraView") as Spec | null;
1
+ import {type TurboModule, TurboModuleRegistry} from "react-native";
2
+
3
+ export interface Spec extends TurboModule {
4
+ createInstance(): string;
5
+
6
+ requestCameraPermission(): void;
7
+
8
+ open(): void;
9
+
10
+ close(): void;
11
+
12
+ setCameraView(viewId: number): void;
13
+
14
+ selectCamera(position: number): void;
15
+
16
+ getCameraPosition(): Promise<number>;
17
+
18
+ setFocus(floatX: number, floatY: number, focusMode: number): void;
19
+
20
+ getFocusMode(): Promise<number>;
21
+
22
+ setZoomFactor(factor: number): void;
23
+
24
+ getZoomFactor(): Promise<number>;
25
+
26
+ enableEnhancedFeatures(features: number): void;
27
+
28
+ disableEnhancedFeatures(features: number): void;
29
+
30
+ setScanRegion(region: unknown | null | undefined): void;
31
+
32
+ getScanRegion(): Promise<unknown | null | undefined>;
33
+
34
+ turnOnTorch(): void;
35
+
36
+ turnOffTorch(): void;
37
+
38
+ setResolution(resolution: number): void;
39
+
40
+ getResolution(): Promise<unknown>;
41
+
42
+ beep(): void;
43
+
44
+ vibrate(): void;
45
+ }
46
+
47
+ export default TurboModuleRegistry.get<Spec>("DynamsoftCameraView") as Spec | null;
@@ -1,9 +1,9 @@
1
- import {type TurboModule, TurboModuleRegistry} from "react-native";
2
-
3
- export interface Spec extends TurboModule {
4
- install(): boolean;
5
- setQuads(viewTag:number, quads: Array<unknown>, layerId:number) : Promise<void>;
6
- getSelectedQuad(viewTag:number) : Promise<unknown>;
7
- }
8
-
9
- export default TurboModuleRegistry.get<Spec>("DynamsoftImageEditorView") as Spec | null;
1
+ import {type TurboModule, TurboModuleRegistry} from "react-native";
2
+
3
+ export interface Spec extends TurboModule {
4
+ install(): boolean;
5
+ setQuads(viewTag:number, quads: Array<unknown>, layerId:number) : Promise<void>;
6
+ getSelectedQuad(viewTag:number) : Promise<unknown>;
7
+ }
8
+
9
+ export default TurboModuleRegistry.get<Spec>("DynamsoftImageEditorView") as Spec | null;
package/src/dce/index.tsx CHANGED
@@ -1,13 +1,13 @@
1
- export * from "./CameraEnhancer"
2
- export * from "./CameraEnhancerModule"
3
- export * from "./CameraView"
4
- export * from "./EnumCameraPosition"
5
- export * from "./EnumDrawingLayerId"
6
- export * from "./EnumEnhancedFeatures"
7
- export * from "./EnumFocusMode"
8
- export * from "./EnumTorchState"
9
- export * from "./FeedBack"
10
- export * from "./ImageEditorView"
11
- export * from "./EnumResolution"
12
- export type {CameraViewNativeProps} from "./DynamsoftCameraViewNativeComponent"
13
- export type {ImageEditorViewNativeProps} from "./DynamsoftImageEditorViewNativeComponent"
1
+ export * from "./CameraEnhancer"
2
+ export * from "./CameraEnhancerModule"
3
+ export * from "./CameraView"
4
+ export * from "./EnumCameraPosition"
5
+ export * from "./EnumDrawingLayerId"
6
+ export * from "./EnumEnhancedFeatures"
7
+ export * from "./EnumFocusMode"
8
+ export * from "./EnumTorchState"
9
+ export * from "./FeedBack"
10
+ export * from "./ImageEditorView"
11
+ export * from "./EnumResolution"
12
+ export type {CameraViewNativeProps} from "./DynamsoftCameraViewNativeComponent"
13
+ export type {ImageEditorViewNativeProps} from "./DynamsoftImageEditorViewNativeComponent"
@@ -1,9 +1,9 @@
1
- import {DynamsoftVersions} from '../VersionsModule'
2
- import {Platform} from "react-native";
3
-
4
- /** @hideconstructor */
5
- export class CodeParserDedicatorModule {
6
- static getVersion(): string {
7
- return '['+Platform.OS+']: ' + DynamsoftVersions.dcpd
8
- }
9
- }
1
+ import {DynamsoftVersions} from '../VersionsModule'
2
+ import {Platform} from "react-native";
3
+
4
+ /** @hideconstructor */
5
+ export class CodeParserDedicatorModule {
6
+ static getVersion(): string {
7
+ return '['+Platform.OS+']: ' + DynamsoftVersions.dcpd
8
+ }
9
+ }
@@ -1,9 +1,9 @@
1
- import {DynamsoftVersions} from '../VersionsModule'
2
- import {Platform} from "react-native";
3
-
4
- /** @hideconstructor */
5
- export class CodeParserModule {
6
- static getVersion(): string {
7
- return '['+Platform.OS+']: ' + DynamsoftVersions.dcp
8
- }
9
- }
1
+ import {DynamsoftVersions} from '../VersionsModule'
2
+ import {Platform} from "react-native";
3
+
4
+ /** @hideconstructor */
5
+ export class CodeParserModule {
6
+ static getVersion(): string {
7
+ return '['+Platform.OS+']: ' + DynamsoftVersions.dcp
8
+ }
9
+ }
@@ -1,14 +1,14 @@
1
- /**
2
- * `MappingStatus` represents the outcome of a mapping operation on a field.
3
- * @see {@link ParsedField.validationStatus}
4
- * */
5
- export enum EnumMappingStatus {
6
- /** The field has no mapping specified. */
7
- MS_NONE,
8
-
9
- /** Find a mapping for the field value. */
10
- MS_SUCCEEDED,
11
-
12
- /** Failed to find a mapping for the field value. */
13
- MS_FAILED
14
- }
1
+ /**
2
+ * `MappingStatus` represents the outcome of a mapping operation on a field.
3
+ * @see {@link ParsedField.validationStatus}
4
+ * */
5
+ export enum EnumMappingStatus {
6
+ /** The field has no mapping specified. */
7
+ MS_NONE,
8
+
9
+ /** Find a mapping for the field value. */
10
+ MS_SUCCEEDED,
11
+
12
+ /** Failed to find a mapping for the field value. */
13
+ MS_FAILED
14
+ }
@@ -1,14 +1,14 @@
1
- /**
2
- * `ValidationStatus` describes the outcome of a validation process on a field.
3
- * @see {@link ParsedField.mappingStatus}
4
- * */
5
- export enum EnumValidationStatus {
6
- /** The field has no validation specified. */
7
- VS_NONE,
8
-
9
- /** The validation for the field has been succeeded. */
10
- VS_SUCCEEDED,
11
-
12
- /** The validation for the field has been succeeded. */
13
- VS_FAILED
14
- }
1
+ /**
2
+ * `ValidationStatus` describes the outcome of a validation process on a field.
3
+ * @see {@link ParsedField.mappingStatus}
4
+ * */
5
+ export enum EnumValidationStatus {
6
+ /** The field has no validation specified. */
7
+ VS_NONE,
8
+
9
+ /** The validation for the field has been succeeded. */
10
+ VS_SUCCEEDED,
11
+
12
+ /** The validation for the field has been succeeded. */
13
+ VS_FAILED
14
+ }
@@ -1,14 +1,14 @@
1
- import type {ParsedResultItem} from "./ParsedResultItem";
2
- import type {CapturedResultReceiver} from "../cvr";
3
- import type {CapturedResultBase} from "../core/CapturedResultBase";
4
-
5
- /**
6
- * The ParsedResult interface provides a structure representing the result object returned by Dynamsoft Code Parser.
7
- * @see {@link CapturedResultReceiver.onParsedResultsReceived}
8
- * */
9
- export interface ParsedResult extends CapturedResultBase {
10
- /**An array that contains all {@link ParsedResultItem}s.
11
- * @see {@link ParsedResultItem}
12
- * */
13
- items?: Array<ParsedResultItem>;
14
- }
1
+ import type {ParsedResultItem} from "./ParsedResultItem";
2
+ import type {CapturedResultReceiver} from "../cvr";
3
+ import type {CapturedResultBase} from "../core/CapturedResultBase";
4
+
5
+ /**
6
+ * The ParsedResult interface provides a structure representing the result object returned by Dynamsoft Code Parser.
7
+ * @see {@link CapturedResultReceiver.onParsedResultsReceived}
8
+ * */
9
+ export interface ParsedResult extends CapturedResultBase {
10
+ /**An array that contains all {@link ParsedResultItem}s.
11
+ * @see {@link ParsedResultItem}
12
+ * */
13
+ items?: Array<ParsedResultItem>;
14
+ }
@@ -1,50 +1,50 @@
1
- import type {CapturedResultItem, EnumCapturedResultItemType} from "../core";
2
- import type {EnumMappingStatus} from "./EnumMappingStatus";
3
- import type {EnumValidationStatus} from "./EnumValidationStatus";
4
-
5
- /**
6
- * The ParsedResultItem interface provides a structure representing the result items returned by Dynamsoft Code Parser.
7
- * @see {@link EnumCapturedResultItemType.CRIT_PARSED_RESULT}
8
- * */
9
- export interface ParsedResultItem extends CapturedResultItem{
10
- /**
11
- * The code type of the parsed result.
12
- * */
13
- codeType: string
14
-
15
- /**
16
- * The parsed result as a JSON formatted string.
17
- * */
18
- jsonString: string
19
-
20
- /**
21
- * Optional fields containing parsed data. Each field represents a specific component
22
- * of the parsed code, such as a value, mapping status, or validation status.
23
- * The key is the field name, and the value is an object containing additional details.
24
- */
25
- parsedFields?: Record<string, ParsedField>
26
- }
27
-
28
-
29
- /**
30
- * The ParsedField interface defines the structure for individual parsed fields within a ParsedResultItem.
31
- * It provides information about the field value and its statuses.
32
- */
33
- export interface ParsedField {
34
- /**
35
- * The value of the parsed field as a string. This represents the extracted data for the field.
36
- */
37
- value?: string,
38
-
39
- /**
40
- * The mapping status of the field.
41
- * @see {@link EnumMappingStatus}
42
- */
43
- mappingStatus?: EnumMappingStatus | number,
44
-
45
- /**
46
- * The validation status of the field.
47
- * @see {@link EnumValidationStatus}
48
- * */
49
- validationStatus?: EnumValidationStatus | number
50
- }
1
+ import type {CapturedResultItem, EnumCapturedResultItemType} from "../core";
2
+ import type {EnumMappingStatus} from "./EnumMappingStatus";
3
+ import type {EnumValidationStatus} from "./EnumValidationStatus";
4
+
5
+ /**
6
+ * The ParsedResultItem interface provides a structure representing the result items returned by Dynamsoft Code Parser.
7
+ * @see {@link EnumCapturedResultItemType.CRIT_PARSED_RESULT}
8
+ * */
9
+ export interface ParsedResultItem extends CapturedResultItem{
10
+ /**
11
+ * The code type of the parsed result.
12
+ * */
13
+ codeType: string
14
+
15
+ /**
16
+ * The parsed result as a JSON formatted string.
17
+ * */
18
+ jsonString: string
19
+
20
+ /**
21
+ * Optional fields containing parsed data. Each field represents a specific component
22
+ * of the parsed code, such as a value, mapping status, or validation status.
23
+ * The key is the field name, and the value is an object containing additional details.
24
+ */
25
+ parsedFields?: Record<string, ParsedField>
26
+ }
27
+
28
+
29
+ /**
30
+ * The ParsedField interface defines the structure for individual parsed fields within a ParsedResultItem.
31
+ * It provides information about the field value and its statuses.
32
+ */
33
+ export interface ParsedField {
34
+ /**
35
+ * The value of the parsed field as a string. This represents the extracted data for the field.
36
+ */
37
+ value?: string,
38
+
39
+ /**
40
+ * The mapping status of the field.
41
+ * @see {@link EnumMappingStatus}
42
+ */
43
+ mappingStatus?: EnumMappingStatus | number,
44
+
45
+ /**
46
+ * The validation status of the field.
47
+ * @see {@link EnumValidationStatus}
48
+ * */
49
+ validationStatus?: EnumValidationStatus | number
50
+ }
package/src/dcp/index.tsx CHANGED
@@ -1,8 +1,8 @@
1
- export * from "./CodeParserDedicatorModule"
2
- export * from "./CodeParserModule"
3
-
4
- export * from "./EnumMappingStatus"
5
- export * from "./EnumValidationStatus"
6
-
7
- export * from "./ParsedResult"
8
- export * from "./ParsedResultItem"
1
+ export * from "./CodeParserDedicatorModule"
2
+ export * from "./CodeParserModule"
3
+
4
+ export * from "./EnumMappingStatus"
5
+ export * from "./EnumValidationStatus"
6
+
7
+ export * from "./ParsedResult"
8
+ export * from "./ParsedResultItem"