@sanctum-key/react-native-sdk 1.0.35 → 1.0.36
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.
- package/build/package.json +1 -1
- package/build/src/modules/camera/VisionCameraModule.d.ts +0 -34
- package/build/src/modules/camera/VisionCameraModule.d.ts.map +1 -1
- package/build/src/modules/camera/VisionCameraModule.js +20 -102
- package/build/src/modules/camera/VisionCameraModule.js.map +1 -1
- package/build/src/utils/pathToBase64.d.ts.map +1 -1
- package/build/src/utils/pathToBase64.js +3 -5
- package/build/src/utils/pathToBase64.js.map +1 -1
- package/package.json +1 -1
- package/src/modules/camera/VisionCameraModule.ts +18 -106
- package/src/utils/pathToBase64.ts +4 -8
package/build/package.json
CHANGED
|
@@ -11,50 +11,16 @@ export interface CameraPermissions {
|
|
|
11
11
|
export declare class VisionCameraModule {
|
|
12
12
|
private static instance;
|
|
13
13
|
static getInstance(): VisionCameraModule;
|
|
14
|
-
/**
|
|
15
|
-
* Get available camera devices
|
|
16
|
-
*/
|
|
17
14
|
getCameraDevices(): Promise<CameraDevice[]>;
|
|
18
|
-
/**
|
|
19
|
-
* Get the best available device for selfies (front camera)
|
|
20
|
-
*/
|
|
21
15
|
getFrontCameraDevice(): Promise<CameraDevice | null>;
|
|
22
|
-
/**
|
|
23
|
-
* Get the best available device for document capture (back camera)
|
|
24
|
-
*/
|
|
25
16
|
getBackCameraDevice(): Promise<CameraDevice | null>;
|
|
26
|
-
/**
|
|
27
|
-
* Request camera permissions
|
|
28
|
-
*/
|
|
29
17
|
requestCameraPermission(): Promise<boolean>;
|
|
30
|
-
/**
|
|
31
|
-
* Request microphone permissions
|
|
32
|
-
*/
|
|
33
18
|
requestMicrophonePermission(): Promise<boolean>;
|
|
34
|
-
/**
|
|
35
|
-
* Get current permission status
|
|
36
|
-
*/
|
|
37
19
|
getPermissionStatus(): Promise<CameraPermissions>;
|
|
38
|
-
/**
|
|
39
|
-
* Check if all required permissions are granted
|
|
40
|
-
*/
|
|
41
20
|
hasAllPermissions(): Promise<boolean>;
|
|
42
|
-
/**
|
|
43
|
-
* Request all required permissions
|
|
44
|
-
*/
|
|
45
21
|
requestAllPermissions(): Promise<boolean>;
|
|
46
|
-
/**
|
|
47
|
-
* Check if camera is available
|
|
48
|
-
*/
|
|
49
22
|
isCameraAvailable(): Promise<boolean>;
|
|
50
|
-
/**
|
|
51
|
-
* Process photo capture result
|
|
52
|
-
*/
|
|
53
23
|
processPhotoResult(photo: PhotoFile): Promise<CameraCaptureResult>;
|
|
54
|
-
/**
|
|
55
|
-
* Legacy method for backward compatibility
|
|
56
|
-
* @deprecated Use VisionCameraView component instead
|
|
57
|
-
*/
|
|
58
24
|
openCameraWithInstructions(instructions: string): Promise<CameraCaptureResult>;
|
|
59
25
|
}
|
|
60
26
|
declare const _default: VisionCameraModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisionCameraModule.d.ts","sourceRoot":"","sources":["../../../../src/modules/camera/VisionCameraModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,YAAY,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"VisionCameraModule.d.ts","sourceRoot":"","sources":["../../../../src/modules/camera/VisionCameraModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,YAAY,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AA0FrG,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,UAAU,EAAE,sBAAsB,CAAC;CACpC;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAqB;WAE9B,WAAW,IAAI,kBAAkB;IAOzC,gBAAgB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAS3C,oBAAoB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAUpD,mBAAmB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAUnD,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC;IAU3C,2BAA2B,IAAI,OAAO,CAAC,OAAO,CAAC;IAU/C,mBAAmB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAYjD,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAWrC,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC;IAazC,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAWrC,kBAAkB,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAoBlE,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAerF;;AAED,wBAAgD"}
|
|
@@ -2,52 +2,41 @@ import { Platform } from 'react-native';
|
|
|
2
2
|
import { Camera } from 'react-native-vision-camera';
|
|
3
3
|
/**
|
|
4
4
|
* Backward-compatible file copy function
|
|
5
|
-
* Tries new File API first (Expo SDK 54+), then legacy API, then regular import for SDK 53
|
|
6
5
|
*/
|
|
7
6
|
async function copyFileCompat(from, to) {
|
|
8
7
|
// Try new File API first (Expo SDK 54+)
|
|
9
8
|
try {
|
|
10
|
-
// @ts-ignore - File API might not be in types yet
|
|
11
9
|
const { File } = require('expo-file-system');
|
|
12
10
|
if (File && typeof File === 'function') {
|
|
13
11
|
const sourceFile = new File(from);
|
|
14
12
|
const destFile = new File(to);
|
|
15
|
-
// File.copy() is synchronous but may throw
|
|
16
13
|
sourceFile.copy(destFile);
|
|
17
14
|
return;
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
17
|
catch (error) {
|
|
21
18
|
// New API not available or failed, try legacy
|
|
22
|
-
// Continue to legacy API
|
|
23
19
|
}
|
|
24
20
|
// Try legacy API from expo-file-system/legacy (Expo SDK 54+)
|
|
25
|
-
// This is the recommended way to avoid deprecation warnings
|
|
26
21
|
try {
|
|
27
|
-
//
|
|
28
|
-
const LegacyFileSystem = require('expo-file-system');
|
|
22
|
+
// FIX: Appended /legacy to the require string
|
|
23
|
+
const LegacyFileSystem = require('expo-file-system/legacy');
|
|
29
24
|
if (LegacyFileSystem && LegacyFileSystem.copyAsync && typeof LegacyFileSystem.copyAsync === 'function') {
|
|
30
25
|
await LegacyFileSystem.copyAsync({ from, to });
|
|
31
26
|
return;
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
29
|
catch (error) {
|
|
35
|
-
// Legacy not available (SDK 53 or earlier), fall through to regular import
|
|
36
|
-
// Check if it's a "module not found" error (SDK 53) vs other error
|
|
37
30
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
38
31
|
if (errorMessage.includes('Cannot find module') || errorMessage.includes('Module not found')) {
|
|
39
|
-
// SDK 53
|
|
40
|
-
// This will show a deprecation warning on SDK 54+, but is necessary for SDK 53 compatibility
|
|
32
|
+
// SDK 53 fallback logic...
|
|
41
33
|
}
|
|
42
34
|
else {
|
|
43
|
-
// Other error, re-throw
|
|
44
35
|
throw new Error(`Unable to copy file: legacy FileSystem API error. Error: ${errorMessage}`);
|
|
45
36
|
}
|
|
46
37
|
}
|
|
47
38
|
// Fallback to regular import for SDK 53 and earlier
|
|
48
|
-
// Note: This will show a deprecation warning on SDK 54+, but is necessary for backward compatibility
|
|
49
39
|
try {
|
|
50
|
-
// @ts-ignore
|
|
51
40
|
const FileSystem = require('expo-file-system');
|
|
52
41
|
if (FileSystem && FileSystem.copyAsync && typeof FileSystem.copyAsync === 'function') {
|
|
53
42
|
await FileSystem.copyAsync({ from, to });
|
|
@@ -62,12 +51,9 @@ async function copyFileCompat(from, to) {
|
|
|
62
51
|
}
|
|
63
52
|
/**
|
|
64
53
|
* Get document directory path in a backward-compatible way
|
|
65
|
-
* Supports SDK 53 (regular import) and SDK 54+ (legacy or new API)
|
|
66
54
|
*/
|
|
67
55
|
function getDocumentDirectory() {
|
|
68
56
|
try {
|
|
69
|
-
// Try new Paths API first (Expo SDK 54+)
|
|
70
|
-
// @ts-ignore
|
|
71
57
|
const { Paths } = require('expo-file-system');
|
|
72
58
|
if (Paths?.document) {
|
|
73
59
|
return Paths.document.uri;
|
|
@@ -76,30 +62,20 @@ function getDocumentDirectory() {
|
|
|
76
62
|
catch (_) {
|
|
77
63
|
// New API not available, try legacy
|
|
78
64
|
}
|
|
79
|
-
// Try legacy API from expo-file-system/legacy (Expo SDK 54+)
|
|
80
|
-
// This is the recommended way to avoid deprecation warnings
|
|
81
65
|
try {
|
|
82
|
-
//
|
|
83
|
-
const LegacyFileSystem = require('expo-file-system');
|
|
66
|
+
// FIX: Appended /legacy to the require string
|
|
67
|
+
const LegacyFileSystem = require('expo-file-system/legacy');
|
|
84
68
|
if (LegacyFileSystem && LegacyFileSystem.documentDirectory) {
|
|
85
69
|
return LegacyFileSystem.documentDirectory;
|
|
86
70
|
}
|
|
87
71
|
}
|
|
88
72
|
catch (error) {
|
|
89
|
-
// Legacy not available (SDK 53 or earlier), fall through to regular import
|
|
90
73
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
91
74
|
if (errorMessage.includes('Cannot find module') || errorMessage.includes('Module not found')) {
|
|
92
|
-
// SDK 53
|
|
93
|
-
// This will show a deprecation warning on SDK 54+, but is necessary for SDK 53 compatibility
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
// Other error, continue to fallback
|
|
75
|
+
// SDK 53 fallback logic...
|
|
97
76
|
}
|
|
98
77
|
}
|
|
99
|
-
// Fallback to regular import for SDK 53 and earlier
|
|
100
|
-
// Note: This will show a deprecation warning on SDK 54+, but is necessary for backward compatibility
|
|
101
78
|
try {
|
|
102
|
-
// @ts-ignore
|
|
103
79
|
const FileSystem = require('expo-file-system');
|
|
104
80
|
if (FileSystem && FileSystem.documentDirectory) {
|
|
105
81
|
return FileSystem.documentDirectory;
|
|
@@ -119,50 +95,35 @@ export class VisionCameraModule {
|
|
|
119
95
|
}
|
|
120
96
|
return VisionCameraModule.instance;
|
|
121
97
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Get available camera devices
|
|
124
|
-
*/
|
|
125
98
|
async getCameraDevices() {
|
|
126
99
|
try {
|
|
127
|
-
|
|
128
|
-
return devices;
|
|
100
|
+
return Camera.getAvailableCameraDevices();
|
|
129
101
|
}
|
|
130
102
|
catch (error) {
|
|
131
103
|
console.error('Error getting camera devices:', error);
|
|
132
104
|
return [];
|
|
133
105
|
}
|
|
134
106
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Get the best available device for selfies (front camera)
|
|
137
|
-
*/
|
|
138
107
|
async getFrontCameraDevice() {
|
|
139
108
|
try {
|
|
140
109
|
const devices = await this.getCameraDevices();
|
|
141
|
-
|
|
142
|
-
return frontCamera || null;
|
|
110
|
+
return devices.find(device => device.position === 'front') || null;
|
|
143
111
|
}
|
|
144
112
|
catch (error) {
|
|
145
113
|
console.error('Error getting front camera:', error);
|
|
146
114
|
return null;
|
|
147
115
|
}
|
|
148
116
|
}
|
|
149
|
-
/**
|
|
150
|
-
* Get the best available device for document capture (back camera)
|
|
151
|
-
*/
|
|
152
117
|
async getBackCameraDevice() {
|
|
153
118
|
try {
|
|
154
119
|
const devices = await this.getCameraDevices();
|
|
155
|
-
|
|
156
|
-
return backCamera || null;
|
|
120
|
+
return devices.find(device => device.position === 'back') || null;
|
|
157
121
|
}
|
|
158
122
|
catch (error) {
|
|
159
123
|
console.error('Error getting back camera:', error);
|
|
160
124
|
return null;
|
|
161
125
|
}
|
|
162
126
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Request camera permissions
|
|
165
|
-
*/
|
|
166
127
|
async requestCameraPermission() {
|
|
167
128
|
try {
|
|
168
129
|
const permission = await Camera.requestCameraPermission();
|
|
@@ -173,9 +134,6 @@ export class VisionCameraModule {
|
|
|
173
134
|
return false;
|
|
174
135
|
}
|
|
175
136
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Request microphone permissions
|
|
178
|
-
*/
|
|
179
137
|
async requestMicrophonePermission() {
|
|
180
138
|
try {
|
|
181
139
|
const permission = await Camera.requestMicrophonePermission();
|
|
@@ -186,29 +144,18 @@ export class VisionCameraModule {
|
|
|
186
144
|
return false;
|
|
187
145
|
}
|
|
188
146
|
}
|
|
189
|
-
/**
|
|
190
|
-
* Get current permission status
|
|
191
|
-
*/
|
|
192
147
|
async getPermissionStatus() {
|
|
193
148
|
try {
|
|
194
|
-
const cameraStatus = await Camera.getCameraPermissionStatus();
|
|
195
|
-
const microphoneStatus = await Camera.getMicrophonePermissionStatus();
|
|
196
149
|
return {
|
|
197
|
-
camera:
|
|
198
|
-
microphone:
|
|
150
|
+
camera: await Camera.getCameraPermissionStatus(),
|
|
151
|
+
microphone: await Camera.getMicrophonePermissionStatus(),
|
|
199
152
|
};
|
|
200
153
|
}
|
|
201
154
|
catch (error) {
|
|
202
155
|
console.error('Error getting permission status:', error);
|
|
203
|
-
return {
|
|
204
|
-
camera: 'denied',
|
|
205
|
-
microphone: 'denied',
|
|
206
|
-
};
|
|
156
|
+
return { camera: 'denied', microphone: 'denied' };
|
|
207
157
|
}
|
|
208
158
|
}
|
|
209
|
-
/**
|
|
210
|
-
* Check if all required permissions are granted
|
|
211
|
-
*/
|
|
212
159
|
async hasAllPermissions() {
|
|
213
160
|
try {
|
|
214
161
|
const status = await this.getPermissionStatus();
|
|
@@ -220,9 +167,6 @@ export class VisionCameraModule {
|
|
|
220
167
|
return false;
|
|
221
168
|
}
|
|
222
169
|
}
|
|
223
|
-
/**
|
|
224
|
-
* Request all required permissions
|
|
225
|
-
*/
|
|
226
170
|
async requestAllPermissions() {
|
|
227
171
|
try {
|
|
228
172
|
const [cameraGranted, microphoneGranted] = await Promise.all([
|
|
@@ -236,14 +180,10 @@ export class VisionCameraModule {
|
|
|
236
180
|
return false;
|
|
237
181
|
}
|
|
238
182
|
}
|
|
239
|
-
/**
|
|
240
|
-
* Check if camera is available
|
|
241
|
-
*/
|
|
242
183
|
async isCameraAvailable() {
|
|
243
184
|
try {
|
|
244
|
-
if (Platform.OS === 'web')
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
185
|
+
if (Platform.OS === 'web')
|
|
186
|
+
return false;
|
|
247
187
|
const devices = await this.getCameraDevices();
|
|
248
188
|
return devices.length > 0;
|
|
249
189
|
}
|
|
@@ -252,9 +192,6 @@ export class VisionCameraModule {
|
|
|
252
192
|
return false;
|
|
253
193
|
}
|
|
254
194
|
}
|
|
255
|
-
/**
|
|
256
|
-
* Process photo capture result
|
|
257
|
-
*/
|
|
258
195
|
async processPhotoResult(photo) {
|
|
259
196
|
try {
|
|
260
197
|
const documentDir = getDocumentDirectory();
|
|
@@ -273,39 +210,20 @@ export class VisionCameraModule {
|
|
|
273
210
|
};
|
|
274
211
|
}
|
|
275
212
|
}
|
|
276
|
-
/**
|
|
277
|
-
* Legacy method for backward compatibility
|
|
278
|
-
* @deprecated Use VisionCameraView component instead
|
|
279
|
-
*/
|
|
280
213
|
async openCameraWithInstructions(instructions) {
|
|
281
214
|
console.warn('openCameraWithInstructions is deprecated. Use VisionCameraView component instead.');
|
|
282
215
|
try {
|
|
283
216
|
const hasPermissions = await this.requestAllPermissions();
|
|
284
|
-
if (!hasPermissions)
|
|
285
|
-
return {
|
|
286
|
-
success: false,
|
|
287
|
-
error: 'Camera permissions not granted',
|
|
288
|
-
};
|
|
289
|
-
}
|
|
217
|
+
if (!hasPermissions)
|
|
218
|
+
return { success: false, error: 'Camera permissions not granted' };
|
|
290
219
|
const isAvailable = await this.isCameraAvailable();
|
|
291
|
-
if (!isAvailable)
|
|
292
|
-
return {
|
|
293
|
-
|
|
294
|
-
error: 'Camera not available',
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
// Return a placeholder result since this should be handled by the component
|
|
298
|
-
return {
|
|
299
|
-
success: true,
|
|
300
|
-
path: `mock_photo_${Date.now()}.jpg`,
|
|
301
|
-
};
|
|
220
|
+
if (!isAvailable)
|
|
221
|
+
return { success: false, error: 'Camera not available' };
|
|
222
|
+
return { success: true, path: `mock_photo_${Date.now()}.jpg` };
|
|
302
223
|
}
|
|
303
224
|
catch (error) {
|
|
304
225
|
console.error('Error in openCameraWithInstructions:', error);
|
|
305
|
-
return {
|
|
306
|
-
success: false,
|
|
307
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
308
|
-
};
|
|
226
|
+
return { success: false, error: error instanceof Error ? error.message : 'Unknown error' };
|
|
309
227
|
}
|
|
310
228
|
}
|
|
311
229
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisionCameraModule.js","sourceRoot":"","sources":["../../../../src/modules/camera/VisionCameraModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,MAAM,EAAmD,MAAM,4BAA4B,CAAC;AAErG;;;GAGG;AACH,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,EAAU;IACpD,wCAAwC;IACxC,IAAI,CAAC;QACH,kDAAkD;QAClD,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAC7C,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;YACvC,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;YAC9B,2CAA2C;YAC3C,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1B,OAAO;QACT,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,8CAA8C;QAC9C,yBAAyB;IAC3B,CAAC;IAED,6DAA6D;IAC7D,4DAA4D;IAC5D,IAAI,CAAC;QACH,mDAAmD;QACnD,MAAM,gBAAgB,GAAG,OAAO,CAAC,kBAAkB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iBAAiB,EAAE,CAAC;YACnD,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,sBAAsB;iBAC9B,CAAC;YACJ,CAAC;YAED,4EAA4E;YAC5E,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,cAAc,IAAI,CAAC,GAAG,EAAE,MAAM;aACrC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC7D,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;aAChE,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,eAAe,kBAAkB,CAAC,WAAW,EAAE,CAAC","sourcesContent":["import { Platform } from 'react-native';\nimport { Camera, CameraDevice, CameraPermissionStatus, PhotoFile } from 'react-native-vision-camera';\n\n/**\n * Backward-compatible file copy function\n * Tries new File API first (Expo SDK 54+), then legacy API, then regular import for SDK 53\n */\nasync function copyFileCompat(from: string, to: string): Promise<void> {\n // Try new File API first (Expo SDK 54+)\n try {\n // @ts-ignore - File API might not be in types yet\n const { File } = require('expo-file-system');\n if (File && typeof File === 'function') {\n const sourceFile = new File(from);\n const destFile = new File(to);\n // File.copy() is synchronous but may throw\n sourceFile.copy(destFile);\n return;\n }\n } catch (error) {\n // New API not available or failed, try legacy\n // Continue to legacy API\n }\n\n // Try legacy API from expo-file-system/legacy (Expo SDK 54+)\n // This is the recommended way to avoid deprecation warnings\n try {\n // @ts-ignore - legacy export might not be in types\n const LegacyFileSystem = require('expo-file-system');\n if (LegacyFileSystem && LegacyFileSystem.copyAsync && typeof LegacyFileSystem.copyAsync === 'function') {\n await LegacyFileSystem.copyAsync({ from, to });\n return;\n }\n } catch (error) {\n // Legacy not available (SDK 53 or earlier), fall through to regular import\n // Check if it's a \"module not found\" error (SDK 53) vs other error\n const errorMessage = error instanceof Error ? error.message : String(error);\n if (errorMessage.includes('Cannot find module') || errorMessage.includes('Module not found')) {\n // SDK 53 or earlier - use regular import as fallback\n // This will show a deprecation warning on SDK 54+, but is necessary for SDK 53 compatibility\n } else {\n // Other error, re-throw\n throw new Error(`Unable to copy file: legacy FileSystem API error. Error: ${errorMessage}`);\n }\n }\n\n // Fallback to regular import for SDK 53 and earlier\n // Note: This will show a deprecation warning on SDK 54+, but is necessary for backward compatibility\n try {\n // @ts-ignore\n const FileSystem = require('expo-file-system');\n if (FileSystem && FileSystem.copyAsync && typeof FileSystem.copyAsync === 'function') {\n await FileSystem.copyAsync({ from, to });\n return;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Unable to copy file: all FileSystem APIs failed. Last error: ${errorMessage}`);\n }\n\n throw new Error('Unable to copy file: no compatible FileSystem API found');\n}\n\n/**\n * Get document directory path in a backward-compatible way\n * Supports SDK 53 (regular import) and SDK 54+ (legacy or new API)\n */\nfunction getDocumentDirectory(): string {\n try {\n // Try new Paths API first (Expo SDK 54+)\n // @ts-ignore\n const { Paths } = require('expo-file-system');\n if (Paths?.document) {\n return Paths.document.uri;\n }\n } catch (_) {\n // New API not available, try legacy\n }\n\n // Try legacy API from expo-file-system/legacy (Expo SDK 54+)\n // This is the recommended way to avoid deprecation warnings\n try {\n // @ts-ignore\n const LegacyFileSystem = require('expo-file-system');\n if (LegacyFileSystem && LegacyFileSystem.documentDirectory) {\n return LegacyFileSystem.documentDirectory;\n }\n } catch (error) {\n // Legacy not available (SDK 53 or earlier), fall through to regular import\n const errorMessage = error instanceof Error ? error.message : String(error);\n if (errorMessage.includes('Cannot find module') || errorMessage.includes('Module not found')) {\n // SDK 53 or earlier - use regular import as fallback\n // This will show a deprecation warning on SDK 54+, but is necessary for SDK 53 compatibility\n } else {\n // Other error, continue to fallback\n }\n }\n\n // Fallback to regular import for SDK 53 and earlier\n // Note: This will show a deprecation warning on SDK 54+, but is necessary for backward compatibility\n try {\n // @ts-ignore\n const FileSystem = require('expo-file-system');\n if (FileSystem && FileSystem.documentDirectory) {\n return FileSystem.documentDirectory;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Unable to get document directory: all FileSystem APIs failed. Last error: ${errorMessage}`);\n }\n\n throw new Error('Unable to get document directory: no compatible FileSystem API found');\n}\n\nexport interface CameraCaptureResult {\n success: boolean;\n path?: string;\n error?: string;\n}\n\nexport interface CameraPermissions {\n camera: CameraPermissionStatus;\n microphone: CameraPermissionStatus;\n}\n\nexport class VisionCameraModule {\n private static instance: VisionCameraModule;\n\n public static getInstance(): VisionCameraModule {\n if (!VisionCameraModule.instance) {\n VisionCameraModule.instance = new VisionCameraModule();\n }\n return VisionCameraModule.instance;\n }\n\n /**\n * Get available camera devices\n */\n async getCameraDevices(): Promise<CameraDevice[]> {\n try {\n const devices = Camera.getAvailableCameraDevices();\n return devices;\n } catch (error) {\n console.error('Error getting camera devices:', error);\n return [];\n }\n }\n\n /**\n * Get the best available device for selfies (front camera)\n */\n async getFrontCameraDevice(): Promise<CameraDevice | null> {\n try {\n const devices = await this.getCameraDevices();\n const frontCamera = devices.find(device => device.position === 'front');\n return frontCamera || null;\n } catch (error) {\n console.error('Error getting front camera:', error);\n return null;\n }\n }\n\n /**\n * Get the best available device for document capture (back camera)\n */\n async getBackCameraDevice(): Promise<CameraDevice | null> {\n try {\n const devices = await this.getCameraDevices();\n const backCamera = devices.find(device => device.position === 'back');\n return backCamera || null;\n } catch (error) {\n console.error('Error getting back camera:', error);\n return null;\n }\n }\n\n /**\n * Request camera permissions\n */\n async requestCameraPermission(): Promise<boolean> {\n try {\n const permission = await Camera.requestCameraPermission();\n return permission === 'granted';\n } catch (error) {\n console.error('Error requesting camera permission:', error);\n return false;\n }\n }\n\n /**\n * Request microphone permissions\n */\n async requestMicrophonePermission(): Promise<boolean> {\n try {\n const permission = await Camera.requestMicrophonePermission();\n return permission === 'granted';\n } catch (error) {\n console.error('Error requesting microphone permission:', error);\n return false;\n }\n }\n\n /**\n * Get current permission status\n */\n async getPermissionStatus(): Promise<CameraPermissions> {\n try {\n const cameraStatus = await Camera.getCameraPermissionStatus();\n const microphoneStatus = await Camera.getMicrophonePermissionStatus();\n\n return {\n camera: cameraStatus,\n microphone: microphoneStatus,\n };\n } catch (error) {\n console.error('Error getting permission status:', error);\n return {\n camera: 'denied',\n microphone: 'denied',\n };\n }\n }\n\n /**\n * Check if all required permissions are granted\n */\n async hasAllPermissions(): Promise<boolean> {\n try {\n const status = await this.getPermissionStatus();\n console.log('status', status);\n return status.camera === 'granted';\n } catch (error) {\n console.error('Error checking permissions:', error);\n return false;\n }\n }\n\n /**\n * Request all required permissions\n */\n async requestAllPermissions(): Promise<boolean> {\n try {\n const [cameraGranted, microphoneGranted] = await Promise.all([\n this.requestCameraPermission(),\n this.requestMicrophonePermission(),\n ]);\n\n return cameraGranted && microphoneGranted;\n } catch (error) {\n console.error('Error requesting permissions:', error);\n return false;\n }\n }\n\n /**\n * Check if camera is available\n */\n async isCameraAvailable(): Promise<boolean> {\n try {\n if (Platform.OS === 'web') {\n return false; // Vision Camera doesn't support web\n }\n\n const devices = await this.getCameraDevices();\n return devices.length > 0;\n } catch (error) {\n console.error('Error checking camera availability:', error);\n return false;\n }\n }\n\n /**\n * Process photo capture result\n */\n async processPhotoResult(photo: PhotoFile): Promise<CameraCaptureResult> {\n try {\n const documentDir = getDocumentDirectory();\n const newPath = documentDir + `photo_${Date.now()}.jpg`;\n\n await copyFileCompat(`file://${photo.path}`, newPath);\n\n return {\n success: true,\n path: newPath,\n };\n } catch (error) {\n console.error('Error processing photo result:', error);\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error processing photo',\n };\n }\n }\n\n /**\n * Legacy method for backward compatibility\n * @deprecated Use VisionCameraView component instead\n */\n async openCameraWithInstructions(instructions: string): Promise<CameraCaptureResult> {\n console.warn('openCameraWithInstructions is deprecated. Use VisionCameraView component instead.');\n\n try {\n const hasPermissions = await this.requestAllPermissions();\n if (!hasPermissions) {\n return {\n success: false,\n error: 'Camera permissions not granted',\n };\n }\n\n const isAvailable = await this.isCameraAvailable();\n if (!isAvailable) {\n return {\n success: false,\n error: 'Camera not available',\n };\n }\n\n // Return a placeholder result since this should be handled by the component\n return {\n success: true,\n path: `mock_photo_${Date.now()}.jpg`,\n };\n } catch (error) {\n console.error('Error in openCameraWithInstructions:', error);\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n }\n }\n}\n\nexport default VisionCameraModule.getInstance();"]}
|
|
1
|
+
{"version":3,"file":"VisionCameraModule.js","sourceRoot":"","sources":["../../../../src/modules/camera/VisionCameraModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,MAAM,EAAmD,MAAM,4BAA4B,CAAC;AAErG;;GAEG;AACH,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,EAAU;IACpD,wCAAwC;IACxC,IAAI,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAC7C,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;YACvC,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;YAC9B,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1B,OAAO;QACT,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,8CAA8C;IAChD,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC;QACH,8CAA8C;QAC9C,MAAM,gBAAgB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;QAC5D,IAAI,gBAAgB,IAAI,gBAAgB,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AE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACvD,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,gCAAgC;aACjF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,0BAA0B,CAAC,YAAoB;QACnD,OAAO,CAAC,IAAI,CAAC,mFAAmF,CAAC,CAAC;QAClG,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC1D,IAAI,CAAC,cAAc;gBAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,gCAAgC,EAAE,CAAC;YAExF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACnD,IAAI,CAAC,WAAW;gBAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;YAE3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC;QACjE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC7D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;QAC7F,CAAC;IACH,CAAC;CACF;AAED,eAAe,kBAAkB,CAAC,WAAW,EAAE,CAAC","sourcesContent":["import { Platform } from 'react-native';\nimport { Camera, CameraDevice, CameraPermissionStatus, PhotoFile } from 'react-native-vision-camera';\n\n/**\n * Backward-compatible file copy function\n */\nasync function copyFileCompat(from: string, to: string): Promise<void> {\n // Try new File API first (Expo SDK 54+)\n try {\n const { File } = require('expo-file-system');\n if (File && typeof File === 'function') {\n const sourceFile = new File(from);\n const destFile = new File(to);\n sourceFile.copy(destFile);\n return;\n }\n } catch (error) {\n // New API not available or failed, try legacy\n }\n\n // Try legacy API from expo-file-system/legacy (Expo SDK 54+)\n try {\n // FIX: Appended /legacy to the require string\n const LegacyFileSystem = require('expo-file-system/legacy');\n if (LegacyFileSystem && LegacyFileSystem.copyAsync && typeof LegacyFileSystem.copyAsync === 'function') {\n await LegacyFileSystem.copyAsync({ from, to });\n return;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n if (errorMessage.includes('Cannot find module') || errorMessage.includes('Module not found')) {\n // SDK 53 fallback logic...\n } else {\n throw new Error(`Unable to copy file: legacy FileSystem API error. Error: ${errorMessage}`);\n }\n }\n\n // Fallback to regular import for SDK 53 and earlier\n try {\n const FileSystem = require('expo-file-system');\n if (FileSystem && FileSystem.copyAsync && typeof FileSystem.copyAsync === 'function') {\n await FileSystem.copyAsync({ from, to });\n return;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Unable to copy file: all FileSystem APIs failed. Last error: ${errorMessage}`);\n }\n\n throw new Error('Unable to copy file: no compatible FileSystem API found');\n}\n\n/**\n * Get document directory path in a backward-compatible way\n */\nfunction getDocumentDirectory(): string {\n try {\n const { Paths } = require('expo-file-system');\n if (Paths?.document) {\n return Paths.document.uri;\n }\n } catch (_) {\n // New API not available, try legacy\n }\n\n try {\n // FIX: Appended /legacy to the require string\n const LegacyFileSystem = require('expo-file-system/legacy');\n if (LegacyFileSystem && LegacyFileSystem.documentDirectory) {\n return LegacyFileSystem.documentDirectory;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n if (errorMessage.includes('Cannot find module') || errorMessage.includes('Module not found')) {\n // SDK 53 fallback logic...\n }\n }\n\n try {\n const FileSystem = require('expo-file-system');\n if (FileSystem && FileSystem.documentDirectory) {\n return FileSystem.documentDirectory;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(`Unable to get document directory: all FileSystem APIs failed. Last error: ${errorMessage}`);\n }\n\n throw new Error('Unable to get document directory: no compatible FileSystem API found');\n}\n\nexport interface CameraCaptureResult {\n success: boolean;\n path?: string;\n error?: string;\n}\n\nexport interface CameraPermissions {\n camera: CameraPermissionStatus;\n microphone: CameraPermissionStatus;\n}\n\nexport class VisionCameraModule {\n private static instance: VisionCameraModule;\n\n public static getInstance(): VisionCameraModule {\n if (!VisionCameraModule.instance) {\n VisionCameraModule.instance = new VisionCameraModule();\n }\n return VisionCameraModule.instance;\n }\n\n async getCameraDevices(): Promise<CameraDevice[]> {\n try {\n return Camera.getAvailableCameraDevices();\n } catch (error) {\n console.error('Error getting camera devices:', error);\n return [];\n }\n }\n\n async getFrontCameraDevice(): Promise<CameraDevice | null> {\n try {\n const devices = await this.getCameraDevices();\n return devices.find(device => device.position === 'front') || null;\n } catch (error) {\n console.error('Error getting front camera:', error);\n return null;\n }\n }\n\n async getBackCameraDevice(): Promise<CameraDevice | null> {\n try {\n const devices = await this.getCameraDevices();\n return devices.find(device => device.position === 'back') || null;\n } catch (error) {\n console.error('Error getting back camera:', error);\n return null;\n }\n }\n\n async requestCameraPermission(): Promise<boolean> {\n try {\n const permission = await Camera.requestCameraPermission();\n return permission === 'granted';\n } catch (error) {\n console.error('Error requesting camera permission:', error);\n return false;\n }\n }\n\n async requestMicrophonePermission(): Promise<boolean> {\n try {\n const permission = await Camera.requestMicrophonePermission();\n return permission === 'granted';\n } catch (error) {\n console.error('Error requesting microphone permission:', error);\n return false;\n }\n }\n\n async getPermissionStatus(): Promise<CameraPermissions> {\n try {\n return {\n camera: await Camera.getCameraPermissionStatus(),\n microphone: await Camera.getMicrophonePermissionStatus(),\n };\n } catch (error) {\n console.error('Error getting permission status:', error);\n return { camera: 'denied', microphone: 'denied' };\n }\n }\n\n async hasAllPermissions(): Promise<boolean> {\n try {\n const status = await this.getPermissionStatus();\n console.log('status', status);\n return status.camera === 'granted';\n } catch (error) {\n console.error('Error checking permissions:', error);\n return false;\n }\n }\n\n async requestAllPermissions(): Promise<boolean> {\n try {\n const [cameraGranted, microphoneGranted] = await Promise.all([\n this.requestCameraPermission(),\n this.requestMicrophonePermission(),\n ]);\n return cameraGranted && microphoneGranted;\n } catch (error) {\n console.error('Error requesting permissions:', error);\n return false;\n }\n }\n\n async isCameraAvailable(): Promise<boolean> {\n try {\n if (Platform.OS === 'web') return false;\n const devices = await this.getCameraDevices();\n return devices.length > 0;\n } catch (error) {\n console.error('Error checking camera availability:', error);\n return false;\n }\n }\n\n async processPhotoResult(photo: PhotoFile): Promise<CameraCaptureResult> {\n try {\n const documentDir = getDocumentDirectory();\n const newPath = documentDir + `photo_${Date.now()}.jpg`;\n\n await copyFileCompat(`file://${photo.path}`, newPath);\n\n return {\n success: true,\n path: newPath,\n };\n } catch (error) {\n console.error('Error processing photo result:', error);\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error processing photo',\n };\n }\n }\n\n async openCameraWithInstructions(instructions: string): Promise<CameraCaptureResult> {\n console.warn('openCameraWithInstructions is deprecated. Use VisionCameraView component instead.');\n try {\n const hasPermissions = await this.requestAllPermissions();\n if (!hasPermissions) return { success: false, error: 'Camera permissions not granted' };\n \n const isAvailable = await this.isCameraAvailable();\n if (!isAvailable) return { success: false, error: 'Camera not available' };\n\n return { success: true, path: `mock_photo_${Date.now()}.jpg` };\n } catch (error) {\n console.error('Error in openCameraWithInstructions:', error);\n return { success: false, error: error instanceof Error ? error.message : 'Unknown error' };\n }\n }\n}\n\nexport default VisionCameraModule.getInstance();"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathToBase64.d.ts","sourceRoot":"","sources":["../../../src/utils/pathToBase64.ts"],"names":[],"mappings":"AAAA,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"pathToBase64.d.ts","sourceRoot":"","sources":["../../../src/utils/pathToBase64.ts"],"names":[],"mappings":"AAAA,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAwD/D;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -9,10 +9,9 @@ export async function pathToBase64(uri) {
|
|
|
9
9
|
// Try Expo FileSystem if available (React Native + Expo)
|
|
10
10
|
try {
|
|
11
11
|
// Try legacy API from expo-file-system/legacy first (Expo SDK 54+)
|
|
12
|
-
// This is the recommended way to avoid deprecation warnings
|
|
13
12
|
try {
|
|
14
|
-
//
|
|
15
|
-
const LegacyFileSystem = require('expo-file-system');
|
|
13
|
+
// FIX: Appended /legacy to the require string
|
|
14
|
+
const LegacyFileSystem = require('expo-file-system/legacy');
|
|
16
15
|
if (LegacyFileSystem?.readAsStringAsync) {
|
|
17
16
|
const base64 = await LegacyFileSystem.readAsStringAsync(uri, { encoding: LegacyFileSystem.EncodingType.Base64 });
|
|
18
17
|
if (base64)
|
|
@@ -32,13 +31,12 @@ export async function pathToBase64(uri) {
|
|
|
32
31
|
return base64;
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
|
-
// If it's a different error, continue to other strategies
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
catch (_) {
|
|
39
37
|
// All FileSystem APIs failed, fall back to other strategies (fetch + FileReader)
|
|
40
38
|
}
|
|
41
|
-
// Generic fetch + FileReader strategy
|
|
39
|
+
// Generic fetch + FileReader strategy
|
|
42
40
|
try {
|
|
43
41
|
const response = await fetch(uri);
|
|
44
42
|
const blob = await response.blob();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathToBase64.js","sourceRoot":"","sources":["../../../src/utils/pathToBase64.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAC5C,IAAI,CAAC,GAAG;QAAE,MAA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C;YAC/D,CAAC,CAAC;YACF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;YACxB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACxC,OAAO,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACzE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,0BAA0B;IAC5B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AACnE,CAAC;AAED,eAAe,YAAY,CAAC","sourcesContent":["export async function pathToBase64(uri: string): Promise<string> {\n if (!uri) throw new Error('pathToBase64: uri is required');\n\n // If already a data URI, return the base64 part\n if (uri.startsWith('data:')) {\n const commaIndex = uri.indexOf(',');\n return commaIndex !== -1 ? uri.substring(commaIndex + 1) : uri;\n }\n\n // Try Expo FileSystem if available (React Native + Expo)\n try {\n // Try legacy API from expo-file-system/legacy first (Expo SDK 54+)\n try {\n // FIX: Appended /legacy to the require string\n const LegacyFileSystem = require('expo-file-system/legacy');\n if (LegacyFileSystem?.readAsStringAsync) {\n const base64 = await LegacyFileSystem.readAsStringAsync(uri, { encoding: LegacyFileSystem.EncodingType.Base64 });\n if (base64) return base64;\n }\n } catch (legacyError) {\n // Legacy not available (SDK 53 or earlier), try regular import\n const errorMessage = legacyError instanceof Error ? legacyError.message : String(legacyError);\n if (errorMessage.includes('Cannot find module') || errorMessage.includes('Module not found')) {\n // SDK 53 or earlier - use regular import as fallback\n // @ts-ignore\n const FileSystem = require('expo-file-system');\n if (FileSystem?.readAsStringAsync) {\n const base64 = await FileSystem.readAsStringAsync(uri, { encoding: FileSystem.EncodingType.Base64 });\n if (base64) return base64;\n }\n }\n }\n } catch (_) {\n // All FileSystem APIs failed, fall back to other strategies (fetch + FileReader)\n }\n\n // Generic fetch + FileReader strategy\n try {\n const response = await fetch(uri);\n const blob = await response.blob();\n const dataUrl = await new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => {\n if (typeof reader.result === 'string') resolve(reader.result);\n else reject(new Error('Failed to convert blob to data URL'));\n };\n reader.onerror = reject;\n reader.readAsDataURL(blob);\n });\n const commaIndex = dataUrl.indexOf(',');\n return commaIndex !== -1 ? dataUrl.substring(commaIndex + 1) : dataUrl;\n } catch (err) {\n // continue to final error\n }\n\n throw new Error('pathToBase64: unable to convert uri to base64');\n}\n\nexport default pathToBase64;"]}
|
package/package.json
CHANGED
|
@@ -3,51 +3,40 @@ import { Camera, CameraDevice, CameraPermissionStatus, PhotoFile } from 'react-n
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Backward-compatible file copy function
|
|
6
|
-
* Tries new File API first (Expo SDK 54+), then legacy API, then regular import for SDK 53
|
|
7
6
|
*/
|
|
8
7
|
async function copyFileCompat(from: string, to: string): Promise<void> {
|
|
9
8
|
// Try new File API first (Expo SDK 54+)
|
|
10
9
|
try {
|
|
11
|
-
// @ts-ignore - File API might not be in types yet
|
|
12
10
|
const { File } = require('expo-file-system');
|
|
13
11
|
if (File && typeof File === 'function') {
|
|
14
12
|
const sourceFile = new File(from);
|
|
15
13
|
const destFile = new File(to);
|
|
16
|
-
// File.copy() is synchronous but may throw
|
|
17
14
|
sourceFile.copy(destFile);
|
|
18
15
|
return;
|
|
19
16
|
}
|
|
20
17
|
} catch (error) {
|
|
21
18
|
// New API not available or failed, try legacy
|
|
22
|
-
// Continue to legacy API
|
|
23
19
|
}
|
|
24
20
|
|
|
25
21
|
// Try legacy API from expo-file-system/legacy (Expo SDK 54+)
|
|
26
|
-
// This is the recommended way to avoid deprecation warnings
|
|
27
22
|
try {
|
|
28
|
-
//
|
|
29
|
-
const LegacyFileSystem = require('expo-file-system');
|
|
23
|
+
// FIX: Appended /legacy to the require string
|
|
24
|
+
const LegacyFileSystem = require('expo-file-system/legacy');
|
|
30
25
|
if (LegacyFileSystem && LegacyFileSystem.copyAsync && typeof LegacyFileSystem.copyAsync === 'function') {
|
|
31
26
|
await LegacyFileSystem.copyAsync({ from, to });
|
|
32
27
|
return;
|
|
33
28
|
}
|
|
34
29
|
} catch (error) {
|
|
35
|
-
// Legacy not available (SDK 53 or earlier), fall through to regular import
|
|
36
|
-
// Check if it's a "module not found" error (SDK 53) vs other error
|
|
37
30
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
38
31
|
if (errorMessage.includes('Cannot find module') || errorMessage.includes('Module not found')) {
|
|
39
|
-
// SDK 53
|
|
40
|
-
// This will show a deprecation warning on SDK 54+, but is necessary for SDK 53 compatibility
|
|
32
|
+
// SDK 53 fallback logic...
|
|
41
33
|
} else {
|
|
42
|
-
// Other error, re-throw
|
|
43
34
|
throw new Error(`Unable to copy file: legacy FileSystem API error. Error: ${errorMessage}`);
|
|
44
35
|
}
|
|
45
36
|
}
|
|
46
37
|
|
|
47
38
|
// Fallback to regular import for SDK 53 and earlier
|
|
48
|
-
// Note: This will show a deprecation warning on SDK 54+, but is necessary for backward compatibility
|
|
49
39
|
try {
|
|
50
|
-
// @ts-ignore
|
|
51
40
|
const FileSystem = require('expo-file-system');
|
|
52
41
|
if (FileSystem && FileSystem.copyAsync && typeof FileSystem.copyAsync === 'function') {
|
|
53
42
|
await FileSystem.copyAsync({ from, to });
|
|
@@ -63,12 +52,9 @@ async function copyFileCompat(from: string, to: string): Promise<void> {
|
|
|
63
52
|
|
|
64
53
|
/**
|
|
65
54
|
* Get document directory path in a backward-compatible way
|
|
66
|
-
* Supports SDK 53 (regular import) and SDK 54+ (legacy or new API)
|
|
67
55
|
*/
|
|
68
56
|
function getDocumentDirectory(): string {
|
|
69
57
|
try {
|
|
70
|
-
// Try new Paths API first (Expo SDK 54+)
|
|
71
|
-
// @ts-ignore
|
|
72
58
|
const { Paths } = require('expo-file-system');
|
|
73
59
|
if (Paths?.document) {
|
|
74
60
|
return Paths.document.uri;
|
|
@@ -77,29 +63,20 @@ function getDocumentDirectory(): string {
|
|
|
77
63
|
// New API not available, try legacy
|
|
78
64
|
}
|
|
79
65
|
|
|
80
|
-
// Try legacy API from expo-file-system/legacy (Expo SDK 54+)
|
|
81
|
-
// This is the recommended way to avoid deprecation warnings
|
|
82
66
|
try {
|
|
83
|
-
//
|
|
84
|
-
const LegacyFileSystem = require('expo-file-system');
|
|
67
|
+
// FIX: Appended /legacy to the require string
|
|
68
|
+
const LegacyFileSystem = require('expo-file-system/legacy');
|
|
85
69
|
if (LegacyFileSystem && LegacyFileSystem.documentDirectory) {
|
|
86
70
|
return LegacyFileSystem.documentDirectory;
|
|
87
71
|
}
|
|
88
72
|
} catch (error) {
|
|
89
|
-
// Legacy not available (SDK 53 or earlier), fall through to regular import
|
|
90
73
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
91
74
|
if (errorMessage.includes('Cannot find module') || errorMessage.includes('Module not found')) {
|
|
92
|
-
// SDK 53
|
|
93
|
-
// This will show a deprecation warning on SDK 54+, but is necessary for SDK 53 compatibility
|
|
94
|
-
} else {
|
|
95
|
-
// Other error, continue to fallback
|
|
75
|
+
// SDK 53 fallback logic...
|
|
96
76
|
}
|
|
97
77
|
}
|
|
98
78
|
|
|
99
|
-
// Fallback to regular import for SDK 53 and earlier
|
|
100
|
-
// Note: This will show a deprecation warning on SDK 54+, but is necessary for backward compatibility
|
|
101
79
|
try {
|
|
102
|
-
// @ts-ignore
|
|
103
80
|
const FileSystem = require('expo-file-system');
|
|
104
81
|
if (FileSystem && FileSystem.documentDirectory) {
|
|
105
82
|
return FileSystem.documentDirectory;
|
|
@@ -133,50 +110,35 @@ export class VisionCameraModule {
|
|
|
133
110
|
return VisionCameraModule.instance;
|
|
134
111
|
}
|
|
135
112
|
|
|
136
|
-
/**
|
|
137
|
-
* Get available camera devices
|
|
138
|
-
*/
|
|
139
113
|
async getCameraDevices(): Promise<CameraDevice[]> {
|
|
140
114
|
try {
|
|
141
|
-
|
|
142
|
-
return devices;
|
|
115
|
+
return Camera.getAvailableCameraDevices();
|
|
143
116
|
} catch (error) {
|
|
144
117
|
console.error('Error getting camera devices:', error);
|
|
145
118
|
return [];
|
|
146
119
|
}
|
|
147
120
|
}
|
|
148
121
|
|
|
149
|
-
/**
|
|
150
|
-
* Get the best available device for selfies (front camera)
|
|
151
|
-
*/
|
|
152
122
|
async getFrontCameraDevice(): Promise<CameraDevice | null> {
|
|
153
123
|
try {
|
|
154
124
|
const devices = await this.getCameraDevices();
|
|
155
|
-
|
|
156
|
-
return frontCamera || null;
|
|
125
|
+
return devices.find(device => device.position === 'front') || null;
|
|
157
126
|
} catch (error) {
|
|
158
127
|
console.error('Error getting front camera:', error);
|
|
159
128
|
return null;
|
|
160
129
|
}
|
|
161
130
|
}
|
|
162
131
|
|
|
163
|
-
/**
|
|
164
|
-
* Get the best available device for document capture (back camera)
|
|
165
|
-
*/
|
|
166
132
|
async getBackCameraDevice(): Promise<CameraDevice | null> {
|
|
167
133
|
try {
|
|
168
134
|
const devices = await this.getCameraDevices();
|
|
169
|
-
|
|
170
|
-
return backCamera || null;
|
|
135
|
+
return devices.find(device => device.position === 'back') || null;
|
|
171
136
|
} catch (error) {
|
|
172
137
|
console.error('Error getting back camera:', error);
|
|
173
138
|
return null;
|
|
174
139
|
}
|
|
175
140
|
}
|
|
176
141
|
|
|
177
|
-
/**
|
|
178
|
-
* Request camera permissions
|
|
179
|
-
*/
|
|
180
142
|
async requestCameraPermission(): Promise<boolean> {
|
|
181
143
|
try {
|
|
182
144
|
const permission = await Camera.requestCameraPermission();
|
|
@@ -187,9 +149,6 @@ export class VisionCameraModule {
|
|
|
187
149
|
}
|
|
188
150
|
}
|
|
189
151
|
|
|
190
|
-
/**
|
|
191
|
-
* Request microphone permissions
|
|
192
|
-
*/
|
|
193
152
|
async requestMicrophonePermission(): Promise<boolean> {
|
|
194
153
|
try {
|
|
195
154
|
const permission = await Camera.requestMicrophonePermission();
|
|
@@ -200,30 +159,18 @@ export class VisionCameraModule {
|
|
|
200
159
|
}
|
|
201
160
|
}
|
|
202
161
|
|
|
203
|
-
/**
|
|
204
|
-
* Get current permission status
|
|
205
|
-
*/
|
|
206
162
|
async getPermissionStatus(): Promise<CameraPermissions> {
|
|
207
163
|
try {
|
|
208
|
-
const cameraStatus = await Camera.getCameraPermissionStatus();
|
|
209
|
-
const microphoneStatus = await Camera.getMicrophonePermissionStatus();
|
|
210
|
-
|
|
211
164
|
return {
|
|
212
|
-
camera:
|
|
213
|
-
microphone:
|
|
165
|
+
camera: await Camera.getCameraPermissionStatus(),
|
|
166
|
+
microphone: await Camera.getMicrophonePermissionStatus(),
|
|
214
167
|
};
|
|
215
168
|
} catch (error) {
|
|
216
169
|
console.error('Error getting permission status:', error);
|
|
217
|
-
return {
|
|
218
|
-
camera: 'denied',
|
|
219
|
-
microphone: 'denied',
|
|
220
|
-
};
|
|
170
|
+
return { camera: 'denied', microphone: 'denied' };
|
|
221
171
|
}
|
|
222
172
|
}
|
|
223
173
|
|
|
224
|
-
/**
|
|
225
|
-
* Check if all required permissions are granted
|
|
226
|
-
*/
|
|
227
174
|
async hasAllPermissions(): Promise<boolean> {
|
|
228
175
|
try {
|
|
229
176
|
const status = await this.getPermissionStatus();
|
|
@@ -235,16 +182,12 @@ export class VisionCameraModule {
|
|
|
235
182
|
}
|
|
236
183
|
}
|
|
237
184
|
|
|
238
|
-
/**
|
|
239
|
-
* Request all required permissions
|
|
240
|
-
*/
|
|
241
185
|
async requestAllPermissions(): Promise<boolean> {
|
|
242
186
|
try {
|
|
243
187
|
const [cameraGranted, microphoneGranted] = await Promise.all([
|
|
244
188
|
this.requestCameraPermission(),
|
|
245
189
|
this.requestMicrophonePermission(),
|
|
246
190
|
]);
|
|
247
|
-
|
|
248
191
|
return cameraGranted && microphoneGranted;
|
|
249
192
|
} catch (error) {
|
|
250
193
|
console.error('Error requesting permissions:', error);
|
|
@@ -252,15 +195,9 @@ export class VisionCameraModule {
|
|
|
252
195
|
}
|
|
253
196
|
}
|
|
254
197
|
|
|
255
|
-
/**
|
|
256
|
-
* Check if camera is available
|
|
257
|
-
*/
|
|
258
198
|
async isCameraAvailable(): Promise<boolean> {
|
|
259
199
|
try {
|
|
260
|
-
if (Platform.OS === 'web')
|
|
261
|
-
return false; // Vision Camera doesn't support web
|
|
262
|
-
}
|
|
263
|
-
|
|
200
|
+
if (Platform.OS === 'web') return false;
|
|
264
201
|
const devices = await this.getCameraDevices();
|
|
265
202
|
return devices.length > 0;
|
|
266
203
|
} catch (error) {
|
|
@@ -269,9 +206,6 @@ export class VisionCameraModule {
|
|
|
269
206
|
}
|
|
270
207
|
}
|
|
271
208
|
|
|
272
|
-
/**
|
|
273
|
-
* Process photo capture result
|
|
274
|
-
*/
|
|
275
209
|
async processPhotoResult(photo: PhotoFile): Promise<CameraCaptureResult> {
|
|
276
210
|
try {
|
|
277
211
|
const documentDir = getDocumentDirectory();
|
|
@@ -292,41 +226,19 @@ export class VisionCameraModule {
|
|
|
292
226
|
}
|
|
293
227
|
}
|
|
294
228
|
|
|
295
|
-
/**
|
|
296
|
-
* Legacy method for backward compatibility
|
|
297
|
-
* @deprecated Use VisionCameraView component instead
|
|
298
|
-
*/
|
|
299
229
|
async openCameraWithInstructions(instructions: string): Promise<CameraCaptureResult> {
|
|
300
230
|
console.warn('openCameraWithInstructions is deprecated. Use VisionCameraView component instead.');
|
|
301
|
-
|
|
302
231
|
try {
|
|
303
232
|
const hasPermissions = await this.requestAllPermissions();
|
|
304
|
-
if (!hasPermissions) {
|
|
305
|
-
|
|
306
|
-
success: false,
|
|
307
|
-
error: 'Camera permissions not granted',
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
|
|
233
|
+
if (!hasPermissions) return { success: false, error: 'Camera permissions not granted' };
|
|
234
|
+
|
|
311
235
|
const isAvailable = await this.isCameraAvailable();
|
|
312
|
-
if (!isAvailable) {
|
|
313
|
-
return {
|
|
314
|
-
success: false,
|
|
315
|
-
error: 'Camera not available',
|
|
316
|
-
};
|
|
317
|
-
}
|
|
236
|
+
if (!isAvailable) return { success: false, error: 'Camera not available' };
|
|
318
237
|
|
|
319
|
-
|
|
320
|
-
return {
|
|
321
|
-
success: true,
|
|
322
|
-
path: `mock_photo_${Date.now()}.jpg`,
|
|
323
|
-
};
|
|
238
|
+
return { success: true, path: `mock_photo_${Date.now()}.jpg` };
|
|
324
239
|
} catch (error) {
|
|
325
240
|
console.error('Error in openCameraWithInstructions:', error);
|
|
326
|
-
return {
|
|
327
|
-
success: false,
|
|
328
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
329
|
-
};
|
|
241
|
+
return { success: false, error: error instanceof Error ? error.message : 'Unknown error' };
|
|
330
242
|
}
|
|
331
243
|
}
|
|
332
244
|
}
|
|
@@ -10,10 +10,9 @@ export async function pathToBase64(uri: string): Promise<string> {
|
|
|
10
10
|
// Try Expo FileSystem if available (React Native + Expo)
|
|
11
11
|
try {
|
|
12
12
|
// Try legacy API from expo-file-system/legacy first (Expo SDK 54+)
|
|
13
|
-
// This is the recommended way to avoid deprecation warnings
|
|
14
13
|
try {
|
|
15
|
-
//
|
|
16
|
-
const LegacyFileSystem = require('expo-file-system');
|
|
14
|
+
// FIX: Appended /legacy to the require string
|
|
15
|
+
const LegacyFileSystem = require('expo-file-system/legacy');
|
|
17
16
|
if (LegacyFileSystem?.readAsStringAsync) {
|
|
18
17
|
const base64 = await LegacyFileSystem.readAsStringAsync(uri, { encoding: LegacyFileSystem.EncodingType.Base64 });
|
|
19
18
|
if (base64) return base64;
|
|
@@ -30,13 +29,12 @@ export async function pathToBase64(uri: string): Promise<string> {
|
|
|
30
29
|
if (base64) return base64;
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
|
-
// If it's a different error, continue to other strategies
|
|
34
32
|
}
|
|
35
33
|
} catch (_) {
|
|
36
34
|
// All FileSystem APIs failed, fall back to other strategies (fetch + FileReader)
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
// Generic fetch + FileReader strategy
|
|
37
|
+
// Generic fetch + FileReader strategy
|
|
40
38
|
try {
|
|
41
39
|
const response = await fetch(uri);
|
|
42
40
|
const blob = await response.blob();
|
|
@@ -58,6 +56,4 @@ export async function pathToBase64(uri: string): Promise<string> {
|
|
|
58
56
|
throw new Error('pathToBase64: unable to convert uri to base64');
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
export default pathToBase64;
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
export default pathToBase64;
|