mediversal-rn-image-intelligence 1.0.6

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 (60) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +361 -0
  3. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  4. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  5. package/android/.gradle/8.9/executionHistory/executionHistory.lock +0 -0
  6. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  7. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  8. package/android/.gradle/8.9/gc.properties +0 -0
  9. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  10. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  11. package/android/.gradle/vcs-1/gc.properties +0 -0
  12. package/android/build.gradle +71 -0
  13. package/android/src/main/AndroidManifest.xml +10 -0
  14. package/android/src/main/java/com/mediversalrnimagintelligence/FaceDetectionModule.kt +147 -0
  15. package/android/src/main/java/com/mediversalrnimagintelligence/HandwritingRecognitionModule.kt +74 -0
  16. package/android/src/main/java/com/mediversalrnimagintelligence/ImageIntelligencePackage.kt +20 -0
  17. package/android/src/main/java/com/mediversalrnimagintelligence/TextRecognitionModule.kt +86 -0
  18. package/ios/FaceDetectionModule.m +16 -0
  19. package/ios/FaceDetectionModule.swift +164 -0
  20. package/ios/HandwritingRecognitionModule.m +14 -0
  21. package/ios/HandwritingRecognitionModule.swift +53 -0
  22. package/ios/TextRecognitionModule.m +14 -0
  23. package/ios/TextRecognitionModule.swift +102 -0
  24. package/lib/commonjs/NativeFaceDetectionModule.js +12 -0
  25. package/lib/commonjs/NativeFaceDetectionModule.js.map +1 -0
  26. package/lib/commonjs/NativeHandwritingRecognitionModule.js +12 -0
  27. package/lib/commonjs/NativeHandwritingRecognitionModule.js.map +1 -0
  28. package/lib/commonjs/NativeTextRecognitionModule.js +12 -0
  29. package/lib/commonjs/NativeTextRecognitionModule.js.map +1 -0
  30. package/lib/commonjs/index.js +194 -0
  31. package/lib/commonjs/index.js.map +1 -0
  32. package/lib/commonjs/types.js +2 -0
  33. package/lib/commonjs/types.js.map +1 -0
  34. package/lib/module/NativeFaceDetectionModule.js +8 -0
  35. package/lib/module/NativeFaceDetectionModule.js.map +1 -0
  36. package/lib/module/NativeHandwritingRecognitionModule.js +8 -0
  37. package/lib/module/NativeHandwritingRecognitionModule.js.map +1 -0
  38. package/lib/module/NativeTextRecognitionModule.js +8 -0
  39. package/lib/module/NativeTextRecognitionModule.js.map +1 -0
  40. package/lib/module/index.js +186 -0
  41. package/lib/module/index.js.map +1 -0
  42. package/lib/module/types.js +2 -0
  43. package/lib/module/types.js.map +1 -0
  44. package/lib/typescript/NativeFaceDetectionModule.d.ts +11 -0
  45. package/lib/typescript/NativeFaceDetectionModule.d.ts.map +1 -0
  46. package/lib/typescript/NativeHandwritingRecognitionModule.d.ts +11 -0
  47. package/lib/typescript/NativeHandwritingRecognitionModule.d.ts.map +1 -0
  48. package/lib/typescript/NativeTextRecognitionModule.d.ts +11 -0
  49. package/lib/typescript/NativeTextRecognitionModule.d.ts.map +1 -0
  50. package/lib/typescript/index.d.ts +44 -0
  51. package/lib/typescript/index.d.ts.map +1 -0
  52. package/lib/typescript/types.d.ts +91 -0
  53. package/lib/typescript/types.d.ts.map +1 -0
  54. package/mediversal-rn-image-intelligence.podspec +0 -0
  55. package/package.json +157 -0
  56. package/src/NativeFaceDetectionModule.ts +18 -0
  57. package/src/NativeHandwritingRecognitionModule.ts +16 -0
  58. package/src/NativeTextRecognitionModule.ts +14 -0
  59. package/src/index.tsx +243 -0
  60. package/src/types.ts +96 -0
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.analyzeImage = analyzeImage;
7
+ exports.default = void 0;
8
+ exports.isAvailable = isAvailable;
9
+ var _reactNative = require("react-native");
10
+ var _NativeFaceDetectionModule = _interopRequireDefault(require("./NativeFaceDetectionModule"));
11
+ var _NativeTextRecognitionModule = _interopRequireDefault(require("./NativeTextRecognitionModule"));
12
+ var _NativeHandwritingRecognitionModule = _interopRequireDefault(require("./NativeHandwritingRecognitionModule"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ // Export types for consumers
15
+
16
+ /**
17
+ * Default analysis options
18
+ */
19
+ const DEFAULT_OPTIONS = {
20
+ detectFaces: true,
21
+ detectPrintedText: true,
22
+ detectHandwrittenText: true,
23
+ faceDetectionMode: 'fast',
24
+ minFaceSize: 0.1
25
+ };
26
+
27
+ /**
28
+ * Validates and normalizes the image URI
29
+ * @param imageUri - The image URI to validate
30
+ * @returns Normalized URI
31
+ * @throws Error if URI is invalid
32
+ */
33
+ function validateImageUri(imageUri) {
34
+ if (!imageUri || typeof imageUri !== 'string') {
35
+ throw new Error('Invalid image URI: must be a non-empty string');
36
+ }
37
+ const trimmedUri = imageUri.trim();
38
+ if (trimmedUri.length === 0) {
39
+ throw new Error('Invalid image URI: must be a non-empty string');
40
+ }
41
+
42
+ // Validate URI format
43
+ if (_reactNative.Platform.OS === 'android') {
44
+ // Android accepts: file://, content://, or absolute paths
45
+ if (!trimmedUri.startsWith('file://') && !trimmedUri.startsWith('content://') && !trimmedUri.startsWith('/')) {
46
+ throw new Error('Invalid Android image URI: must start with file://, content://, or be an absolute path');
47
+ }
48
+ } else if (_reactNative.Platform.OS === 'ios') {
49
+ // iOS accepts: file://, ph://, assets-library://, or absolute paths
50
+ if (!trimmedUri.startsWith('file://') && !trimmedUri.startsWith('ph://') && !trimmedUri.startsWith('assets-library://') && !trimmedUri.startsWith('/')) {
51
+ throw new Error('Invalid iOS image URI: must start with file://, ph://, assets-library://, or be an absolute path');
52
+ }
53
+ }
54
+ return trimmedUri;
55
+ }
56
+
57
+ /**
58
+ * Analyzes an image using Google ML Kit on-device APIs
59
+ *
60
+ * This function performs parallel analysis using three ML Kit models:
61
+ * - Face Detection: Detects human faces and facial attributes
62
+ * - Text Recognition: Extracts printed text (OCR)
63
+ * - Digital Ink Recognition: Extracts handwritten text
64
+ *
65
+ * @param imageUri - Local file URI (e.g., "file:///path/to/image.jpg", "content://...", or absolute path)
66
+ * @param options - Configuration options for the analysis
67
+ * @returns Promise resolving to the analysis result
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const result = await analyzeImage('file:///path/to/image.jpg');
72
+ *
73
+ * if (result.containsFace) {
74
+ * console.log(`Found ${result.faces?.length} face(s)`);
75
+ * result.faces?.forEach(face => {
76
+ * console.log('Smiling:', face.smilingProbability);
77
+ * });
78
+ * }
79
+ *
80
+ * if (result.containsPrintedText) {
81
+ * console.log('Text:', result.printedText);
82
+ * }
83
+ * ```
84
+ *
85
+ * @throws Error if imageUri is invalid or if all analyses fail
86
+ */
87
+ async function analyzeImage(imageUri, options = {}) {
88
+ // Validate input
89
+ const validatedUri = validateImageUri(imageUri);
90
+
91
+ // Merge with default options
92
+ const opts = {
93
+ ...DEFAULT_OPTIONS,
94
+ ...options
95
+ };
96
+
97
+ // Initialize result
98
+ const result = {
99
+ containsFace: false,
100
+ containsPrintedText: false,
101
+ containsHandwrittenText: false
102
+ };
103
+
104
+ // Create promises array for parallel execution
105
+ const promises = [];
106
+
107
+ // Face Detection
108
+ if (opts.detectFaces) {
109
+ promises.push((async () => {
110
+ try {
111
+ const faceResult = await _NativeFaceDetectionModule.default.detectFaces(validatedUri, opts.faceDetectionMode, opts.minFaceSize);
112
+ if (faceResult.error) {
113
+ result.errors = result.errors || {};
114
+ result.errors.faceDetection = faceResult.error;
115
+ } else if (faceResult.faces && faceResult.faces.length > 0) {
116
+ result.containsFace = true;
117
+ result.faces = faceResult.faces;
118
+ }
119
+ } catch (error) {
120
+ result.errors = result.errors || {};
121
+ result.errors.faceDetection = error instanceof Error ? error.message : 'Unknown error';
122
+ }
123
+ })());
124
+ }
125
+
126
+ // Text Recognition (Printed)
127
+ if (opts.detectPrintedText) {
128
+ promises.push((async () => {
129
+ try {
130
+ const textResult = await _NativeTextRecognitionModule.default.recognizeText(validatedUri);
131
+ if (textResult.error) {
132
+ result.errors = result.errors || {};
133
+ result.errors.textRecognition = textResult.error;
134
+ } else if (textResult.text && textResult.text.trim().length > 0) {
135
+ result.containsPrintedText = true;
136
+ result.printedText = textResult.text;
137
+ }
138
+ } catch (error) {
139
+ result.errors = result.errors || {};
140
+ result.errors.textRecognition = error instanceof Error ? error.message : 'Unknown error';
141
+ }
142
+ })());
143
+ }
144
+
145
+ // Handwriting Recognition
146
+ if (opts.detectHandwrittenText) {
147
+ promises.push((async () => {
148
+ try {
149
+ const handwritingResult = await _NativeHandwritingRecognitionModule.default.recognizeHandwriting(validatedUri);
150
+ if (handwritingResult.error) {
151
+ result.errors = result.errors || {};
152
+ result.errors.handwritingRecognition = handwritingResult.error;
153
+ } else if (handwritingResult.text && handwritingResult.text.trim().length > 0) {
154
+ result.containsHandwrittenText = true;
155
+ result.handwrittenText = handwritingResult.text;
156
+ }
157
+ } catch (error) {
158
+ result.errors = result.errors || {};
159
+ result.errors.handwritingRecognition = error instanceof Error ? error.message : 'Unknown error';
160
+ }
161
+ })());
162
+ }
163
+
164
+ // Wait for all analyses to complete
165
+ await Promise.all(promises);
166
+
167
+ // If all enabled analyses failed, throw an error
168
+ const enabledCount = promises.length;
169
+ const errorCount = result.errors ? Object.keys(result.errors).length : 0;
170
+ if (enabledCount > 0 && errorCount === enabledCount) {
171
+ throw new Error(`All image analyses failed: ${JSON.stringify(result.errors)}`);
172
+ }
173
+ return result;
174
+ }
175
+
176
+ /**
177
+ * Check if the library is properly installed and native modules are available
178
+ * @returns Promise resolving to true if all modules are available
179
+ */
180
+ async function isAvailable() {
181
+ try {
182
+ // Simple check - all modules should be available
183
+ return !!(_NativeFaceDetectionModule.default && _NativeTextRecognitionModule.default && _NativeHandwritingRecognitionModule.default);
184
+ } catch {
185
+ return false;
186
+ }
187
+ }
188
+
189
+ // Default export for convenience
190
+ var _default = exports.default = {
191
+ analyzeImage,
192
+ isAvailable
193
+ };
194
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_NativeFaceDetectionModule","_interopRequireDefault","_NativeTextRecognitionModule","_NativeHandwritingRecognitionModule","e","__esModule","default","DEFAULT_OPTIONS","detectFaces","detectPrintedText","detectHandwrittenText","faceDetectionMode","minFaceSize","validateImageUri","imageUri","Error","trimmedUri","trim","length","Platform","OS","startsWith","analyzeImage","options","validatedUri","opts","result","containsFace","containsPrintedText","containsHandwrittenText","promises","push","faceResult","FaceDetectionModule","error","errors","faceDetection","faces","message","textResult","TextRecognitionModule","recognizeText","textRecognition","text","printedText","handwritingResult","HandwritingRecognitionModule","recognizeHandwriting","handwritingRecognition","handwrittenText","Promise","all","enabledCount","errorCount","Object","keys","JSON","stringify","isAvailable","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,4BAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,mCAAA,GAAAF,sBAAA,CAAAF,OAAA;AAAgF,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGhF;;AAQA;AACA;AACA;AACA,MAAMG,eAA0C,GAAG;EACjDC,WAAW,EAAE,IAAI;EACjBC,iBAAiB,EAAE,IAAI;EACvBC,qBAAqB,EAAE,IAAI;EAC3BC,iBAAiB,EAAE,MAAM;EACzBC,WAAW,EAAE;AACf,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAACC,QAAgB,EAAU;EAClD,IAAI,CAACA,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;IAC7C,MAAM,IAAIC,KAAK,CAAC,+CAA+C,CAAC;EAClE;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YnB,KAAK,GAAGmB,KAAK,CAACI,OAAO,GAAG,eAAe;MAC5D;IACF,CAAC,EAAE,CACL,CAAC;EACH;;EAEA;EACA,MAAMY,OAAO,CAACC,GAAG,CAACrB,QAAQ,CAAC;;EAE3B;EACA,MAAMsB,YAAY,GAAGtB,QAAQ,CAACZ,MAAM;EACpC,MAAMmC,UAAU,GAAG3B,MAAM,CAACS,MAAM,GAAGmB,MAAM,CAACC,IAAI,CAAC7B,MAAM,CAACS,MAAM,CAAC,CAACjB,MAAM,GAAG,CAAC;EAExE,IAAIkC,YAAY,GAAG,CAAC,IAAIC,UAAU,KAAKD,YAAY,EAAE;IACnD,MAAM,IAAIrC,KAAK,CACb,8BAA8ByC,IAAI,CAACC,SAAS,CAAC/B,MAAM,CAACS,MAAM,CAAC,EAC7D,CAAC;EACH;EAEA,OAAOT,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACO,eAAegC,WAAWA,CAAA,EAAqB;EACpD,IAAI;IACF;IACA,OAAO,CAAC,EACNzB,kCAAmB,IACnBO,oCAAqB,IACrBM,2CAA4B,CAC7B;EACH,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF;;AAEA;AAAA,IAAAa,QAAA,GAAAC,OAAA,CAAAtD,OAAA,GACe;EACbgB,YAAY;EACZoC;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import { TurboModuleRegistry } from 'react-native';
2
+
3
+ /**
4
+ * Face Detection TurboModule Specification
5
+ */
6
+
7
+ export default TurboModuleRegistry.getEnforcing('FaceDetectionModule');
8
+ //# sourceMappingURL=NativeFaceDetectionModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeFaceDetectionModule.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAGlD;AACA;AACA;;AASA,eAAeA,mBAAmB,CAACC,YAAY,CAC7C,qBACF,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import { TurboModuleRegistry } from 'react-native';
2
+
3
+ /**
4
+ * Handwriting Recognition TurboModule Specification
5
+ */
6
+
7
+ export default TurboModuleRegistry.getEnforcing('HandwritingRecognitionModule');
8
+ //# sourceMappingURL=NativeHandwritingRecognitionModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeHandwritingRecognitionModule.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAGlD;AACA;AACA;;AAOA,eAAeA,mBAAmB,CAACC,YAAY,CAC7C,8BACF,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import { TurboModuleRegistry } from 'react-native';
2
+
3
+ /**
4
+ * Text Recognition TurboModule Specification
5
+ */
6
+
7
+ export default TurboModuleRegistry.getEnforcing('TextRecognitionModule');
8
+ //# sourceMappingURL=NativeTextRecognitionModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeTextRecognitionModule.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAGlD;AACA;AACA;;AAKA,eAAeA,mBAAmB,CAACC,YAAY,CAC7C,uBACF,CAAC","ignoreList":[]}
@@ -0,0 +1,186 @@
1
+ import { Platform } from 'react-native';
2
+ import FaceDetectionModule from './NativeFaceDetectionModule';
3
+ import TextRecognitionModule from './NativeTextRecognitionModule';
4
+ import HandwritingRecognitionModule from './NativeHandwritingRecognitionModule';
5
+
6
+ // Export types for consumers
7
+
8
+ /**
9
+ * Default analysis options
10
+ */
11
+ const DEFAULT_OPTIONS = {
12
+ detectFaces: true,
13
+ detectPrintedText: true,
14
+ detectHandwrittenText: true,
15
+ faceDetectionMode: 'fast',
16
+ minFaceSize: 0.1
17
+ };
18
+
19
+ /**
20
+ * Validates and normalizes the image URI
21
+ * @param imageUri - The image URI to validate
22
+ * @returns Normalized URI
23
+ * @throws Error if URI is invalid
24
+ */
25
+ function validateImageUri(imageUri) {
26
+ if (!imageUri || typeof imageUri !== 'string') {
27
+ throw new Error('Invalid image URI: must be a non-empty string');
28
+ }
29
+ const trimmedUri = imageUri.trim();
30
+ if (trimmedUri.length === 0) {
31
+ throw new Error('Invalid image URI: must be a non-empty string');
32
+ }
33
+
34
+ // Validate URI format
35
+ if (Platform.OS === 'android') {
36
+ // Android accepts: file://, content://, or absolute paths
37
+ if (!trimmedUri.startsWith('file://') && !trimmedUri.startsWith('content://') && !trimmedUri.startsWith('/')) {
38
+ throw new Error('Invalid Android image URI: must start with file://, content://, or be an absolute path');
39
+ }
40
+ } else if (Platform.OS === 'ios') {
41
+ // iOS accepts: file://, ph://, assets-library://, or absolute paths
42
+ if (!trimmedUri.startsWith('file://') && !trimmedUri.startsWith('ph://') && !trimmedUri.startsWith('assets-library://') && !trimmedUri.startsWith('/')) {
43
+ throw new Error('Invalid iOS image URI: must start with file://, ph://, assets-library://, or be an absolute path');
44
+ }
45
+ }
46
+ return trimmedUri;
47
+ }
48
+
49
+ /**
50
+ * Analyzes an image using Google ML Kit on-device APIs
51
+ *
52
+ * This function performs parallel analysis using three ML Kit models:
53
+ * - Face Detection: Detects human faces and facial attributes
54
+ * - Text Recognition: Extracts printed text (OCR)
55
+ * - Digital Ink Recognition: Extracts handwritten text
56
+ *
57
+ * @param imageUri - Local file URI (e.g., "file:///path/to/image.jpg", "content://...", or absolute path)
58
+ * @param options - Configuration options for the analysis
59
+ * @returns Promise resolving to the analysis result
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const result = await analyzeImage('file:///path/to/image.jpg');
64
+ *
65
+ * if (result.containsFace) {
66
+ * console.log(`Found ${result.faces?.length} face(s)`);
67
+ * result.faces?.forEach(face => {
68
+ * console.log('Smiling:', face.smilingProbability);
69
+ * });
70
+ * }
71
+ *
72
+ * if (result.containsPrintedText) {
73
+ * console.log('Text:', result.printedText);
74
+ * }
75
+ * ```
76
+ *
77
+ * @throws Error if imageUri is invalid or if all analyses fail
78
+ */
79
+ export async function analyzeImage(imageUri, options = {}) {
80
+ // Validate input
81
+ const validatedUri = validateImageUri(imageUri);
82
+
83
+ // Merge with default options
84
+ const opts = {
85
+ ...DEFAULT_OPTIONS,
86
+ ...options
87
+ };
88
+
89
+ // Initialize result
90
+ const result = {
91
+ containsFace: false,
92
+ containsPrintedText: false,
93
+ containsHandwrittenText: false
94
+ };
95
+
96
+ // Create promises array for parallel execution
97
+ const promises = [];
98
+
99
+ // Face Detection
100
+ if (opts.detectFaces) {
101
+ promises.push((async () => {
102
+ try {
103
+ const faceResult = await FaceDetectionModule.detectFaces(validatedUri, opts.faceDetectionMode, opts.minFaceSize);
104
+ if (faceResult.error) {
105
+ result.errors = result.errors || {};
106
+ result.errors.faceDetection = faceResult.error;
107
+ } else if (faceResult.faces && faceResult.faces.length > 0) {
108
+ result.containsFace = true;
109
+ result.faces = faceResult.faces;
110
+ }
111
+ } catch (error) {
112
+ result.errors = result.errors || {};
113
+ result.errors.faceDetection = error instanceof Error ? error.message : 'Unknown error';
114
+ }
115
+ })());
116
+ }
117
+
118
+ // Text Recognition (Printed)
119
+ if (opts.detectPrintedText) {
120
+ promises.push((async () => {
121
+ try {
122
+ const textResult = await TextRecognitionModule.recognizeText(validatedUri);
123
+ if (textResult.error) {
124
+ result.errors = result.errors || {};
125
+ result.errors.textRecognition = textResult.error;
126
+ } else if (textResult.text && textResult.text.trim().length > 0) {
127
+ result.containsPrintedText = true;
128
+ result.printedText = textResult.text;
129
+ }
130
+ } catch (error) {
131
+ result.errors = result.errors || {};
132
+ result.errors.textRecognition = error instanceof Error ? error.message : 'Unknown error';
133
+ }
134
+ })());
135
+ }
136
+
137
+ // Handwriting Recognition
138
+ if (opts.detectHandwrittenText) {
139
+ promises.push((async () => {
140
+ try {
141
+ const handwritingResult = await HandwritingRecognitionModule.recognizeHandwriting(validatedUri);
142
+ if (handwritingResult.error) {
143
+ result.errors = result.errors || {};
144
+ result.errors.handwritingRecognition = handwritingResult.error;
145
+ } else if (handwritingResult.text && handwritingResult.text.trim().length > 0) {
146
+ result.containsHandwrittenText = true;
147
+ result.handwrittenText = handwritingResult.text;
148
+ }
149
+ } catch (error) {
150
+ result.errors = result.errors || {};
151
+ result.errors.handwritingRecognition = error instanceof Error ? error.message : 'Unknown error';
152
+ }
153
+ })());
154
+ }
155
+
156
+ // Wait for all analyses to complete
157
+ await Promise.all(promises);
158
+
159
+ // If all enabled analyses failed, throw an error
160
+ const enabledCount = promises.length;
161
+ const errorCount = result.errors ? Object.keys(result.errors).length : 0;
162
+ if (enabledCount > 0 && errorCount === enabledCount) {
163
+ throw new Error(`All image analyses failed: ${JSON.stringify(result.errors)}`);
164
+ }
165
+ return result;
166
+ }
167
+
168
+ /**
169
+ * Check if the library is properly installed and native modules are available
170
+ * @returns Promise resolving to true if all modules are available
171
+ */
172
+ export async function isAvailable() {
173
+ try {
174
+ // Simple check - all modules should be available
175
+ return !!(FaceDetectionModule && TextRecognitionModule && HandwritingRecognitionModule);
176
+ } catch {
177
+ return false;
178
+ }
179
+ }
180
+
181
+ // Default export for convenience
182
+ export default {
183
+ analyzeImage,
184
+ isAvailable
185
+ };
186
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","FaceDetectionModule","TextRecognitionModule","HandwritingRecognitionModule","DEFAULT_OPTIONS","detectFaces","detectPrintedText","detectHandwrittenText","faceDetectionMode","minFaceSize","validateImageUri","imageUri","Error","trimmedUri","trim","length","OS","startsWith","analyzeImage","options","validatedUri","opts","result","containsFace","containsPrintedText","containsHandwrittenText","promises","push","faceResult","error","errors","faceDetection","faces","message","textResult","recognizeText","textRecognition","text","printedText","handwritingResult","recognizeHandwriting","handwritingRecognition","handwrittenText","Promise","all","enabledCount","errorCount","Object","keys","JSON","stringify","isAvailable"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,mBAAmB,MAAM,6BAA6B;AAC7D,OAAOC,qBAAqB,MAAM,+BAA+B;AACjE,OAAOC,4BAA4B,MAAM,sCAAsC;;AAG/E;;AAQA;AACA;AACA;AACA,MAAMC,eAA0C,GAAG;EACjDC,WAAW,EAAE,IAAI;EACjBC,iBAAiB,EAAE,IAAI;EACvBC,qBAAqB,EAAE,IAAI;EAC3BC,iBAAiB,EAAE,MAAM;EACzBC,WAAW,EAAE;AACf,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAACC,QAAgB,EAAU;EAClD,IAAI,CAACA,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;IAC7C,MAAM,IAAIC,KAAK,CAAC,+CAA+C,CAAC;EAClE;EAEA,MAAMC,UAAU,GAAGF,QAAQ,CAACG,IAAI,CAAC,CAAC;EAElC,IAAID,UAAU,CAACE,MAAM,KAAK,CAAC,EAAE;IAC3B,MAAM,IAAIH,KAAK,CAAC,+CAA+C,CAAC;EAClE;;EAEA;EACA,IAAIZ,QAAQ,CAACgB,EAAE,KAAK,SAAS,EAAE;IAC7B;IACA,IACE,CAACH,UAAU,CAACI,UAAU,CAAC,SAAS,CAAC,IACjC,CAACJ,UAAU,CAACI,UAAU,CAAC,YAAY,CAAC,IACpC,CAACJ,UAAU,CAACI,UAAU,CAAC,GAAG,CAAC,EAC3B;MACA,MAAM,IAAIL,KAAK,CACb,wFACF,CAAC;IACH;EACF,CAAC,MAAM,IAAIZ,QAAQ,CAACgB,EAAE,KAAK,KAAK,EAAE;IAChC;IACA,IACE,CAACH,UAAU,CAACI,UAAU,CAAC,SAAS,CAAC,IACjC,CAACJ,UAAU,CAACI,UAAU,CAAC,OAAO,CAAC,IAC/B,CAACJ,UAAU,CAACI,UA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EACpD,IAAI;IACF;IACA,OAAO,CAAC,EACNlD,mBAAmB,IACnBC,qBAAqB,IACrBC,4BAA4B,CAC7B;EACH,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF;;AAEA;AACA,eAAe;EACbe,YAAY;EACZiC;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import type { NativeFaceDetectionResult } from './types';
3
+ /**
4
+ * Face Detection TurboModule Specification
5
+ */
6
+ export interface Spec extends TurboModule {
7
+ detectFaces(imageUri: string, mode: string, minFaceSize: number): Promise<NativeFaceDetectionResult>;
8
+ }
9
+ declare const _default: Spec;
10
+ export default _default;
11
+ //# sourceMappingURL=NativeFaceDetectionModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeFaceDetectionModule.d.ts","sourceRoot":"","sources":["../../src/NativeFaceDetectionModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,WAAW,CACT,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACvC;;AAED,wBAEU"}
@@ -0,0 +1,11 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import type { NativeHandwritingRecognitionResult } from './types';
3
+ /**
4
+ * Handwriting Recognition TurboModule Specification
5
+ */
6
+ export interface Spec extends TurboModule {
7
+ recognizeHandwriting(imageUri: string): Promise<NativeHandwritingRecognitionResult>;
8
+ }
9
+ declare const _default: Spec;
10
+ export default _default;
11
+ //# sourceMappingURL=NativeHandwritingRecognitionModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeHandwritingRecognitionModule.d.ts","sourceRoot":"","sources":["../../src/NativeHandwritingRecognitionModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,SAAS,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,oBAAoB,CAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,kCAAkC,CAAC,CAAC;CAChD;;AAED,wBAEU"}
@@ -0,0 +1,11 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import type { NativeTextRecognitionResult } from './types';
3
+ /**
4
+ * Text Recognition TurboModule Specification
5
+ */
6
+ export interface Spec extends TurboModule {
7
+ recognizeText(imageUri: string): Promise<NativeTextRecognitionResult>;
8
+ }
9
+ declare const _default: Spec;
10
+ export default _default;
11
+ //# sourceMappingURL=NativeTextRecognitionModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeTextRecognitionModule.d.ts","sourceRoot":"","sources":["../../src/NativeTextRecognitionModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;CACvE;;AAED,wBAEU"}
@@ -0,0 +1,44 @@
1
+ import type { AnalysisResult, AnalysisOptions } from './types';
2
+ export type { AnalysisResult, AnalysisOptions, FaceData, BoundingBox, } from './types';
3
+ /**
4
+ * Analyzes an image using Google ML Kit on-device APIs
5
+ *
6
+ * This function performs parallel analysis using three ML Kit models:
7
+ * - Face Detection: Detects human faces and facial attributes
8
+ * - Text Recognition: Extracts printed text (OCR)
9
+ * - Digital Ink Recognition: Extracts handwritten text
10
+ *
11
+ * @param imageUri - Local file URI (e.g., "file:///path/to/image.jpg", "content://...", or absolute path)
12
+ * @param options - Configuration options for the analysis
13
+ * @returns Promise resolving to the analysis result
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const result = await analyzeImage('file:///path/to/image.jpg');
18
+ *
19
+ * if (result.containsFace) {
20
+ * console.log(`Found ${result.faces?.length} face(s)`);
21
+ * result.faces?.forEach(face => {
22
+ * console.log('Smiling:', face.smilingProbability);
23
+ * });
24
+ * }
25
+ *
26
+ * if (result.containsPrintedText) {
27
+ * console.log('Text:', result.printedText);
28
+ * }
29
+ * ```
30
+ *
31
+ * @throws Error if imageUri is invalid or if all analyses fail
32
+ */
33
+ export declare function analyzeImage(imageUri: string, options?: AnalysisOptions): Promise<AnalysisResult>;
34
+ /**
35
+ * Check if the library is properly installed and native modules are available
36
+ * @returns Promise resolving to true if all modules are available
37
+ */
38
+ export declare function isAvailable(): Promise<boolean>;
39
+ declare const _default: {
40
+ analyzeImage: typeof analyzeImage;
41
+ isAvailable: typeof isAvailable;
42
+ };
43
+ export default _default;
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/D,YAAY,EACV,cAAc,EACd,eAAe,EACf,QAAQ,EACR,WAAW,GACZ,MAAM,SAAS,CAAC;AA2DjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,cAAc,CAAC,CAmHzB;AAED;;;GAGG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAWpD;;;;;AAGD,wBAGE"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Bounding box coordinates and dimensions
3
+ */
4
+ export interface BoundingBox {
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ }
10
+ /**
11
+ * Face detection result with metadata
12
+ */
13
+ export interface FaceData {
14
+ /** Bounding box of the detected face */
15
+ boundingBox: BoundingBox;
16
+ /** Probability that the face is smiling (0.0 to 1.0) */
17
+ smilingProbability?: number;
18
+ /** Probability that the left eye is open (0.0 to 1.0) */
19
+ leftEyeOpenProbability?: number;
20
+ /** Probability that the right eye is open (0.0 to 1.0) */
21
+ rightEyeOpenProbability?: number;
22
+ /** Head rotation around Y-axis (yaw) in degrees */
23
+ headEulerAngleY?: number;
24
+ /** Head rotation around Z-axis (roll) in degrees */
25
+ headEulerAngleZ?: number;
26
+ /** Tracking ID for video sequences */
27
+ trackingId?: number;
28
+ }
29
+ /**
30
+ * Complete analysis result from image intelligence
31
+ */
32
+ export interface AnalysisResult {
33
+ /** True if at least one human face was detected */
34
+ containsFace: boolean;
35
+ /** True if printed text was detected */
36
+ containsPrintedText: boolean;
37
+ /** True if handwritten text was detected */
38
+ containsHandwrittenText: boolean;
39
+ /** Array of detected faces with metadata */
40
+ faces?: FaceData[];
41
+ /** Extracted printed text content */
42
+ printedText?: string;
43
+ /** Extracted handwritten text content */
44
+ handwrittenText?: string;
45
+ /** Error messages if any module failed (won't throw, for graceful degradation) */
46
+ errors?: {
47
+ faceDetection?: string;
48
+ textRecognition?: string;
49
+ handwritingRecognition?: string;
50
+ };
51
+ }
52
+ /**
53
+ * Configuration options for image analysis
54
+ */
55
+ export interface AnalysisOptions {
56
+ /** Enable face detection (default: true) */
57
+ detectFaces?: boolean;
58
+ /** Enable printed text recognition (default: true) */
59
+ detectPrintedText?: boolean;
60
+ /** Enable handwritten text recognition (default: true) */
61
+ detectHandwrittenText?: boolean;
62
+ /** Face detection performance mode: 'fast' or 'accurate' (default: 'fast') */
63
+ faceDetectionMode?: 'fast' | 'accurate';
64
+ /** Minimum face size relative to image (0.0 to 1.0, default: 0.1) */
65
+ minFaceSize?: number;
66
+ }
67
+ /**
68
+ * Internal face detection result from native module
69
+ * @internal
70
+ */
71
+ export interface NativeFaceDetectionResult {
72
+ faces: FaceData[];
73
+ error?: string;
74
+ }
75
+ /**
76
+ * Internal text recognition result from native module
77
+ * @internal
78
+ */
79
+ export interface NativeTextRecognitionResult {
80
+ text: string;
81
+ error?: string;
82
+ }
83
+ /**
84
+ * Internal handwriting recognition result from native module
85
+ * @internal
86
+ */
87
+ export interface NativeHandwritingRecognitionResult {
88
+ text: string;
89
+ error?: string;
90
+ }
91
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,wCAAwC;IACxC,WAAW,EAAE,WAAW,CAAC;IACzB,wDAAwD;IACxD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yDAAyD;IACzD,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,0DAA0D;IAC1D,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,mDAAmD;IACnD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,YAAY,EAAE,OAAO,CAAC;IACtB,wCAAwC;IACxC,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