@dariyd/react-native-document-scanner 2.0.13

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.
@@ -0,0 +1,13 @@
1
+ // DocumentScanner.h
2
+
3
+ #import <React/RCTBridgeModule.h>
4
+
5
+ #ifdef RCT_NEW_ARCH_ENABLED
6
+ #import <RNDocumentScannerSpec/RNDocumentScannerSpec.h>
7
+
8
+ @interface DocumentScanner : NativeDocumentScannerSpecBase <NativeDocumentScannerSpec>
9
+ #else
10
+ @interface DocumentScanner : NSObject <RCTBridgeModule>
11
+ #endif
12
+
13
+ @end
@@ -0,0 +1,180 @@
1
+ // DocumentScanner.mm
2
+
3
+ #import "DocumentScanner.h"
4
+ #import "VisionKit/VisionKit.h"
5
+ #import "VisionKit/VNDocumentCameraViewController.h"
6
+ #import <React/RCTUtils.h>
7
+
8
+ #ifdef RCT_NEW_ARCH_ENABLED
9
+ #import <RNDocumentScannerSpec/RNDocumentScannerSpec.h>
10
+ #endif
11
+
12
+ using namespace facebook::react;
13
+
14
+ @interface DocumentScanner ()
15
+
16
+ @property (nonatomic, strong) RCTResponseSenderBlock callback;
17
+ @property (nonatomic, copy) NSDictionary *options;
18
+ @end
19
+
20
+
21
+ @interface DocumentScanner (VNDocumentCameraViewControllerDelegate) <VNDocumentCameraViewControllerDelegate>
22
+ @end
23
+
24
+ @implementation DocumentScanner
25
+
26
+ RCT_EXPORT_MODULE()
27
+
28
+ + (BOOL)requiresMainQueueSetup
29
+ {
30
+ return NO;
31
+ }
32
+
33
+ #ifdef RCT_NEW_ARCH_ENABLED
34
+ - (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params
35
+ {
36
+ return std::make_shared<NativeDocumentScannerSpecJSI>(params);
37
+ }
38
+
39
+ // New architecture method (implements the protocol)
40
+ - (void)launchScanner:(JS::NativeDocumentScanner::Options &)options
41
+ callback:(RCTResponseSenderBlock)callback
42
+ {
43
+ // Convert C++ struct to NSDictionary
44
+ NSMutableDictionary *opts = [NSMutableDictionary new];
45
+ if (options.quality().has_value()) {
46
+ opts[@"quality"] = @(options.quality().value());
47
+ }
48
+ if (options.includeBase64().has_value()) {
49
+ opts[@"includeBase64"] = @(options.includeBase64().value());
50
+ }
51
+
52
+ dispatch_async(dispatch_get_main_queue(), ^{
53
+ [self launchDocScanner:opts callback:callback];
54
+ });
55
+ }
56
+ #else
57
+ // Old architecture method
58
+ RCT_EXPORT_METHOD(launchScanner:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback)
59
+ {
60
+ dispatch_async(dispatch_get_main_queue(), ^{
61
+ [self launchDocScanner:options callback:callback];
62
+ });
63
+ }
64
+ #endif
65
+
66
+ - (void)launchDocScanner:(NSDictionary *)options callback:(RCTResponseSenderBlock)callback
67
+ {
68
+ self.callback = callback;
69
+ self.options = options;
70
+
71
+ VNDocumentCameraViewController * scanner = [[VNDocumentCameraViewController alloc] init];
72
+ scanner.delegate = self;
73
+
74
+ [RCTPresentedViewController() presentViewController:scanner animated:YES completion:nil];
75
+ }
76
+ @end
77
+
78
+ @implementation DocumentScanner (VNDocumentCameraViewControllerDelegate)
79
+
80
+ + (NSString*) getFileType:(NSData *)imageData
81
+ {
82
+ const uint8_t firstByteJpg = 0xFF;
83
+ const uint8_t firstBytePng = 0x89;
84
+ const uint8_t firstByteGif = 0x47;
85
+
86
+ uint8_t firstByte;
87
+ [imageData getBytes:&firstByte length:1];
88
+ switch (firstByte) {
89
+ case firstByteJpg:
90
+ return @"jpg";
91
+ case firstBytePng:
92
+ return @"png";
93
+ case firstByteGif:
94
+ return @"gif";
95
+ default:
96
+ return @"jpg";
97
+ }
98
+ }
99
+
100
+ - (NSString *)getImageFileName:(NSString *)fileType
101
+ {
102
+ NSString *fileName = [[NSUUID UUID] UUIDString];
103
+ fileName = [fileName stringByAppendingString:@"."];
104
+ return [fileName stringByAppendingString:fileType];
105
+ }
106
+
107
+ -(NSMutableDictionary *)mapImageToAsset:(UIImage *)image {
108
+ NSString *fileType = self.options[@"quality"] != nil && [self.options[@"quality"] floatValue] < 1.0 ? @"jpg" : @"png";
109
+ NSData *data = nil;
110
+
111
+ if ([fileType isEqualToString:@"jpg"]) {
112
+ data = UIImageJPEGRepresentation(image, [self.options[@"quality"] floatValue]);
113
+ } else if ([fileType isEqualToString:@"png"]) {
114
+ data = UIImagePNGRepresentation(image);
115
+ }
116
+
117
+ NSMutableDictionary *asset = [[NSMutableDictionary alloc] init];
118
+ asset[@"type"] = [@"image/" stringByAppendingString:fileType];
119
+
120
+ NSString *fileName = [self getImageFileName:fileType];
121
+ NSString *path = [[NSTemporaryDirectory() stringByStandardizingPath] stringByAppendingPathComponent:fileName];
122
+ [data writeToFile:path atomically:YES];
123
+
124
+ if ([self.options[@"includeBase64"] boolValue]) {
125
+ asset[@"base64"] = [data base64EncodedStringWithOptions:0];
126
+ }
127
+
128
+ NSURL *fileURL = [NSURL fileURLWithPath:path];
129
+ asset[@"uri"] = [fileURL absoluteString];
130
+
131
+ NSNumber *fileSizeValue = nil;
132
+ NSError *fileSizeError = nil;
133
+ [fileURL getResourceValue:&fileSizeValue forKey:NSURLFileSizeKey error:&fileSizeError];
134
+ if (fileSizeValue){
135
+ asset[@"fileSize"] = fileSizeValue;
136
+ }
137
+
138
+ asset[@"fileName"] = fileName;
139
+ asset[@"width"] = @(image.size.width);
140
+ asset[@"height"] = @(image.size.height);
141
+
142
+ return asset;
143
+ }
144
+
145
+ - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
146
+ {
147
+ dispatch_async(dispatch_get_main_queue(), ^{
148
+ [picker dismissViewControllerAnimated:YES completion:^{
149
+ self.callback(@[@{ @"didCancel": @YES }]);
150
+ }];
151
+ });
152
+ }
153
+
154
+ - (void)documentCameraViewController:(VNDocumentCameraViewController *)controller didFinishWithScan:(VNDocumentCameraScan *)scan{
155
+ NSMutableArray *scannedImages = [NSMutableArray array];
156
+ for (int i = 0; i < [scan pageCount]; i++) {
157
+ UIImage *image = [scan imageOfPageAtIndex:i];
158
+ [scannedImages addObject:[self mapImageToAsset:image]];
159
+ }
160
+
161
+ [controller dismissViewControllerAnimated:true completion:^{
162
+ self.callback(@[@{ @"images": scannedImages }]);
163
+ }];
164
+ }
165
+
166
+ - (void)documentCameraViewControllerDidCancel:(VNDocumentCameraViewController *)controller {
167
+ [controller dismissViewControllerAnimated:true completion:^{
168
+ self.callback(@[@{ @"didCancel": @YES }]);
169
+ }];
170
+ }
171
+
172
+ - (void)documentCameraViewController:(VNDocumentCameraViewController *)controller didFailWithError:(NSError *)error {
173
+ [controller dismissViewControllerAnimated:true completion:^{
174
+ self.callback(@[@{ @"error": @YES, @"errorMessage": error.localizedFailureReason }]);
175
+ }];
176
+ }
177
+
178
+ @end
179
+
180
+
@@ -0,0 +1,281 @@
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 46;
7
+ objects = {
8
+
9
+ /* Begin PBXCopyFilesBuildPhase section */
10
+ 58B511D91A9E6C8500147676 /* CopyFiles */ = {
11
+ isa = PBXCopyFilesBuildPhase;
12
+ buildActionMask = 2147483647;
13
+ dstPath = "include/$(PRODUCT_NAME)";
14
+ dstSubfolderSpec = 16;
15
+ files = (
16
+ );
17
+ runOnlyForDeploymentPostprocessing = 0;
18
+ };
19
+ /* End PBXCopyFilesBuildPhase section */
20
+
21
+ /* Begin PBXFileReference section */
22
+ 134814201AA4EA6300B7C361 /* libDocumentScanner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDocumentScanner.a; sourceTree = BUILT_PRODUCTS_DIR; };
23
+ /* End PBXFileReference section */
24
+
25
+ /* Begin PBXFrameworksBuildPhase section */
26
+ 58B511D81A9E6C8500147676 /* Frameworks */ = {
27
+ isa = PBXFrameworksBuildPhase;
28
+ buildActionMask = 2147483647;
29
+ files = (
30
+ );
31
+ runOnlyForDeploymentPostprocessing = 0;
32
+ };
33
+ /* End PBXFrameworksBuildPhase section */
34
+
35
+ /* Begin PBXGroup section */
36
+ 134814211AA4EA7D00B7C361 /* Products */ = {
37
+ isa = PBXGroup;
38
+ children = (
39
+ 134814201AA4EA6300B7C361 /* libDocumentScanner.a */,
40
+ );
41
+ name = Products;
42
+ sourceTree = "<group>";
43
+ };
44
+ 58B511D21A9E6C8500147676 = {
45
+ isa = PBXGroup;
46
+ children = (
47
+ 134814211AA4EA7D00B7C361 /* Products */,
48
+ );
49
+ sourceTree = "<group>";
50
+ };
51
+ /* End PBXGroup section */
52
+
53
+ /* Begin PBXNativeTarget section */
54
+ 58B511DA1A9E6C8500147676 /* DocumentScanner */ = {
55
+ isa = PBXNativeTarget;
56
+ buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "DocumentScanner" */;
57
+ buildPhases = (
58
+ 58B511D71A9E6C8500147676 /* Sources */,
59
+ 58B511D81A9E6C8500147676 /* Frameworks */,
60
+ 58B511D91A9E6C8500147676 /* CopyFiles */,
61
+ );
62
+ buildRules = (
63
+ );
64
+ dependencies = (
65
+ );
66
+ name = DocumentScanner;
67
+ productName = RCTDataManager;
68
+ productReference = 134814201AA4EA6300B7C361 /* libDocumentScanner.a */;
69
+ productType = "com.apple.product-type.library.static";
70
+ };
71
+ /* End PBXNativeTarget section */
72
+
73
+ /* Begin PBXProject section */
74
+ 58B511D31A9E6C8500147676 /* Project object */ = {
75
+ isa = PBXProject;
76
+ attributes = {
77
+ LastUpgradeCheck = 0920;
78
+ ORGANIZATIONNAME = Facebook;
79
+ TargetAttributes = {
80
+ 58B511DA1A9E6C8500147676 = {
81
+ CreatedOnToolsVersion = 6.1.1;
82
+ };
83
+ };
84
+ };
85
+ buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "DocumentScanner" */;
86
+ compatibilityVersion = "Xcode 3.2";
87
+ developmentRegion = en;
88
+ hasScannedForEncodings = 0;
89
+ knownRegions = (
90
+ en,
91
+ Base,
92
+ );
93
+ mainGroup = 58B511D21A9E6C8500147676;
94
+ productRefGroup = 58B511D21A9E6C8500147676;
95
+ projectDirPath = "";
96
+ projectRoot = "";
97
+ targets = (
98
+ 58B511DA1A9E6C8500147676 /* DocumentScanner */,
99
+ );
100
+ };
101
+ /* End PBXProject section */
102
+
103
+ /* Begin PBXSourcesBuildPhase section */
104
+ 58B511D71A9E6C8500147676 /* Sources */ = {
105
+ isa = PBXSourcesBuildPhase;
106
+ buildActionMask = 2147483647;
107
+ files = (
108
+ );
109
+ runOnlyForDeploymentPostprocessing = 0;
110
+ };
111
+ /* End PBXSourcesBuildPhase section */
112
+
113
+ /* Begin XCBuildConfiguration section */
114
+ 58B511ED1A9E6C8500147676 /* Debug */ = {
115
+ isa = XCBuildConfiguration;
116
+ buildSettings = {
117
+ ALWAYS_SEARCH_USER_PATHS = NO;
118
+ CLANG_ANALYZER_NONNULL = YES;
119
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
120
+ CLANG_CXX_LIBRARY = "libc++";
121
+ CLANG_ENABLE_MODULES = YES;
122
+ CLANG_ENABLE_OBJC_ARC = YES;
123
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
124
+ CLANG_WARN_BOOL_CONVERSION = YES;
125
+ CLANG_WARN_COMMA = YES;
126
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
127
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
128
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
129
+ CLANG_WARN_EMPTY_BODY = YES;
130
+ CLANG_WARN_ENUM_CONVERSION = YES;
131
+ CLANG_WARN_INFINITE_RECURSION = YES;
132
+ CLANG_WARN_INT_CONVERSION = YES;
133
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
134
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
135
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
136
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
137
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
138
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
139
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
140
+ CLANG_WARN_UNREACHABLE_CODE = YES;
141
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
142
+ COPY_PHASE_STRIP = NO;
143
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
144
+ ENABLE_TESTABILITY = YES;
145
+ GCC_C_LANGUAGE_STANDARD = gnu99;
146
+ GCC_DYNAMIC_NO_PIC = NO;
147
+ GCC_NO_COMMON_BLOCKS = YES;
148
+ GCC_OPTIMIZATION_LEVEL = 0;
149
+ GCC_PREPROCESSOR_DEFINITIONS = (
150
+ "DEBUG=1",
151
+ "$(inherited)",
152
+ );
153
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
154
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
155
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
156
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
157
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
158
+ GCC_WARN_UNUSED_FUNCTION = YES;
159
+ GCC_WARN_UNUSED_VARIABLE = YES;
160
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
161
+ LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)";
162
+ LIBRARY_SEARCH_PATHS = (
163
+ "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
164
+ "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"",
165
+ "\"$(inherited)\"",
166
+ );
167
+ MTL_ENABLE_DEBUG_INFO = YES;
168
+ ONLY_ACTIVE_ARCH = YES;
169
+ SDKROOT = iphoneos;
170
+ };
171
+ name = Debug;
172
+ };
173
+ 58B511EE1A9E6C8500147676 /* Release */ = {
174
+ isa = XCBuildConfiguration;
175
+ buildSettings = {
176
+ ALWAYS_SEARCH_USER_PATHS = NO;
177
+ CLANG_ANALYZER_NONNULL = YES;
178
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
179
+ CLANG_CXX_LIBRARY = "libc++";
180
+ CLANG_ENABLE_MODULES = YES;
181
+ CLANG_ENABLE_OBJC_ARC = YES;
182
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
183
+ CLANG_WARN_BOOL_CONVERSION = YES;
184
+ CLANG_WARN_COMMA = YES;
185
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
186
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
187
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
188
+ CLANG_WARN_EMPTY_BODY = YES;
189
+ CLANG_WARN_ENUM_CONVERSION = YES;
190
+ CLANG_WARN_INFINITE_RECURSION = YES;
191
+ CLANG_WARN_INT_CONVERSION = YES;
192
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
193
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
194
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
195
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
196
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
197
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
198
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
199
+ CLANG_WARN_UNREACHABLE_CODE = YES;
200
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
201
+ COPY_PHASE_STRIP = YES;
202
+ ENABLE_NS_ASSERTIONS = NO;
203
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
204
+ GCC_C_LANGUAGE_STANDARD = gnu99;
205
+ GCC_NO_COMMON_BLOCKS = YES;
206
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
207
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
208
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
209
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
210
+ GCC_WARN_UNUSED_FUNCTION = YES;
211
+ GCC_WARN_UNUSED_VARIABLE = YES;
212
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
213
+ LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)";
214
+ LIBRARY_SEARCH_PATHS = (
215
+ "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
216
+ "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"",
217
+ "\"$(inherited)\"",
218
+ );
219
+ MTL_ENABLE_DEBUG_INFO = NO;
220
+ SDKROOT = iphoneos;
221
+ VALIDATE_PRODUCT = YES;
222
+ };
223
+ name = Release;
224
+ };
225
+ 58B511F01A9E6C8500147676 /* Debug */ = {
226
+ isa = XCBuildConfiguration;
227
+ buildSettings = {
228
+ HEADER_SEARCH_PATHS = (
229
+ "$(inherited)",
230
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
231
+ "$(SRCROOT)/../../../React/**",
232
+ "$(SRCROOT)/../../react-native/React/**",
233
+ );
234
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
235
+ OTHER_LDFLAGS = "-ObjC";
236
+ PRODUCT_NAME = DocumentScanner;
237
+ SKIP_INSTALL = YES;
238
+ };
239
+ name = Debug;
240
+ };
241
+ 58B511F11A9E6C8500147676 /* Release */ = {
242
+ isa = XCBuildConfiguration;
243
+ buildSettings = {
244
+ HEADER_SEARCH_PATHS = (
245
+ "$(inherited)",
246
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
247
+ "$(SRCROOT)/../../../React/**",
248
+ "$(SRCROOT)/../../react-native/React/**",
249
+ );
250
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
251
+ OTHER_LDFLAGS = "-ObjC";
252
+ PRODUCT_NAME = DocumentScanner;
253
+ SKIP_INSTALL = YES;
254
+ };
255
+ name = Release;
256
+ };
257
+ /* End XCBuildConfiguration section */
258
+
259
+ /* Begin XCConfigurationList section */
260
+ 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "DocumentScanner" */ = {
261
+ isa = XCConfigurationList;
262
+ buildConfigurations = (
263
+ 58B511ED1A9E6C8500147676 /* Debug */,
264
+ 58B511EE1A9E6C8500147676 /* Release */,
265
+ );
266
+ defaultConfigurationIsVisible = 0;
267
+ defaultConfigurationName = Release;
268
+ };
269
+ 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "DocumentScanner" */ = {
270
+ isa = XCConfigurationList;
271
+ buildConfigurations = (
272
+ 58B511F01A9E6C8500147676 /* Debug */,
273
+ 58B511F11A9E6C8500147676 /* Release */,
274
+ );
275
+ defaultConfigurationIsVisible = 0;
276
+ defaultConfigurationName = Release;
277
+ };
278
+ /* End XCConfigurationList section */
279
+ };
280
+ rootObject = 58B511D31A9E6C8500147676 /* Project object */;
281
+ }
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>DocumentScanner.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "group:DocumentScanner.xcodeproj">
6
+ </FileRef>
7
+ </Workspace>
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@dariyd/react-native-document-scanner",
3
+ "title": "React Native Document Scanner",
4
+ "version": "2.0.13",
5
+ "description": "React Native document scanner using VisionKit (iOS) and ML Kit (Android) with support for both old and new architecture",
6
+ "main": "index.js",
7
+ "types": "index.d.ts",
8
+ "files": [
9
+ "README.md",
10
+ "CHANGELOG.md",
11
+ "android",
12
+ "index.js",
13
+ "index.d.ts",
14
+ "src",
15
+ "ios",
16
+ "react-native-document-scanner.podspec",
17
+ "react-native.config.js",
18
+ "assets"
19
+ ],
20
+ "scripts": {
21
+ "test": "echo \"Error: no test specified\" && exit 1",
22
+ "prepare": "echo \"✅ Installing dependencies...\"",
23
+ "prepublishOnly": "echo \"📦 Preparing package for publishing...\" && npm pack --dry-run",
24
+ "postpublish": "echo \"🎉 Published successfully! Don't forget to: git push && git push --tags\""
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/dariyd/react-native-document-scanner.git",
29
+ "baseUrl": "https://github.com/dariyd/react-native-document-scanner"
30
+ },
31
+ "keywords": [
32
+ "react-native",
33
+ "document-scanner",
34
+ "visionkit",
35
+ "mlkit",
36
+ "ios",
37
+ "android",
38
+ "fabric",
39
+ "turbomodules"
40
+ ],
41
+ "author": {
42
+ "name": "Dariy",
43
+ "email": "dariy@example.com"
44
+ },
45
+ "homepage": "https://github.com/dariyd/react-native-document-scanner#readme",
46
+ "bugs": {
47
+ "url": "https://github.com/dariyd/react-native-document-scanner/issues"
48
+ },
49
+ "license": "MIT",
50
+ "licenseFilename": "LICENSE",
51
+ "readmeFilename": "README.md",
52
+ "peerDependencies": {
53
+ "react": ">=18.2.0",
54
+ "react-native": ">=0.77.3"
55
+ },
56
+ "devDependencies": {
57
+ "react": "^18.3.1",
58
+ "react-native": "^0.77.3"
59
+ },
60
+ "codegenConfig": {
61
+ "name": "RNDocumentScannerSpec",
62
+ "type": "modules",
63
+ "jsSrcsDir": "src",
64
+ "android": {
65
+ "javaPackageName": "com.docscanner"
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,45 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "react-native-document-scanner"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.description = <<-DESC
10
+ React Native document scanner using VisionKit (iOS) and ML Kit (Android) with support for both old and new architecture
11
+ DESC
12
+ s.homepage = "https://github.com/dariyd/react-native-document-scanner"
13
+ s.license = "MIT"
14
+ s.authors = { "Dariy" => "dariy@email.com" }
15
+ s.platforms = { :ios => "13.0" }
16
+ s.source = { :git => "https://github.com/dariyd/react-native-document-scanner.git", :tag => "#{s.version}" }
17
+
18
+ s.source_files = "ios/**/*.{h,c,cc,cpp,m,mm,swift}"
19
+ s.requires_arc = true
20
+ # Link VisionKit for VNDocumentCameraViewController
21
+ s.frameworks = ["VisionKit"]
22
+
23
+ # Use install_modules_dependencies helper for React Native 0.71+
24
+ if respond_to?(:install_modules_dependencies, true)
25
+ install_modules_dependencies(s)
26
+ else
27
+ s.dependency "React-Core"
28
+
29
+ # Don't install the dependencies when we run `pod install` in the old architecture.
30
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
31
+ s.compiler_flags = "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DRCT_NEW_ARCH_ENABLED=1"
32
+ s.pod_target_xcconfig = {
33
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
34
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
35
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
36
+ }
37
+ s.dependency "React-Codegen"
38
+ s.dependency "RCT-Folly"
39
+ s.dependency "RCTRequired"
40
+ s.dependency "RCTTypeSafety"
41
+ s.dependency "ReactCommon/turbomodule/core"
42
+ end
43
+ end
44
+ end
45
+
@@ -0,0 +1,15 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ android: {
5
+ // This is a Java-only TurboModule - no C++ codegen needed
6
+ // Setting cmakeListsPath to null tells autolinking to skip C++ setup
7
+ cmakeListsPath: null,
8
+ },
9
+ ios: {
10
+ // iOS uses Objective-C++ and needs codegen - use defaults
11
+ },
12
+ },
13
+ },
14
+ };
15
+
@@ -0,0 +1,31 @@
1
+ import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface ImageObject {
5
+ base64?: string;
6
+ uri: string;
7
+ width: number;
8
+ height: number;
9
+ fileSize: number;
10
+ type: string;
11
+ fileName: string;
12
+ }
13
+
14
+ export interface ScanResult {
15
+ didCancel?: boolean;
16
+ error?: boolean;
17
+ errorMessage?: string;
18
+ images?: ImageObject[];
19
+ }
20
+
21
+ export interface Options {
22
+ quality?: number;
23
+ includeBase64?: boolean;
24
+ }
25
+
26
+ export interface Spec extends TurboModule {
27
+ launchScanner(options: Options, callback: (result: ScanResult) => void): void;
28
+ }
29
+
30
+ export default TurboModuleRegistry.get<Spec>('DocumentScanner');
31
+