@arfuhad/react-native-smart-camera 0.1.0

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 (95) hide show
  1. package/ARCHITECTURE.md +341 -0
  2. package/README.md +154 -0
  3. package/android/build.gradle +89 -0
  4. package/android/src/main/AndroidManifest.xml +2 -0
  5. package/android/src/main/java/expo/modules/smartcamera/ImageLoader.kt +106 -0
  6. package/android/src/main/java/expo/modules/smartcamera/MLKitFaceDetector.kt +273 -0
  7. package/android/src/main/java/expo/modules/smartcamera/SmartCameraModule.kt +205 -0
  8. package/android/src/main/java/expo/modules/smartcamera/SmartCameraView.kt +153 -0
  9. package/android/src/main/java/expo/modules/smartcamera/WebRTCFrameBridge.kt +184 -0
  10. package/app.plugin.js +17 -0
  11. package/build/SmartCamera.d.ts +17 -0
  12. package/build/SmartCamera.d.ts.map +1 -0
  13. package/build/SmartCamera.js +270 -0
  14. package/build/SmartCamera.js.map +1 -0
  15. package/build/SmartCameraModule.d.ts +112 -0
  16. package/build/SmartCameraModule.d.ts.map +1 -0
  17. package/build/SmartCameraModule.js +121 -0
  18. package/build/SmartCameraModule.js.map +1 -0
  19. package/build/SmartCameraView.d.ts +8 -0
  20. package/build/SmartCameraView.d.ts.map +1 -0
  21. package/build/SmartCameraView.js +7 -0
  22. package/build/SmartCameraView.js.map +1 -0
  23. package/build/detection/blinkProcessor.d.ts +23 -0
  24. package/build/detection/blinkProcessor.d.ts.map +1 -0
  25. package/build/detection/blinkProcessor.js +90 -0
  26. package/build/detection/blinkProcessor.js.map +1 -0
  27. package/build/detection/faceDetector.d.ts +16 -0
  28. package/build/detection/faceDetector.d.ts.map +1 -0
  29. package/build/detection/faceDetector.js +46 -0
  30. package/build/detection/faceDetector.js.map +1 -0
  31. package/build/detection/index.d.ts +4 -0
  32. package/build/detection/index.d.ts.map +1 -0
  33. package/build/detection/index.js +4 -0
  34. package/build/detection/index.js.map +1 -0
  35. package/build/detection/staticImageDetector.d.ts +25 -0
  36. package/build/detection/staticImageDetector.d.ts.map +1 -0
  37. package/build/detection/staticImageDetector.js +48 -0
  38. package/build/detection/staticImageDetector.js.map +1 -0
  39. package/build/hooks/index.d.ts +5 -0
  40. package/build/hooks/index.d.ts.map +1 -0
  41. package/build/hooks/index.js +5 -0
  42. package/build/hooks/index.js.map +1 -0
  43. package/build/hooks/useBlinkDetection.d.ts +39 -0
  44. package/build/hooks/useBlinkDetection.d.ts.map +1 -0
  45. package/build/hooks/useBlinkDetection.js +67 -0
  46. package/build/hooks/useBlinkDetection.js.map +1 -0
  47. package/build/hooks/useFaceDetection.d.ts +46 -0
  48. package/build/hooks/useFaceDetection.d.ts.map +1 -0
  49. package/build/hooks/useFaceDetection.js +80 -0
  50. package/build/hooks/useFaceDetection.js.map +1 -0
  51. package/build/hooks/useSmartCamera.d.ts +31 -0
  52. package/build/hooks/useSmartCamera.d.ts.map +1 -0
  53. package/build/hooks/useSmartCamera.js +75 -0
  54. package/build/hooks/useSmartCamera.js.map +1 -0
  55. package/build/hooks/useSmartCameraWebRTC.d.ts +58 -0
  56. package/build/hooks/useSmartCameraWebRTC.d.ts.map +1 -0
  57. package/build/hooks/useSmartCameraWebRTC.js +160 -0
  58. package/build/hooks/useSmartCameraWebRTC.js.map +1 -0
  59. package/build/index.d.ts +14 -0
  60. package/build/index.d.ts.map +1 -0
  61. package/build/index.js +20 -0
  62. package/build/index.js.map +1 -0
  63. package/build/types.d.ts +478 -0
  64. package/build/types.d.ts.map +1 -0
  65. package/build/types.js +2 -0
  66. package/build/types.js.map +1 -0
  67. package/build/utils/index.d.ts +98 -0
  68. package/build/utils/index.d.ts.map +1 -0
  69. package/build/utils/index.js +276 -0
  70. package/build/utils/index.js.map +1 -0
  71. package/build/webrtc/WebRTCBridge.d.ts +55 -0
  72. package/build/webrtc/WebRTCBridge.d.ts.map +1 -0
  73. package/build/webrtc/WebRTCBridge.js +113 -0
  74. package/build/webrtc/WebRTCBridge.js.map +1 -0
  75. package/build/webrtc/index.d.ts +3 -0
  76. package/build/webrtc/index.d.ts.map +1 -0
  77. package/build/webrtc/index.js +2 -0
  78. package/build/webrtc/index.js.map +1 -0
  79. package/build/webrtc/types.d.ts +64 -0
  80. package/build/webrtc/types.d.ts.map +1 -0
  81. package/build/webrtc/types.js +5 -0
  82. package/build/webrtc/types.js.map +1 -0
  83. package/expo-module.config.json +9 -0
  84. package/ios/MLKitFaceDetector.swift +310 -0
  85. package/ios/SmartCamera.podspec +33 -0
  86. package/ios/SmartCameraModule.swift +225 -0
  87. package/ios/SmartCameraView.swift +146 -0
  88. package/ios/WebRTCFrameBridge.swift +150 -0
  89. package/package.json +91 -0
  90. package/plugin/build/index.d.ts +28 -0
  91. package/plugin/build/index.js +33 -0
  92. package/plugin/build/withSmartCameraAndroid.d.ts +9 -0
  93. package/plugin/build/withSmartCameraAndroid.js +108 -0
  94. package/plugin/build/withSmartCameraIOS.d.ts +11 -0
  95. package/plugin/build/withSmartCameraIOS.js +92 -0
@@ -0,0 +1,478 @@
1
+ import type { ViewStyle } from 'react-native';
2
+ /**
3
+ * Performance mode for face detection
4
+ * - 'fast': Favor speed over accuracy
5
+ * - 'accurate': Favor accuracy over speed
6
+ */
7
+ export type PerformanceMode = 'fast' | 'accurate';
8
+ /**
9
+ * Mode for detecting facial landmarks
10
+ * - 'none': Don't detect landmarks
11
+ * - 'all': Detect all landmarks (eyes, ears, nose, cheeks, mouth)
12
+ */
13
+ export type LandmarkMode = 'none' | 'all';
14
+ /**
15
+ * Mode for detecting facial contours
16
+ * - 'none': Don't detect contours
17
+ * - 'all': Detect contours (only for most prominent face)
18
+ */
19
+ export type ContourMode = 'none' | 'all';
20
+ /**
21
+ * Mode for face classification
22
+ * - 'none': Don't classify faces
23
+ * - 'all': Classify faces (smiling, eyes open)
24
+ */
25
+ export type ClassificationMode = 'none' | 'all';
26
+ /**
27
+ * Camera facing direction
28
+ */
29
+ export type CameraFacing = 'front' | 'back';
30
+ /**
31
+ * Common face detection options shared between frame processor and static images
32
+ */
33
+ export interface FaceDetectionOptions {
34
+ /**
35
+ * Favor speed or accuracy when detecting faces
36
+ * @default 'fast'
37
+ */
38
+ performanceMode?: PerformanceMode;
39
+ /**
40
+ * Whether to identify facial landmarks: eyes, ears, nose, cheeks, mouth
41
+ * @default 'none'
42
+ */
43
+ landmarkMode?: LandmarkMode;
44
+ /**
45
+ * Whether to detect contours of facial features.
46
+ * Contours are detected for only the most prominent face in an image.
47
+ * @default 'none'
48
+ */
49
+ contourMode?: ContourMode;
50
+ /**
51
+ * Whether to classify faces into categories such as 'smiling' and 'eyes open'
52
+ * @default 'none'
53
+ */
54
+ classificationMode?: ClassificationMode;
55
+ /**
56
+ * Sets the smallest desired face size, expressed as the ratio
57
+ * of the width of the head to width of the image.
58
+ * @default 0.15
59
+ */
60
+ minFaceSize?: number;
61
+ /**
62
+ * Whether to assign faces an ID to track faces across images.
63
+ * Note: When contour detection is enabled, only one face is detected,
64
+ * so face tracking doesn't produce useful results. Don't enable both
65
+ * contour detection and face tracking for best performance.
66
+ * @default false
67
+ */
68
+ trackingEnabled?: boolean;
69
+ }
70
+ /**
71
+ * Frame processor specific options
72
+ */
73
+ export interface FrameProcessorOptions extends FaceDetectionOptions {
74
+ /**
75
+ * Current active camera
76
+ * @default 'front'
77
+ */
78
+ cameraFacing?: CameraFacing;
79
+ /**
80
+ * Should handle auto scale (face bounds, contour and landmarks) and rotation
81
+ * on native side? If disabled, all detection results will be relative to frame
82
+ * coordinates, not to screen/preview.
83
+ * You shouldn't use this option if you want to draw on screen using Skia Frame Processor.
84
+ * @default false
85
+ */
86
+ autoMode?: boolean;
87
+ /**
88
+ * Required if you want to use autoMode. Screen width for coordinate scaling.
89
+ * You must handle your own logic to get screen sizes, with or without statusbar size, etc.
90
+ * @default 1.0
91
+ */
92
+ windowWidth?: number;
93
+ /**
94
+ * Required if you want to use autoMode. Screen height for coordinate scaling.
95
+ * You must handle your own logic to get screen sizes, with or without statusbar size, etc.
96
+ * @default 1.0
97
+ */
98
+ windowHeight?: number;
99
+ }
100
+ /**
101
+ * Static image face detection options
102
+ */
103
+ export interface StaticImageOptions extends FaceDetectionOptions {
104
+ /**
105
+ * Image source for static face detection.
106
+ * Can be a require() result (number), a URI string, or an object with uri.
107
+ */
108
+ image: number | string | {
109
+ uri: string;
110
+ };
111
+ }
112
+ /**
113
+ * 2D point coordinates
114
+ */
115
+ export interface Point {
116
+ x: number;
117
+ y: number;
118
+ }
119
+ /**
120
+ * Bounding rectangle
121
+ */
122
+ export interface Bounds {
123
+ x: number;
124
+ y: number;
125
+ width: number;
126
+ height: number;
127
+ }
128
+ /**
129
+ * Facial landmarks detected by ML Kit
130
+ */
131
+ export interface FaceLandmarks {
132
+ leftEye?: Point;
133
+ rightEye?: Point;
134
+ leftEar?: Point;
135
+ rightEar?: Point;
136
+ leftCheek?: Point;
137
+ rightCheek?: Point;
138
+ noseBase?: Point;
139
+ leftMouth?: Point;
140
+ rightMouth?: Point;
141
+ bottomMouth?: Point;
142
+ }
143
+ /**
144
+ * Face contour types
145
+ */
146
+ export type ContourType = 'face' | 'leftEyebrowTop' | 'leftEyebrowBottom' | 'rightEyebrowTop' | 'rightEyebrowBottom' | 'leftEye' | 'rightEye' | 'upperLipTop' | 'upperLipBottom' | 'lowerLipTop' | 'lowerLipBottom' | 'noseBridge' | 'noseBottom' | 'leftCheek' | 'rightCheek';
147
+ /**
148
+ * Facial contours detected by ML Kit
149
+ */
150
+ export interface FaceContours {
151
+ [key: string]: Point[];
152
+ }
153
+ /**
154
+ * Detected face data
155
+ */
156
+ export interface Face {
157
+ /**
158
+ * Bounding box of the detected face
159
+ */
160
+ bounds: Bounds;
161
+ /**
162
+ * Roll angle of the face (rotation around front-to-back axis)
163
+ */
164
+ rollAngle?: number;
165
+ /**
166
+ * Pitch angle of the face (rotation around left-to-right axis)
167
+ */
168
+ pitchAngle?: number;
169
+ /**
170
+ * Yaw angle of the face (rotation around top-to-bottom axis)
171
+ */
172
+ yawAngle?: number;
173
+ /**
174
+ * Facial landmarks (when landmarkMode is 'all')
175
+ */
176
+ landmarks?: FaceLandmarks;
177
+ /**
178
+ * Facial contours (when contourMode is 'all')
179
+ */
180
+ contours?: FaceContours;
181
+ /**
182
+ * Probability that the face is smiling (0.0 - 1.0)
183
+ * Only available when classificationMode is 'all'
184
+ */
185
+ smilingProbability?: number;
186
+ /**
187
+ * Probability that the left eye is open (0.0 - 1.0)
188
+ * Only available when classificationMode is 'all'
189
+ */
190
+ leftEyeOpenProbability?: number;
191
+ /**
192
+ * Probability that the right eye is open (0.0 - 1.0)
193
+ * Only available when classificationMode is 'all'
194
+ */
195
+ rightEyeOpenProbability?: number;
196
+ /**
197
+ * Tracking ID for this face (when trackingEnabled is true)
198
+ */
199
+ trackingId?: number;
200
+ }
201
+ /**
202
+ * Blink detection event
203
+ */
204
+ export interface BlinkEvent {
205
+ /**
206
+ * Timestamp when the blink was detected
207
+ */
208
+ timestamp: number;
209
+ /**
210
+ * Left eye open probability (0.0 - 1.0)
211
+ */
212
+ leftEyeOpen: number;
213
+ /**
214
+ * Right eye open probability (0.0 - 1.0)
215
+ */
216
+ rightEyeOpen: number;
217
+ /**
218
+ * Whether a blink was detected
219
+ */
220
+ isBlink: boolean;
221
+ /**
222
+ * Face tracking ID (when trackingEnabled is true)
223
+ */
224
+ faceId?: number;
225
+ }
226
+ /**
227
+ * WebRTC mode
228
+ * - 'call': Video calling (1:1 or group)
229
+ * - 'stream': Live streaming to a server
230
+ */
231
+ export type WebRTCMode = 'call' | 'stream';
232
+ /**
233
+ * WebRTC video constraints
234
+ */
235
+ export interface VideoConstraints {
236
+ width?: number;
237
+ height?: number;
238
+ frameRate?: number;
239
+ }
240
+ /**
241
+ * WebRTC configuration
242
+ */
243
+ export interface WebRTCConfig {
244
+ /**
245
+ * Whether WebRTC is enabled
246
+ */
247
+ enabled: boolean;
248
+ /**
249
+ * RTCPeerConnection instance
250
+ */
251
+ peerConnection?: RTCPeerConnection;
252
+ /**
253
+ * WebRTC mode (call or stream)
254
+ * @default 'call'
255
+ */
256
+ mode?: WebRTCMode;
257
+ /**
258
+ * Video constraints for the stream
259
+ */
260
+ videoConstraints?: VideoConstraints;
261
+ }
262
+ /**
263
+ * Face detection configuration for SmartCamera component
264
+ */
265
+ export interface FaceDetectionConfig extends FaceDetectionOptions {
266
+ /**
267
+ * Whether face detection is enabled
268
+ * @default false
269
+ */
270
+ enabled?: boolean;
271
+ /**
272
+ * Handle auto scale on native side
273
+ * @default false
274
+ */
275
+ autoMode?: boolean;
276
+ /**
277
+ * Screen width for coordinate scaling (required when autoMode is true)
278
+ * @default 1.0
279
+ */
280
+ windowWidth?: number;
281
+ /**
282
+ * Screen height for coordinate scaling (required when autoMode is true)
283
+ * @default 1.0
284
+ */
285
+ windowHeight?: number;
286
+ }
287
+ /**
288
+ * SmartCamera component props
289
+ */
290
+ export interface SmartCameraProps {
291
+ /**
292
+ * Camera facing direction
293
+ * @default 'front'
294
+ */
295
+ camera?: CameraFacing;
296
+ /**
297
+ * Target frame rate for the camera
298
+ * @default 30
299
+ */
300
+ fps?: number;
301
+ /**
302
+ * Style for the camera view
303
+ */
304
+ style?: ViewStyle;
305
+ /**
306
+ * Face detection configuration
307
+ */
308
+ faceDetection?: FaceDetectionConfig;
309
+ /**
310
+ * Whether blink detection is enabled
311
+ * @default false
312
+ */
313
+ blinkDetection?: boolean;
314
+ /**
315
+ * Callback when a blink is detected
316
+ */
317
+ onBlinkDetected?: (event: BlinkEvent) => void;
318
+ /**
319
+ * Callback when faces are detected
320
+ */
321
+ onFaceDetected?: (faces: Face[]) => void;
322
+ /**
323
+ * WebRTC configuration for streaming
324
+ */
325
+ webrtc?: WebRTCConfig;
326
+ /**
327
+ * Whether the camera is active
328
+ * @default true
329
+ */
330
+ isActive?: boolean;
331
+ /**
332
+ * Callback when camera is ready
333
+ */
334
+ onReady?: () => void;
335
+ /**
336
+ * Callback when an error occurs
337
+ */
338
+ onError?: (error: SmartCameraError) => void;
339
+ }
340
+ /**
341
+ * Error codes for SmartCamera
342
+ */
343
+ export type SmartCameraErrorCode = 'CAMERA_UNAVAILABLE' | 'PERMISSION_DENIED' | 'WEBRTC_ERROR' | 'ML_KIT_ERROR' | 'FRAME_PROCESSOR_ERROR' | 'UNKNOWN_ERROR';
344
+ /**
345
+ * SmartCamera error
346
+ */
347
+ export interface SmartCameraError {
348
+ /**
349
+ * Error code
350
+ */
351
+ code: SmartCameraErrorCode;
352
+ /**
353
+ * Human-readable error message
354
+ */
355
+ message: string;
356
+ /**
357
+ * Original native error (if available)
358
+ */
359
+ nativeError?: Error;
360
+ }
361
+ /**
362
+ * Return type for useSmartCameraWebRTC hook
363
+ */
364
+ export interface UseSmartCameraWebRTCResult {
365
+ /**
366
+ * The video track for WebRTC
367
+ */
368
+ videoTrack: MediaStreamTrack | null;
369
+ /**
370
+ * Start streaming to the peer connection
371
+ */
372
+ startStreaming: () => void;
373
+ /**
374
+ * Stop streaming
375
+ */
376
+ stopStreaming: () => void;
377
+ /**
378
+ * Switch between front and back camera
379
+ */
380
+ switchCamera: () => void;
381
+ /**
382
+ * Whether streaming is active
383
+ */
384
+ isStreaming: boolean;
385
+ }
386
+ /**
387
+ * Return type for useFaceDetection hook
388
+ */
389
+ export interface UseFaceDetectionResult {
390
+ /**
391
+ * Currently detected faces
392
+ */
393
+ faces: Face[];
394
+ /**
395
+ * Whether face detection is active/detecting
396
+ */
397
+ isDetecting: boolean;
398
+ }
399
+ /**
400
+ * Return type for useBlinkDetection hook
401
+ */
402
+ export interface UseBlinkDetectionResult {
403
+ /**
404
+ * Last blink event
405
+ */
406
+ lastBlink: BlinkEvent | null;
407
+ /**
408
+ * Total blink count
409
+ */
410
+ blinkCount: number;
411
+ /**
412
+ * Reset blink count
413
+ */
414
+ resetCount: () => void;
415
+ }
416
+ /**
417
+ * Camera device information
418
+ */
419
+ export interface CameraDevice {
420
+ /**
421
+ * Unique identifier for the camera device
422
+ */
423
+ id: string;
424
+ /**
425
+ * Human-readable name of the camera
426
+ */
427
+ name: string;
428
+ /**
429
+ * Camera position (front or back)
430
+ */
431
+ position: CameraFacing;
432
+ /**
433
+ * Whether the camera has a flash
434
+ */
435
+ hasFlash: boolean;
436
+ /**
437
+ * Whether the camera has a torch (flashlight)
438
+ */
439
+ hasTorch: boolean;
440
+ /**
441
+ * Whether the camera supports low-light boost
442
+ */
443
+ supportsLowLightBoost: boolean;
444
+ }
445
+ /**
446
+ * Return type for useSmartCamera hook
447
+ */
448
+ export interface UseSmartCameraResult {
449
+ /**
450
+ * Whether camera permission has been granted
451
+ */
452
+ hasPermission: boolean;
453
+ /**
454
+ * Request camera permission
455
+ */
456
+ requestPermission: () => Promise<boolean>;
457
+ /**
458
+ * Current camera device
459
+ */
460
+ device: CameraDevice | undefined;
461
+ /**
462
+ * Switch between front and back camera
463
+ */
464
+ switchCamera: () => void;
465
+ /**
466
+ * Current camera facing direction
467
+ */
468
+ currentCamera: CameraFacing;
469
+ }
470
+ /**
471
+ * Device orientation
472
+ */
473
+ export type Orientation = 'portrait' | 'portrait-upside-down' | 'landscape-left' | 'landscape-right';
474
+ /**
475
+ * Camera output orientation
476
+ */
477
+ export type OutputOrientation = Orientation | 'device';
478
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAM9C;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,UAAU,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC;AAE1C;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,KAAK,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,KAAK,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,CAA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G;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,YAAY,CAAC;IAEvB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAE1C;;OAEG;IACH,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;IAEjC;;OAEG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IAEzB;;OAEG;IACH,aAAa,EAAE,YAAY,CAAC;CAC7B;AAMD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,sBAAsB,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAErG;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,QAAQ,CAAC"}
package/build/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ViewStyle } from 'react-native';\n\n// ============================================================================\n// Face Detection Options\n// ============================================================================\n\n/**\n * Performance mode for face detection\n * - 'fast': Favor speed over accuracy\n * - 'accurate': Favor accuracy over speed\n */\nexport type PerformanceMode = 'fast' | 'accurate';\n\n/**\n * Mode for detecting facial landmarks\n * - 'none': Don't detect landmarks\n * - 'all': Detect all landmarks (eyes, ears, nose, cheeks, mouth)\n */\nexport type LandmarkMode = 'none' | 'all';\n\n/**\n * Mode for detecting facial contours\n * - 'none': Don't detect contours\n * - 'all': Detect contours (only for most prominent face)\n */\nexport type ContourMode = 'none' | 'all';\n\n/**\n * Mode for face classification\n * - 'none': Don't classify faces\n * - 'all': Classify faces (smiling, eyes open)\n */\nexport type ClassificationMode = 'none' | 'all';\n\n/**\n * Camera facing direction\n */\nexport type CameraFacing = 'front' | 'back';\n\n/**\n * Common face detection options shared between frame processor and static images\n */\nexport interface FaceDetectionOptions {\n /**\n * Favor speed or accuracy when detecting faces\n * @default 'fast'\n */\n performanceMode?: PerformanceMode;\n\n /**\n * Whether to identify facial landmarks: eyes, ears, nose, cheeks, mouth\n * @default 'none'\n */\n landmarkMode?: LandmarkMode;\n\n /**\n * Whether to detect contours of facial features.\n * Contours are detected for only the most prominent face in an image.\n * @default 'none'\n */\n contourMode?: ContourMode;\n\n /**\n * Whether to classify faces into categories such as 'smiling' and 'eyes open'\n * @default 'none'\n */\n classificationMode?: ClassificationMode;\n\n /**\n * Sets the smallest desired face size, expressed as the ratio\n * of the width of the head to width of the image.\n * @default 0.15\n */\n minFaceSize?: number;\n\n /**\n * Whether to assign faces an ID to track faces across images.\n * Note: When contour detection is enabled, only one face is detected,\n * so face tracking doesn't produce useful results. Don't enable both\n * contour detection and face tracking for best performance.\n * @default false\n */\n trackingEnabled?: boolean;\n}\n\n/**\n * Frame processor specific options\n */\nexport interface FrameProcessorOptions extends FaceDetectionOptions {\n /**\n * Current active camera\n * @default 'front'\n */\n cameraFacing?: CameraFacing;\n\n /**\n * Should handle auto scale (face bounds, contour and landmarks) and rotation\n * on native side? If disabled, all detection results will be relative to frame\n * coordinates, not to screen/preview.\n * You shouldn't use this option if you want to draw on screen using Skia Frame Processor.\n * @default false\n */\n autoMode?: boolean;\n\n /**\n * Required if you want to use autoMode. Screen width for coordinate scaling.\n * You must handle your own logic to get screen sizes, with or without statusbar size, etc.\n * @default 1.0\n */\n windowWidth?: number;\n\n /**\n * Required if you want to use autoMode. Screen height for coordinate scaling.\n * You must handle your own logic to get screen sizes, with or without statusbar size, etc.\n * @default 1.0\n */\n windowHeight?: number;\n}\n\n/**\n * Static image face detection options\n */\nexport interface StaticImageOptions extends FaceDetectionOptions {\n /**\n * Image source for static face detection.\n * Can be a require() result (number), a URI string, or an object with uri.\n */\n image: number | string | { uri: string };\n}\n\n// ============================================================================\n// Face Detection Results\n// ============================================================================\n\n/**\n * 2D point coordinates\n */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/**\n * Bounding rectangle\n */\nexport interface Bounds {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * Facial landmarks detected by ML Kit\n */\nexport interface FaceLandmarks {\n leftEye?: Point;\n rightEye?: Point;\n leftEar?: Point;\n rightEar?: Point;\n leftCheek?: Point;\n rightCheek?: Point;\n noseBase?: Point;\n leftMouth?: Point;\n rightMouth?: Point;\n bottomMouth?: Point;\n}\n\n/**\n * Face contour types\n */\nexport type ContourType =\n | 'face'\n | 'leftEyebrowTop'\n | 'leftEyebrowBottom'\n | 'rightEyebrowTop'\n | 'rightEyebrowBottom'\n | 'leftEye'\n | 'rightEye'\n | 'upperLipTop'\n | 'upperLipBottom'\n | 'lowerLipTop'\n | 'lowerLipBottom'\n | 'noseBridge'\n | 'noseBottom'\n | 'leftCheek'\n | 'rightCheek';\n\n/**\n * Facial contours detected by ML Kit\n */\nexport interface FaceContours {\n [key: string]: Point[];\n}\n\n/**\n * Detected face data\n */\nexport interface Face {\n /**\n * Bounding box of the detected face\n */\n bounds: Bounds;\n\n /**\n * Roll angle of the face (rotation around front-to-back axis)\n */\n rollAngle?: number;\n\n /**\n * Pitch angle of the face (rotation around left-to-right axis)\n */\n pitchAngle?: number;\n\n /**\n * Yaw angle of the face (rotation around top-to-bottom axis)\n */\n yawAngle?: number;\n\n /**\n * Facial landmarks (when landmarkMode is 'all')\n */\n landmarks?: FaceLandmarks;\n\n /**\n * Facial contours (when contourMode is 'all')\n */\n contours?: FaceContours;\n\n /**\n * Probability that the face is smiling (0.0 - 1.0)\n * Only available when classificationMode is 'all'\n */\n smilingProbability?: number;\n\n /**\n * Probability that the left eye is open (0.0 - 1.0)\n * Only available when classificationMode is 'all'\n */\n leftEyeOpenProbability?: number;\n\n /**\n * Probability that the right eye is open (0.0 - 1.0)\n * Only available when classificationMode is 'all'\n */\n rightEyeOpenProbability?: number;\n\n /**\n * Tracking ID for this face (when trackingEnabled is true)\n */\n trackingId?: number;\n}\n\n// ============================================================================\n// Blink Detection\n// ============================================================================\n\n/**\n * Blink detection event\n */\nexport interface BlinkEvent {\n /**\n * Timestamp when the blink was detected\n */\n timestamp: number;\n\n /**\n * Left eye open probability (0.0 - 1.0)\n */\n leftEyeOpen: number;\n\n /**\n * Right eye open probability (0.0 - 1.0)\n */\n rightEyeOpen: number;\n\n /**\n * Whether a blink was detected\n */\n isBlink: boolean;\n\n /**\n * Face tracking ID (when trackingEnabled is true)\n */\n faceId?: number;\n}\n\n// ============================================================================\n// WebRTC Configuration\n// ============================================================================\n\n/**\n * WebRTC mode\n * - 'call': Video calling (1:1 or group)\n * - 'stream': Live streaming to a server\n */\nexport type WebRTCMode = 'call' | 'stream';\n\n/**\n * WebRTC video constraints\n */\nexport interface VideoConstraints {\n width?: number;\n height?: number;\n frameRate?: number;\n}\n\n/**\n * WebRTC configuration\n */\nexport interface WebRTCConfig {\n /**\n * Whether WebRTC is enabled\n */\n enabled: boolean;\n\n /**\n * RTCPeerConnection instance\n */\n peerConnection?: RTCPeerConnection;\n\n /**\n * WebRTC mode (call or stream)\n * @default 'call'\n */\n mode?: WebRTCMode;\n\n /**\n * Video constraints for the stream\n */\n videoConstraints?: VideoConstraints;\n}\n\n// ============================================================================\n// Face Detection Configuration (for SmartCamera component)\n// ============================================================================\n\n/**\n * Face detection configuration for SmartCamera component\n */\nexport interface FaceDetectionConfig extends FaceDetectionOptions {\n /**\n * Whether face detection is enabled\n * @default false\n */\n enabled?: boolean;\n\n /**\n * Handle auto scale on native side\n * @default false\n */\n autoMode?: boolean;\n\n /**\n * Screen width for coordinate scaling (required when autoMode is true)\n * @default 1.0\n */\n windowWidth?: number;\n\n /**\n * Screen height for coordinate scaling (required when autoMode is true)\n * @default 1.0\n */\n windowHeight?: number;\n}\n\n// ============================================================================\n// SmartCamera Component Props\n// ============================================================================\n\n/**\n * SmartCamera component props\n */\nexport interface SmartCameraProps {\n /**\n * Camera facing direction\n * @default 'front'\n */\n camera?: CameraFacing;\n\n /**\n * Target frame rate for the camera\n * @default 30\n */\n fps?: number;\n\n /**\n * Style for the camera view\n */\n style?: ViewStyle;\n\n /**\n * Face detection configuration\n */\n faceDetection?: FaceDetectionConfig;\n\n /**\n * Whether blink detection is enabled\n * @default false\n */\n blinkDetection?: boolean;\n\n /**\n * Callback when a blink is detected\n */\n onBlinkDetected?: (event: BlinkEvent) => void;\n\n /**\n * Callback when faces are detected\n */\n onFaceDetected?: (faces: Face[]) => void;\n\n /**\n * WebRTC configuration for streaming\n */\n webrtc?: WebRTCConfig;\n\n /**\n * Whether the camera is active\n * @default true\n */\n isActive?: boolean;\n\n /**\n * Callback when camera is ready\n */\n onReady?: () => void;\n\n /**\n * Callback when an error occurs\n */\n onError?: (error: SmartCameraError) => void;\n}\n\n// ============================================================================\n// Error Handling\n// ============================================================================\n\n/**\n * Error codes for SmartCamera\n */\nexport type SmartCameraErrorCode =\n | 'CAMERA_UNAVAILABLE'\n | 'PERMISSION_DENIED'\n | 'WEBRTC_ERROR'\n | 'ML_KIT_ERROR'\n | 'FRAME_PROCESSOR_ERROR'\n | 'UNKNOWN_ERROR';\n\n/**\n * SmartCamera error\n */\nexport interface SmartCameraError {\n /**\n * Error code\n */\n code: SmartCameraErrorCode;\n\n /**\n * Human-readable error message\n */\n message: string;\n\n /**\n * Original native error (if available)\n */\n nativeError?: Error;\n}\n\n// ============================================================================\n// Hook Return Types\n// ============================================================================\n\n/**\n * Return type for useSmartCameraWebRTC hook\n */\nexport interface UseSmartCameraWebRTCResult {\n /**\n * The video track for WebRTC\n */\n videoTrack: MediaStreamTrack | null;\n\n /**\n * Start streaming to the peer connection\n */\n startStreaming: () => void;\n\n /**\n * Stop streaming\n */\n stopStreaming: () => void;\n\n /**\n * Switch between front and back camera\n */\n switchCamera: () => void;\n\n /**\n * Whether streaming is active\n */\n isStreaming: boolean;\n}\n\n/**\n * Return type for useFaceDetection hook\n */\nexport interface UseFaceDetectionResult {\n /**\n * Currently detected faces\n */\n faces: Face[];\n\n /**\n * Whether face detection is active/detecting\n */\n isDetecting: boolean;\n}\n\n/**\n * Return type for useBlinkDetection hook\n */\nexport interface UseBlinkDetectionResult {\n /**\n * Last blink event\n */\n lastBlink: BlinkEvent | null;\n\n /**\n * Total blink count\n */\n blinkCount: number;\n\n /**\n * Reset blink count\n */\n resetCount: () => void;\n}\n\n// ============================================================================\n// Camera Device Types\n// ============================================================================\n\n/**\n * Camera device information\n */\nexport interface CameraDevice {\n /**\n * Unique identifier for the camera device\n */\n id: string;\n\n /**\n * Human-readable name of the camera\n */\n name: string;\n\n /**\n * Camera position (front or back)\n */\n position: CameraFacing;\n\n /**\n * Whether the camera has a flash\n */\n hasFlash: boolean;\n\n /**\n * Whether the camera has a torch (flashlight)\n */\n hasTorch: boolean;\n\n /**\n * Whether the camera supports low-light boost\n */\n supportsLowLightBoost: boolean;\n}\n\n/**\n * Return type for useSmartCamera hook\n */\nexport interface UseSmartCameraResult {\n /**\n * Whether camera permission has been granted\n */\n hasPermission: boolean;\n\n /**\n * Request camera permission\n */\n requestPermission: () => Promise<boolean>;\n\n /**\n * Current camera device\n */\n device: CameraDevice | undefined;\n\n /**\n * Switch between front and back camera\n */\n switchCamera: () => void;\n\n /**\n * Current camera facing direction\n */\n currentCamera: CameraFacing;\n}\n\n// ============================================================================\n// Orientation Types\n// ============================================================================\n\n/**\n * Device orientation\n */\nexport type Orientation = 'portrait' | 'portrait-upside-down' | 'landscape-left' | 'landscape-right';\n\n/**\n * Camera output orientation\n */\nexport type OutputOrientation = Orientation | 'device';\n"]}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * SmartCamera utility functions
3
+ */
4
+ /**
5
+ * Creates an FPS limiter for frame processing
6
+ *
7
+ * @param targetFps - Target frames per second
8
+ * @returns Object with shouldProcess function
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const limiter = createFpsLimiter(15);
13
+ *
14
+ * const frameProcessor = useFrameProcessor((frame) => {
15
+ * if (!limiter.shouldProcess()) return;
16
+ * // Process frame...
17
+ * }, []);
18
+ * ```
19
+ */
20
+ export declare function createFpsLimiter(targetFps: number): {
21
+ shouldProcess: () => boolean;
22
+ reset: () => void;
23
+ setTargetFps: (fps: number) => void;
24
+ };
25
+ /**
26
+ * Creates a debounced function
27
+ *
28
+ * @param fn - Function to debounce
29
+ * @param delay - Delay in milliseconds
30
+ * @returns Debounced function
31
+ */
32
+ export declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void;
33
+ /**
34
+ * Creates a throttled function
35
+ *
36
+ * @param fn - Function to throttle
37
+ * @param limit - Minimum time between calls in milliseconds
38
+ * @returns Throttled function
39
+ */
40
+ export declare function throttle<T extends (...args: unknown[]) => unknown>(fn: T, limit: number): (...args: Parameters<T>) => void;
41
+ /**
42
+ * Creates an object pool for reducing garbage collection
43
+ *
44
+ * @param factory - Factory function to create new objects
45
+ * @param initialSize - Initial pool size
46
+ * @param maxSize - Maximum pool size
47
+ */
48
+ export declare function createObjectPool<T>(factory: () => T, initialSize?: number, maxSize?: number): {
49
+ acquire: () => T;
50
+ release: (obj: T) => void;
51
+ clear: () => void;
52
+ getStats: () => {
53
+ size: number;
54
+ inUse: number;
55
+ available: number;
56
+ };
57
+ };
58
+ import type { SmartCameraError, SmartCameraErrorCode } from '../types';
59
+ /**
60
+ * Creates a SmartCameraError from an unknown error
61
+ *
62
+ * @param error - The original error
63
+ * @param defaultCode - Default error code if not determinable
64
+ * @returns SmartCameraError
65
+ */
66
+ export declare function createSmartCameraError(error: unknown, defaultCode?: SmartCameraErrorCode): SmartCameraError;
67
+ /**
68
+ * Safely execute a function and return a SmartCameraError on failure
69
+ */
70
+ export declare function safeExecute<T>(fn: () => Promise<T>, errorCode?: SmartCameraErrorCode): Promise<{
71
+ data: T;
72
+ error: null;
73
+ } | {
74
+ data: null;
75
+ error: SmartCameraError;
76
+ }>;
77
+ /**
78
+ * Validates face detection options
79
+ */
80
+ export declare function validateFaceDetectionOptions(options: Record<string, unknown>): string[];
81
+ interface PerformanceMetrics {
82
+ frameCount: number;
83
+ averageProcessingTime: number;
84
+ minProcessingTime: number;
85
+ maxProcessingTime: number;
86
+ droppedFrames: number;
87
+ }
88
+ /**
89
+ * Creates a performance monitor for frame processing
90
+ */
91
+ export declare function createPerformanceMonitor(windowSize?: number): {
92
+ startFrame: () => number;
93
+ endFrame: (startTime: number) => void;
94
+ getMetrics: () => PerformanceMetrics;
95
+ reset: () => void;
96
+ };
97
+ export {};
98
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM;yBAK3B,OAAO;;wBAWN,MAAM;EAK7B;AAMD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EAChE,EAAE,EAAE,CAAC,EACL,KAAK,EAAE,MAAM,GACZ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAYlC;AAMD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EAChE,EAAE,EAAE,CAAC,EACL,KAAK,EAAE,MAAM,GACZ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAUlC;AAWD;;;;;;GAMG;A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