@getyoti/react-native-yoti-face-capture 3.0.0 → 4.0.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 (35) hide show
  1. package/README.md +4 -4
  2. package/android/build.gradle +34 -30
  3. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  4. package/android/src/main/java/com/yoti/reactnative/facecapture/YotiFaceCaptureEvent.java +34 -0
  5. package/android/src/main/java/com/yoti/reactnative/facecapture/YotiFaceCaptureModule.java +55 -56
  6. package/android/src/main/java/com/yoti/reactnative/facecapture/YotiFaceCapturePackage.java +5 -2
  7. package/android/src/main/java/com/yoti/reactnative/facecapture/YotiFaceCaptureView.java +129 -73
  8. package/android/src/main/java/com/yoti/reactnative/facecapture/YotiFaceCaptureViewManager.java +10 -1
  9. package/android/src/main/res/layout/yotifacecapture.xml +3 -9
  10. package/lib/commonjs/RNYotiCapture.android.js +63 -94
  11. package/lib/commonjs/RNYotiCapture.android.js.map +1 -1
  12. package/lib/commonjs/RNYotiCapture.ios.js +77 -84
  13. package/lib/commonjs/RNYotiCapture.ios.js.map +1 -1
  14. package/lib/commonjs/RNYotiCaptureTypes.js +9 -17
  15. package/lib/commonjs/RNYotiCaptureTypes.js.map +1 -1
  16. package/lib/commonjs/index.js +21 -6
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/module/RNYotiCapture.android.js +62 -85
  19. package/lib/module/RNYotiCapture.android.js.map +1 -1
  20. package/lib/module/RNYotiCapture.ios.js +76 -75
  21. package/lib/module/RNYotiCapture.ios.js.map +1 -1
  22. package/lib/module/RNYotiCaptureTypes.js +5 -7
  23. package/lib/module/RNYotiCaptureTypes.js.map +1 -1
  24. package/lib/module/index.js +1 -0
  25. package/lib/module/index.js.map +1 -1
  26. package/lib/typescript/RNYotiCapture.android.d.ts +7 -46
  27. package/lib/typescript/RNYotiCapture.ios.d.ts +7 -9
  28. package/lib/typescript/RNYotiCaptureTypes.d.ts +6 -6
  29. package/lib/typescript/index.d.ts +1 -0
  30. package/package.json +6 -8
  31. package/react-native-yoti-face-capture.podspec +1 -1
  32. package/src/RNYotiCapture.android.tsx +128 -115
  33. package/src/RNYotiCapture.ios.tsx +107 -80
  34. package/src/index.tsx +6 -0
  35. package/CHANGELOG.md +0 -29
@@ -1,8 +1,5 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
-
5
- import React from 'react';
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
6
3
  import { findNodeHandle, requireNativeComponent, NativeModules } from 'react-native';
7
4
  import { IMAGE_QUALITY_MEDIUM } from './RNYotiCaptureTypes';
8
5
  const YotiFaceCaptureView = requireNativeComponent('YotiFaceCaptureView');
@@ -19,66 +16,62 @@ const FACE_CAPTURE_FAILURE_RENAMING = {
19
16
  AnalysisError: 'FaceCaptureAnalysisErrorFaceAnalysisFailed',
20
17
  MultipleFacesDetected: 'FaceCaptureAnalysisErrorMultipleFaces'
21
18
  };
22
- export default class RNYotiCapture extends React.Component {
23
- constructor(props) {
24
- super(props);
25
-
26
- _defineProperty(this, "_faceCaptureHandle", void 0);
27
-
28
- _defineProperty(this, "_setReference", ref => {
29
- if (ref) {
30
- this._faceCaptureHandle = findNodeHandle(ref);
31
- } else {
32
- this._faceCaptureHandle = null;
33
- }
34
- });
35
-
36
- this._faceCaptureHandle = null;
37
- }
38
-
39
- startAnalyzing() {
40
- YotiFaceCaptureModule.startAnalyzing(this._faceCaptureHandle);
41
- }
42
-
43
- stopAnalyzing() {
44
- YotiFaceCaptureModule.stopAnalyzing(this._faceCaptureHandle);
45
- }
46
-
47
- startCamera() {
48
- YotiFaceCaptureModule.startCamera(this._faceCaptureHandle);
49
- }
50
-
51
- stopCamera() {
52
- YotiFaceCaptureModule.stopCamera(this._faceCaptureHandle);
53
- }
54
-
55
- onCameraStateChange(cameraState) {
56
- let state = cameraState.nativeEvent.state;
57
-
19
+ const RNYotiCapture = /*#__PURE__*/forwardRef((props, ref) => {
20
+ const {
21
+ requireEyesOpen = false,
22
+ requireBrightEnvironment = true,
23
+ requireValidAngle = false,
24
+ requiredStableFrames = 3,
25
+ imageQuality = IMAGE_QUALITY_MEDIUM,
26
+ faceCenter = [0.5, 0.5],
27
+ onFaceCaptureStateChanged,
28
+ onFaceCaptureStateFailed,
29
+ onFaceCaptureAnalyzedImage,
30
+ onFaceCaptureImageAnalysisFailed
31
+ } = props;
32
+ const faceCaptureHandleRef = useRef(null);
33
+ const setReference = useCallback(nativeRef => {
34
+ if (nativeRef) {
35
+ faceCaptureHandleRef.current = findNodeHandle(nativeRef);
36
+ } else {
37
+ faceCaptureHandleRef.current = null;
38
+ }
39
+ }, []);
40
+ useImperativeHandle(ref, () => ({
41
+ startAnalyzing: () => {
42
+ YotiFaceCaptureModule.startAnalyzing(faceCaptureHandleRef.current);
43
+ },
44
+ stopAnalyzing: () => {
45
+ YotiFaceCaptureModule.stopAnalyzing(faceCaptureHandleRef.current);
46
+ },
47
+ startCamera: () => {
48
+ YotiFaceCaptureModule.startCamera(faceCaptureHandleRef.current);
49
+ },
50
+ stopCamera: () => {
51
+ YotiFaceCaptureModule.stopCamera(faceCaptureHandleRef.current);
52
+ }
53
+ }));
54
+ const handleCameraStateChange = useCallback(cameraState => {
55
+ const state = cameraState.nativeEvent.state;
58
56
  switch (state) {
59
57
  case 'Analyzing':
60
- this.props.onFaceCaptureStateChanged('FaceCaptureStateAnalyzing');
58
+ onFaceCaptureStateChanged('FaceCaptureStateAnalyzing');
61
59
  break;
62
-
63
60
  case 'CameraReady':
64
- this.props.onFaceCaptureStateChanged('FaceCaptureStateCameraReady');
61
+ onFaceCaptureStateChanged('FaceCaptureStateCameraReady');
65
62
  break;
66
-
67
63
  case 'CameraStopped':
68
- this.props.onFaceCaptureStateChanged('FaceCaptureStateCameraStopped');
64
+ onFaceCaptureStateChanged('FaceCaptureStateCameraStopped');
69
65
  break;
70
-
71
66
  case 'CameraInitializationError':
72
- this.props.onFaceCaptureStateFailed('FaceCaptureStateErrorCameraInitializingError');
67
+ onFaceCaptureStateFailed('FaceCaptureStateErrorCameraInitializingError');
73
68
  break;
74
-
75
69
  case 'MissingPermissions':
76
- this.props.onFaceCaptureStateFailed('FaceCaptureStateErrorCameraNotAccessible');
70
+ onFaceCaptureStateFailed('FaceCaptureStateErrorCameraNotAccessible');
77
71
  break;
78
72
  }
79
- }
80
-
81
- onFaceCaptureResult(faceCaptureResult) {
73
+ }, [onFaceCaptureStateChanged, onFaceCaptureStateFailed]);
74
+ const handleFaceCaptureResult = useCallback(faceCaptureResult => {
82
75
  const {
83
76
  cause: nativeCause,
84
77
  croppedImage,
@@ -87,9 +80,8 @@ export default class RNYotiCapture extends React.Component {
87
80
  originalImage,
88
81
  state
89
82
  } = faceCaptureResult.nativeEvent;
90
-
91
83
  if (state === 'ValidFace' && croppedImage != null && croppedFaceBoundingBox != null && faceBoundingBox != null && originalImage != null) {
92
- this.props.onFaceCaptureAnalyzedImage({
84
+ onFaceCaptureAnalyzedImage({
93
85
  croppedImage,
94
86
  croppedFaceBoundingBox,
95
87
  faceBoundingBox,
@@ -97,44 +89,29 @@ export default class RNYotiCapture extends React.Component {
97
89
  });
98
90
  return;
99
91
  }
100
-
101
92
  if (nativeCause === undefined || originalImage === undefined) {
102
93
  return;
103
94
  }
104
-
105
95
  let cause = FACE_CAPTURE_FAILURE_RENAMING[nativeCause];
106
-
107
96
  if (cause === undefined) {
108
97
  cause = 'FaceCaptureAnalysisErrorFaceAnalysisFailed';
109
98
  }
110
-
111
- this.props.onFaceCaptureImageAnalysisFailed({
99
+ onFaceCaptureImageAnalysisFailed({
112
100
  cause,
113
101
  originalImage
114
102
  });
115
- }
116
-
117
- render() {
118
- const {
119
- requireEyesOpen = false,
120
- requireBrightEnvironment = true,
121
- requireValidAngle = false,
122
- requiredStableFrames = 3,
123
- imageQuality = IMAGE_QUALITY_MEDIUM,
124
- faceCenter = [0.5, 0.5]
125
- } = this.props;
126
- return /*#__PURE__*/React.createElement(YotiFaceCaptureView, _extends({}, this.props, {
127
- requireEyesOpen: requireEyesOpen,
128
- requireValidAngle: requireValidAngle,
129
- requiredStableFrames: requiredStableFrames,
130
- requireBrightEnvironment: requireBrightEnvironment,
131
- imageQuality: imageQuality,
132
- faceCenter: faceCenter,
133
- ref: this._setReference,
134
- onCameraStateChange: this.onCameraStateChange.bind(this),
135
- onFaceCaptureResult: this.onFaceCaptureResult.bind(this)
136
- }));
137
- }
138
-
139
- }
103
+ }, [onFaceCaptureAnalyzedImage, onFaceCaptureImageAnalysisFailed]);
104
+ return /*#__PURE__*/React.createElement(YotiFaceCaptureView, _extends({}, props, {
105
+ requireEyesOpen: requireEyesOpen,
106
+ requireValidAngle: requireValidAngle,
107
+ requiredStableFrames: requiredStableFrames,
108
+ requireBrightEnvironment: requireBrightEnvironment,
109
+ imageQuality: imageQuality,
110
+ faceCenter: faceCenter,
111
+ ref: setReference,
112
+ onCameraStateChange: handleCameraStateChange,
113
+ onFaceCaptureResult: handleFaceCaptureResult
114
+ }));
115
+ });
116
+ export default RNYotiCapture;
140
117
  //# sourceMappingURL=RNYotiCapture.android.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["RNYotiCapture.android.tsx"],"names":["React","findNodeHandle","requireNativeComponent","NativeModules","IMAGE_QUALITY_MEDIUM","YotiFaceCaptureView","YotiFaceCaptureModule","FACE_CAPTURE_FAILURE_RENAMING","FaceTooBig","EyesClosed","FaceTooSmall","FaceNotStable","NoFaceDetected","FaceNotCentered","FaceNotStraight","EnvironmentTooDark","AnalysisError","MultipleFacesDetected","RNYotiCapture","Component","constructor","props","ref","_faceCaptureHandle","startAnalyzing","stopAnalyzing","startCamera","stopCamera","onCameraStateChange","cameraState","state","nativeEvent","onFaceCaptureStateChanged","onFaceCaptureStateFailed","onFaceCaptureResult","faceCaptureResult","cause","nativeCause","croppedImage","croppedFaceBoundingBox","faceBoundingBox","originalImage","onFaceCaptureAnalyzedImage","undefined","onFaceCaptureImageAnalysisFailed","render","requireEyesOpen","requireBrightEnvironment","requireValidAngle","requiredStableFrames","imageQuality","faceCenter","_setReference","bind"],"mappings":";;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SACEC,cADF,EAEEC,sBAFF,EAGEC,aAHF,QAIO,cAJP;AAYA,SAASC,oBAAT,QAAqC,sBAArC;AAEA,MAAMC,mBAAmB,GACvBH,sBAAsB,CAA+B,qBAA/B,CADxB;AAEA,MAAMI,qBAAqB,GAAGH,aAAa,CAACG,qBAA5C;AA2EA,MAAMC,6BAA8C,GAAG;AACrDC,EAAAA,UAAU,EAAE,oCADyC;AAErDC,EAAAA,UAAU,EAAE,qCAFyC;AAGrDC,EAAAA,YAAY,EAAE,sCAHuC;AAIrDC,EAAAA,aAAa,EAAE,uCAJsC;AAKrDC,EAAAA,cAAc,EAAE,wCALqC;AAMrDC,EAAAA,eAAe,EAAE,yCANoC;AAOrDC,EAAAA,eAAe,EAAE,yCAPoC;AAQrDC,EAAAA,kBAAkB,EAAE,4CARiC;AASrDC,EAAAA,aAAa,EAAE,4CATsC;AAUrDC,EAAAA,qBAAqB,EAAE;AAV8B,CAAvD;AAaA,eAAe,MAAMC,aAAN,SAA4BlB,KAAK,CAACmB,SAAlC,CAA4D;AAGzEC,EAAAA,WAAW,CAACC,KAAD,EAAwB;AACjC,UAAMA,KAAN;;AADiC;;AAAA,2CAKlBC,GAAD,IAAc;AAC5B,UAAIA,GA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AAKxB,mBAAL,CAAyByB,IAAzB,CAA8B,IAA9B,CATvB;AAUE,MAAA,mBAAmB,EAAE,KAAKnB,mBAAL,CAAyBmB,IAAzB,CAA8B,IAA9B;AAVvB,OADF;AAcD;;AAnIwE","sourcesContent":["import React from 'react';\nimport {\n findNodeHandle,\n requireNativeComponent,\n NativeModules,\n} from 'react-native';\n\nimport type {\n ANALYSIS_FAILURE_CAUSE,\n ComponentProps,\n IMAGE_QUALITY,\n} from './RNYotiCaptureTypes';\n\nimport { IMAGE_QUALITY_MEDIUM } from './RNYotiCaptureTypes';\n\nconst YotiFaceCaptureView =\n requireNativeComponent<NativeFaceCaptureViewAndroid>('YotiFaceCaptureView');\nconst YotiFaceCaptureModule = NativeModules.YotiFaceCaptureModule;\n\ntype NativeCaptureResultState = 'ValidFace' | 'InvalidFace';\n\ntype NATIVE_ANALYSIS_FAILURE_CAUSE =\n | 'FaceTooBig'\n | 'EyesClosed'\n | 'FaceTooSmall'\n | 'FaceNotStable'\n | 'NoFaceDetected'\n | 'FaceNotCentered'\n | 'FaceNotStraight'\n | 'EnvironmentTooDark'\n | 'AnalysisError'\n | 'MultipleFacesDetected';\n\ntype NativeCaptureResult = {\n nativeEvent: {\n cause?: NATIVE_ANALYSIS_FAILURE_CAUSE;\n croppedImage?: string;\n croppedFaceBoundingBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n faceBoundingBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n originalImage?: string;\n state: NativeCaptureResultState;\n };\n};\n\ntype NativeFaceCaptureSuccessState =\n | 'Analyzing'\n | 'CameraReady'\n | 'CameraStopped';\n\ntype NativeFaceCaptureFailureState =\n | 'CameraInitializationError'\n | 'MissingPermissions';\n\ntype NativeFaceCaptureState = {\n nativeEvent: {\n state: NativeFaceCaptureSuccessState;\n };\n};\n\ntype NativeFaceCaptureStateFailure = {\n nativeEvent: {\n state: NativeFaceCaptureFailureState;\n };\n};\n\ninterface NativeFaceCaptureViewAndroid {\n requireEyesOpen: boolean;\n requireValidAngle: boolean;\n requiredStableFrames: number;\n requireBrightEnvironment: Boolean;\n imageQuality: IMAGE_QUALITY;\n faceCenter: Array<number>;\n onCameraStateChange: (\n faceCaptureState: NativeFaceCaptureState | NativeFaceCaptureStateFailure\n ) => void;\n onFaceCaptureResult: (faceCaptureResult: NativeCaptureResult) => void;\n}\n\ntype FailureRenaming = {\n [Property in NATIVE_ANALYSIS_FAILURE_CAUSE]: ANALYSIS_FAILURE_CAUSE;\n};\n\nconst FACE_CAPTURE_FAILURE_RENAMING: FailureRenaming = {\n FaceTooBig: 'FaceCaptureAnalysisErrorFaceTooBig',\n EyesClosed: 'FaceCaptureAnalysisErrorEyesNotOpen',\n FaceTooSmall: 'FaceCaptureAnalysisErrorFaceTooSmall',\n FaceNotStable: 'FaceCaptureAnalysisErrorFaceNotStable',\n NoFaceDetected: 'FaceCaptureAnalysisErrorNoFaceDetected',\n FaceNotCentered: 'FaceCaptureAnalysisErrorFaceNotCentered',\n FaceNotStraight: 'FaceCaptureAnalysisErrorFaceNotStraight',\n EnvironmentTooDark: 'FaceCaptureAnalysisErrorEnvironmentTooDark',\n AnalysisError: 'FaceCaptureAnalysisErrorFaceAnalysisFailed',\n MultipleFacesDetected: 'FaceCaptureAnalysisErrorMultipleFaces',\n};\n\nexport default class RNYotiCapture extends React.Component<ComponentProps> {\n _faceCaptureHandle: number | null;\n\n constructor(props: ComponentProps) {\n super(props);\n this._faceCaptureHandle = null;\n }\n\n _setReference = (ref: any) => {\n if (ref) {\n this._faceCaptureHandle = findNodeHandle(ref);\n } else {\n this._faceCaptureHandle = null;\n }\n };\n\n startAnalyzing() {\n YotiFaceCaptureModule.startAnalyzing(this._faceCaptureHandle);\n }\n\n stopAnalyzing() {\n YotiFaceCaptureModule.stopAnalyzing(this._faceCaptureHandle);\n }\n\n startCamera() {\n YotiFaceCaptureModule.startCamera(this._faceCaptureHandle);\n }\n\n stopCamera() {\n YotiFaceCaptureModule.stopCamera(this._faceCaptureHandle);\n }\n\n onCameraStateChange(\n cameraState: NativeFaceCaptureState | NativeFaceCaptureStateFailure\n ) {\n let state = cameraState.nativeEvent.state;\n\n switch (state) {\n case 'Analyzing':\n this.props.onFaceCaptureStateChanged('FaceCaptureStateAnalyzing');\n break;\n\n case 'CameraReady':\n this.props.onFaceCaptureStateChanged('FaceCaptureStateCameraReady');\n break;\n\n case 'CameraStopped':\n this.props.onFaceCaptureStateChanged('FaceCaptureStateCameraStopped');\n break;\n\n case 'CameraInitializationError':\n this.props.onFaceCaptureStateFailed(\n 'FaceCaptureStateErrorCameraInitializingError'\n );\n break;\n\n case 'MissingPermissions':\n this.props.onFaceCaptureStateFailed(\n 'FaceCaptureStateErrorCameraNotAccessible'\n );\n break;\n }\n }\n\n onFaceCaptureResult(faceCaptureResult: NativeCaptureResult) {\n const {\n cause: nativeCause,\n croppedImage,\n croppedFaceBoundingBox,\n faceBoundingBox,\n originalImage,\n state,\n } = faceCaptureResult.nativeEvent;\n\n if (\n state === 'ValidFace' &&\n croppedImage != null &&\n croppedFaceBoundingBox != null &&\n faceBoundingBox != null &&\n originalImage != null\n ) {\n this.props.onFaceCaptureAnalyzedImage({\n croppedImage,\n croppedFaceBoundingBox,\n faceBoundingBox,\n originalImage,\n });\n return;\n }\n if (nativeCause === undefined || originalImage === undefined) {\n return;\n }\n\n let cause = FACE_CAPTURE_FAILURE_RENAMING[nativeCause];\n if (cause === undefined) {\n cause = 'FaceCaptureAnalysisErrorFaceAnalysisFailed';\n }\n\n this.props.onFaceCaptureImageAnalysisFailed({\n cause,\n originalImage,\n });\n }\n\n render() {\n const {\n requireEyesOpen = false,\n requireBrightEnvironment = true,\n requireValidAngle = false,\n requiredStableFrames = 3,\n imageQuality = IMAGE_QUALITY_MEDIUM,\n faceCenter = [\n 0.5,\n 0.5\n ],\n } = this.props;\n\n return (\n <YotiFaceCaptureView\n {...this.props}\n requireEyesOpen={requireEyesOpen}\n requireValidAngle={requireValidAngle}\n requiredStableFrames={requiredStableFrames}\n requireBrightEnvironment={requireBrightEnvironment}\n imageQuality={imageQuality}\n faceCenter={faceCenter}\n ref={this._setReference}\n onCameraStateChange={this.onCameraStateChange.bind(this)}\n onFaceCaptureResult={this.onFaceCaptureResult.bind(this)}\n />\n );\n }\n}\n"]}
1
+ {"version":3,"names":["React","forwardRef","useCallback","useImperativeHandle","useRef","findNodeHandle","requireNativeComponent","NativeModules","IMAGE_QUALITY_MEDIUM","YotiFaceCaptureView","YotiFaceCaptureModule","FACE_CAPTURE_FAILURE_RENAMING","FaceTooBig","EyesClosed","FaceTooSmall","FaceNotStable","NoFaceDetected","FaceNotCentered","FaceNotStraight","EnvironmentTooDark","AnalysisError","MultipleFacesDetected","RNYotiCapture","props","ref","requireEyesOpen","requireBrightEnvironment","requireValidAngle","requiredStableFrames","imageQuality","faceCenter","onFaceCaptureStateChanged","onFaceCaptureStateFailed","onFaceCaptureAnalyzedImage","onFaceCaptureImageAnalysisFailed","faceCaptureHandleRef","setReference","nativeRef","current","startAnalyzing","stopAnalyzing","startCamera","stopCamera","handleCameraStateChange","cameraState","state","nativeEvent","handleFaceCaptureResult","faceCaptureResult","cause","nativeCause","croppedImage","croppedFaceBoundingBox","faceBoundingBox","originalImage","undefined","createElement","_extends","onCameraStateChange","onFaceCaptureResult"],"sources":["RNYotiCapture.android.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport {\n findNodeHandle,\n requireNativeComponent,\n NativeModules,\n} from 'react-native';\n\nimport type {\n ANALYSIS_FAILURE_CAUSE,\n ComponentProps,\n IMAGE_QUALITY,\n} from './RNYotiCaptureTypes';\n\nimport { IMAGE_QUALITY_MEDIUM } from './RNYotiCaptureTypes';\n\nconst YotiFaceCaptureView =\n requireNativeComponent<NativeFaceCaptureViewAndroid>('YotiFaceCaptureView');\nconst YotiFaceCaptureModule = NativeModules.YotiFaceCaptureModule;\n\ntype NativeCaptureResultState = 'ValidFace' | 'InvalidFace';\n\ntype NATIVE_ANALYSIS_FAILURE_CAUSE =\n | 'FaceTooBig'\n | 'EyesClosed'\n | 'FaceTooSmall'\n | 'FaceNotStable'\n | 'NoFaceDetected'\n | 'FaceNotCentered'\n | 'FaceNotStraight'\n | 'EnvironmentTooDark'\n | 'AnalysisError'\n | 'MultipleFacesDetected';\n\ntype NativeCaptureResult = {\n nativeEvent: {\n cause?: NATIVE_ANALYSIS_FAILURE_CAUSE;\n croppedImage?: string;\n croppedFaceBoundingBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n faceBoundingBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n originalImage?: string;\n state: NativeCaptureResultState;\n };\n};\n\ntype NativeFaceCaptureSuccessState =\n | 'Analyzing'\n | 'CameraReady'\n | 'CameraStopped';\n\ntype NativeFaceCaptureFailureState =\n | 'CameraInitializationError'\n | 'MissingPermissions';\n\ntype NativeFaceCaptureState = {\n nativeEvent: {\n state: NativeFaceCaptureSuccessState;\n };\n};\n\ntype NativeFaceCaptureStateFailure = {\n nativeEvent: {\n state: NativeFaceCaptureFailureState;\n };\n};\n\ninterface NativeFaceCaptureViewAndroid {\n requireEyesOpen: boolean;\n requireValidAngle: boolean;\n requiredStableFrames: number;\n requireBrightEnvironment: Boolean;\n imageQuality: IMAGE_QUALITY;\n faceCenter: Array<number>;\n onCameraStateChange: (\n faceCaptureState: NativeFaceCaptureState | NativeFaceCaptureStateFailure\n ) => void;\n onFaceCaptureResult: (faceCaptureResult: NativeCaptureResult) => void;\n}\n\ntype FailureRenaming = {\n [Property in NATIVE_ANALYSIS_FAILURE_CAUSE]: ANALYSIS_FAILURE_CAUSE;\n};\n\nconst FACE_CAPTURE_FAILURE_RENAMING: FailureRenaming = {\n FaceTooBig: 'FaceCaptureAnalysisErrorFaceTooBig',\n EyesClosed: 'FaceCaptureAnalysisErrorEyesNotOpen',\n FaceTooSmall: 'FaceCaptureAnalysisErrorFaceTooSmall',\n FaceNotStable: 'FaceCaptureAnalysisErrorFaceNotStable',\n NoFaceDetected: 'FaceCaptureAnalysisErrorNoFaceDetected',\n FaceNotCentered: 'FaceCaptureAnalysisErrorFaceNotCentered',\n FaceNotStraight: 'FaceCaptureAnalysisErrorFaceNotStraight',\n EnvironmentTooDark: 'FaceCaptureAnalysisErrorEnvironmentTooDark',\n AnalysisError: 'FaceCaptureAnalysisErrorFaceAnalysisFailed',\n MultipleFacesDetected: 'FaceCaptureAnalysisErrorMultipleFaces',\n};\n\nexport type RNYotiCaptureRef = {\n startAnalyzing: () => void;\n stopAnalyzing: () => void;\n startCamera: () => void;\n stopCamera: () => void;\n};\n\nconst RNYotiCapture = forwardRef<RNYotiCaptureRef, ComponentProps>(\n (props, ref) => {\n const {\n requireEyesOpen = false,\n requireBrightEnvironment = true,\n requireValidAngle = false,\n requiredStableFrames = 3,\n imageQuality = IMAGE_QUALITY_MEDIUM,\n faceCenter = [0.5, 0.5],\n onFaceCaptureStateChanged,\n onFaceCaptureStateFailed,\n onFaceCaptureAnalyzedImage,\n onFaceCaptureImageAnalysisFailed,\n } = props;\n\n const faceCaptureHandleRef = useRef<number | null>(null);\n\n const setReference = useCallback((nativeRef: any) => {\n if (nativeRef) {\n faceCaptureHandleRef.current = findNodeHandle(nativeRef);\n } else {\n faceCaptureHandleRef.current = null;\n }\n }, []);\n\n useImperativeHandle(ref, () => ({\n startAnalyzing: () => {\n YotiFaceCaptureModule.startAnalyzing(faceCaptureHandleRef.current);\n },\n stopAnalyzing: () => {\n YotiFaceCaptureModule.stopAnalyzing(faceCaptureHandleRef.current);\n },\n startCamera: () => {\n YotiFaceCaptureModule.startCamera(faceCaptureHandleRef.current);\n },\n stopCamera: () => {\n YotiFaceCaptureModule.stopCamera(faceCaptureHandleRef.current);\n },\n }));\n\n const handleCameraStateChange = useCallback(\n (cameraState: NativeFaceCaptureState | NativeFaceCaptureStateFailure) => {\n const state = cameraState.nativeEvent.state;\n\n switch (state) {\n case 'Analyzing':\n onFaceCaptureStateChanged('FaceCaptureStateAnalyzing');\n break;\n\n case 'CameraReady':\n onFaceCaptureStateChanged('FaceCaptureStateCameraReady');\n break;\n\n case 'CameraStopped':\n onFaceCaptureStateChanged('FaceCaptureStateCameraStopped');\n break;\n\n case 'CameraInitializationError':\n onFaceCaptureStateFailed(\n 'FaceCaptureStateErrorCameraInitializingError'\n );\n break;\n\n case 'MissingPermissions':\n onFaceCaptureStateFailed(\n 'FaceCaptureStateErrorCameraNotAccessible'\n );\n break;\n }\n },\n [onFaceCaptureStateChanged, onFaceCaptureStateFailed]\n );\n\n const handleFaceCaptureResult = useCallback(\n (faceCaptureResult: NativeCaptureResult) => {\n const {\n cause: nativeCause,\n croppedImage,\n croppedFaceBoundingBox,\n faceBoundingBox,\n originalImage,\n state,\n } = faceCaptureResult.nativeEvent;\n\n if (\n state === 'ValidFace' &&\n croppedImage != null &&\n croppedFaceBoundingBox != null &&\n faceBoundingBox != null &&\n originalImage != null\n ) {\n onFaceCaptureAnalyzedImage({\n croppedImage,\n croppedFaceBoundingBox,\n faceBoundingBox,\n originalImage,\n });\n return;\n }\n if (nativeCause === undefined || originalImage === undefined) {\n return;\n }\n\n let cause = FACE_CAPTURE_FAILURE_RENAMING[nativeCause];\n if (cause === undefined) {\n cause = 'FaceCaptureAnalysisErrorFaceAnalysisFailed';\n }\n\n onFaceCaptureImageAnalysisFailed({\n cause,\n originalImage,\n });\n },\n [onFaceCaptureAnalyzedImage, onFaceCaptureImageAnalysisFailed]\n );\n\n return (\n <YotiFaceCaptureView\n {...props}\n requireEyesOpen={requireEyesOpen}\n requireValidAngle={requireValidAngle}\n requiredStableFrames={requiredStableFrames}\n requireBrightEnvironment={requireBrightEnvironment}\n imageQuality={imageQuality}\n faceCenter={faceCenter}\n ref={setReference}\n onCameraStateChange={handleCameraStateChange}\n onFaceCaptureResult={handleFaceCaptureResult}\n />\n );\n }\n);\n\nexport default RNYotiCapture;\n"],"mappings":";AAAA,OAAOA,KAAK,IACVC,UAAU,EACVC,WAAW,EACXC,mBAA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e,IAAI,IAAI,IACvBC,aAAa,IAAI,IAAI,EACrB;MACArB,0BAA0B,CAAC;QACzBkB,YAAY;QACZC,sBAAsB;QACtBC,eAAe;QACfC;MACF,CAAC,CAAC;MACF;IACF;IACA,IAAIJ,WAAW,KAAKK,SAAS,IAAID,aAAa,KAAKC,SAAS,EAAE;MAC5D;IACF;IAEA,IAAIN,KAAK,GAAGtC,6BAA6B,CAACuC,WAAW,CAAC;IACtD,IAAID,KAAK,KAAKM,SAAS,EAAE;MACvBN,KAAK,GAAG,4CAA4C;IACtD;IAEAf,gCAAgC,CAAC;MAC/Be,KAAK;MACLK;IACF,CAAC,CAAC;EACJ,CAAC,EACD,CAACrB,0BAA0B,EAAEC,gCAAgC,CAC/D,CAAC;EAED,oBACElC,KAAA,CAAAwD,aAAA,CAAC/C,mBAAmB,EAAAgD,QAAA,KACdlC,KAAK;IACTE,eAAe,EAAEA,eAAgB;IACjCE,iBAAiB,EAAEA,iBAAkB;IACrCC,oBAAoB,EAAEA,oBAAqB;IAC3CF,wBAAwB,EAAEA,wBAAyB;IACnDG,YAAY,EAAEA,YAAa;IAC3BC,UAAU,EAAEA,UAAW;IACvBN,GAAG,EAAEY,YAAa;IAClBsB,mBAAmB,EAAEf,uBAAwB;IAC7CgB,mBAAmB,EAAEZ;EAAwB,EAC9C,CAAC;AAEN,CACF,CAAC;AAED,eAAezB,aAAa","ignoreList":[]}
@@ -1,79 +1,80 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
-
5
- import React from 'react';
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
6
3
  import { findNodeHandle, requireNativeComponent, UIManager } from 'react-native';
7
4
  import { IMAGE_QUALITY_MEDIUM } from './RNYotiCaptureTypes';
8
5
  const YotiFaceCaptureView = requireNativeComponent('YotiFaceCaptureView');
9
- export default class RNYotiCapture extends React.Component {
10
- constructor(props) {
11
- super(props);
12
-
13
- _defineProperty(this, "_faceCaptureHandle", void 0);
14
-
15
- _defineProperty(this, "_setReference", ref => {
16
- if (ref) {
17
- this._faceCaptureHandle = findNodeHandle(ref);
18
- } else {
19
- this._faceCaptureHandle = null;
20
- }
21
- });
22
-
23
- _defineProperty(this, "startCamera", () => {
24
- UIManager.dispatchViewManagerCommand(findNodeHandle(this._faceCaptureHandle), UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands.startCamera, []);
25
- });
26
-
27
- this._faceCaptureHandle = null;
28
- }
29
-
30
- startAnalyzing() {
31
- UIManager.dispatchViewManagerCommand(findNodeHandle(this), UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands.startAnalyzing, []);
32
- }
33
-
34
- stopAnalyzing() {
35
- UIManager.dispatchViewManagerCommand(findNodeHandle(this), UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands.stopAnalyzing, []);
36
- }
37
-
38
- stopCamera() {
39
- UIManager.dispatchViewManagerCommand(findNodeHandle(this._faceCaptureHandle), UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands.stopCamera, []);
40
- }
41
-
42
- render() {
43
- const {
44
- requireEyesOpen = false,
45
- requireValidAngle = false,
46
- requiredStableFrames = 3,
47
- requireBrightEnvironment = true,
48
- imageQuality = IMAGE_QUALITY_MEDIUM,
49
- faceCenter = [0.5, 0.5]
50
- } = this.props;
51
- return /*#__PURE__*/React.createElement(YotiFaceCaptureView, _extends({}, this.props, {
52
- requireEyesOpen: requireEyesOpen,
53
- requireValidAngle: requireValidAngle,
54
- requiredStableFrames: requiredStableFrames,
55
- requireBrightEnvironment: requireBrightEnvironment,
56
- imageQuality: imageQuality,
57
- faceCenter: faceCenter,
58
- onFaceCaptureAnalyzedImage: ({
59
- nativeEvent: faceCaptureResult
60
- }) => this.props.onFaceCaptureAnalyzedImage(faceCaptureResult),
61
- onFaceCaptureImageAnalysisFailed: ({
62
- nativeEvent: faceCaptureAnalysisFailure
63
- }) => this.props.onFaceCaptureImageAnalysisFailed(faceCaptureAnalysisFailure),
64
- onFaceCaptureStateChanged: ({
65
- nativeEvent: {
66
- state: faceCaptureState
67
- }
68
- }) => this.props.onFaceCaptureStateChanged(faceCaptureState),
69
- onFaceCaptureStateFailed: ({
70
- nativeEvent: {
71
- state: faceCaptureStateFailure
72
- }
73
- }) => this.props.onFaceCaptureStateFailed(faceCaptureStateFailure),
74
- ref: this._setReference
75
- }));
76
- }
77
-
78
- }
6
+ const RNYotiCapture = /*#__PURE__*/forwardRef((props, ref) => {
7
+ const {
8
+ requireEyesOpen = false,
9
+ requireValidAngle = false,
10
+ requiredStableFrames = 3,
11
+ requireBrightEnvironment = true,
12
+ imageQuality = IMAGE_QUALITY_MEDIUM,
13
+ faceCenter = [0.5, 0.5],
14
+ onFaceCaptureAnalyzedImage,
15
+ onFaceCaptureImageAnalysisFailed,
16
+ onFaceCaptureStateChanged,
17
+ onFaceCaptureStateFailed
18
+ } = props;
19
+ const faceCaptureHandleRef = useRef(null);
20
+ const setReference = useCallback(nativeRef => {
21
+ if (nativeRef) {
22
+ faceCaptureHandleRef.current = findNodeHandle(nativeRef);
23
+ } else {
24
+ faceCaptureHandleRef.current = null;
25
+ }
26
+ }, []);
27
+ useImperativeHandle(ref, () => ({
28
+ startAnalyzing: () => {
29
+ UIManager.dispatchViewManagerCommand(faceCaptureHandleRef.current, UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands.startAnalyzing, []);
30
+ },
31
+ stopAnalyzing: () => {
32
+ UIManager.dispatchViewManagerCommand(faceCaptureHandleRef.current, UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands.stopAnalyzing, []);
33
+ },
34
+ startCamera: () => {
35
+ UIManager.dispatchViewManagerCommand(faceCaptureHandleRef.current, UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands.startCamera, []);
36
+ },
37
+ stopCamera: () => {
38
+ UIManager.dispatchViewManagerCommand(faceCaptureHandleRef.current, UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands.stopCamera, []);
39
+ }
40
+ }));
41
+ const handleFaceCaptureAnalyzedImage = useCallback(({
42
+ nativeEvent: faceCaptureResult
43
+ }) => {
44
+ onFaceCaptureAnalyzedImage(faceCaptureResult);
45
+ }, [onFaceCaptureAnalyzedImage]);
46
+ const handleFaceCaptureImageAnalysisFailed = useCallback(({
47
+ nativeEvent: faceCaptureAnalysisFailure
48
+ }) => {
49
+ onFaceCaptureImageAnalysisFailed(faceCaptureAnalysisFailure);
50
+ }, [onFaceCaptureImageAnalysisFailed]);
51
+ const handleFaceCaptureStateChanged = useCallback(({
52
+ nativeEvent: {
53
+ state: faceCaptureState
54
+ }
55
+ }) => {
56
+ onFaceCaptureStateChanged(faceCaptureState);
57
+ }, [onFaceCaptureStateChanged]);
58
+ const handleFaceCaptureStateFailed = useCallback(({
59
+ nativeEvent: {
60
+ state: faceCaptureStateFailure
61
+ }
62
+ }) => {
63
+ onFaceCaptureStateFailed(faceCaptureStateFailure);
64
+ }, [onFaceCaptureStateFailed]);
65
+ return /*#__PURE__*/React.createElement(YotiFaceCaptureView, _extends({}, props, {
66
+ requireEyesOpen: requireEyesOpen,
67
+ requireValidAngle: requireValidAngle,
68
+ requiredStableFrames: requiredStableFrames,
69
+ requireBrightEnvironment: requireBrightEnvironment,
70
+ imageQuality: imageQuality,
71
+ faceCenter: faceCenter,
72
+ onFaceCaptureAnalyzedImage: handleFaceCaptureAnalyzedImage,
73
+ onFaceCaptureImageAnalysisFailed: handleFaceCaptureImageAnalysisFailed,
74
+ onFaceCaptureStateChanged: handleFaceCaptureStateChanged,
75
+ onFaceCaptureStateFailed: handleFaceCaptureStateFailed,
76
+ ref: setReference
77
+ }));
78
+ });
79
+ export default RNYotiCapture;
79
80
  //# sourceMappingURL=RNYotiCapture.ios.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["RNYotiCapture.ios.tsx"],"names":["React","findNodeHandle","requireNativeComponent","UIManager","IMAGE_QUALITY_MEDIUM","YotiFaceCaptureView","RNYotiCapture","Component","constructor","props","ref","_faceCaptureHandle","dispatchViewManagerCommand","getViewManagerConfig","Commands","startCamera","startAnalyzing","stopAnalyzing","stopCamera","render","requireEyesOpen","requireValidAngle","requiredStableFrames","requireBrightEnvironment","imageQuality","faceCenter","nativeEvent","faceCaptureResult","onFaceCaptureAnalyzedImage","faceCaptureAnalysisFailure","onFaceCaptureImageAnalysisFailed","state","faceCaptureState","onFaceCaptureStateChanged","faceCaptureStateFailure","onFaceCaptureStateFailed","_setReference"],"mappings":";;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SACEC,cADF,EAEEC,sBAFF,EAGEC,SAHF,QAIO,cAJP;AAeA,SAASC,oBAAT,QAAqC,sBAArC;AA4CA,MAAMC,mBAAmB,GAAGH,sBAAsB,CAChD,qBADgD,CAAlD;AAIA,eAAe,MAAMI,aAAN,SAA4BN,KAAK,CAACO,SAAlC,CAA4D;AAGzEC,EAAAA,WAAW,CAACC,KAAD,EAAwB;AACjC,UAAMA,KAAN;;AADiC;;AAAA,2CAKlBC,GAAD,IAAc;AAC5B,UAAIA,GAAJ,EAAS;AACP,aAAKC,kBAAL,GAA0BV,cAAc,CAACS,GAAD,CAAxC;AACD,OAFD,MAEO;AACL,aAAKC,kBAAL,GAA0B,IAA1B;AACD;AACF,KAXkC;;AAAA,yCA+Bd,MAAM;AACzBR,MAAAA,SAAS,CAACS,0BAAV,CACEX,cAAc,CAAC,KAAKU,kBAAN,CADhB,EAEER,SAAS,CAACU,oBAAV,CAA+B,qBA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,EAAEC;AADc,OAAD,KAG1B,KAAKlB,KAAL,CAAWmB,0BAAX,CAAsCD,iBAAtC,CAXJ;AAaE,MAAA,gCAAgC,EAAE,CAAC;AACjCD,QAAAA,WAAW,EAAEG;AADoB,OAAD,KAGhC,KAAKpB,KAAL,CAAWqB,gCAAX,CACED,0BADF,CAhBJ;AAoBE,MAAA,yBAAyB,EAAE,CAAC;AAC1BH,QAAAA,WAAW,EAAE;AAAEK,UAAAA,KAAK,EAAEC;AAAT;AADa,OAAD,KAGzB,KAAKvB,KAAL,CAAWwB,yBAAX,CAAqCD,gBAArC,CAvBJ;AAyBE,MAAA,wBAAwB,EAAE,CAAC;AACzBN,QAAAA,WAAW,EAAE;AAAEK,UAAAA,KAAK,EAAEG;AAAT;AADY,OAAD,KAGxB,KAAKzB,KAAL,CAAW0B,wBAAX,CAAoCD,uBAApC,CA5BJ;AA8BE,MAAA,GAAG,EAAE,KAAKE;AA9BZ,OADF;AAkCD;;AAjGwE","sourcesContent":["import React from 'react';\nimport {\n findNodeHandle,\n requireNativeComponent,\n UIManager,\n} from 'react-native';\n\nimport type {\n ANALYSIS_FAILURE_CAUSE,\n ComponentProps,\n FaceCaptureResult,\n FaceCaptureSuccessState,\n FaceCaptureFailureState,\n IMAGE_QUALITY,\n} from './RNYotiCaptureTypes';\n\nimport { IMAGE_QUALITY_MEDIUM } from './RNYotiCaptureTypes';\n\ntype NativeFaceCaptureResult = {\n nativeEvent: FaceCaptureResult;\n};\n\ntype NativeFaceCaptureState = {\n nativeEvent: {\n state: FaceCaptureSuccessState;\n };\n};\n\ntype NativeFaceCaptureStateFailure = {\n nativeEvent: {\n state: FaceCaptureFailureState;\n };\n};\n\ntype NativeFaceCaptureAnalysisFailure = {\n nativeEvent: {\n cause: ANALYSIS_FAILURE_CAUSE;\n originalImage: string;\n };\n};\n\ninterface NativeFaceCaptureViewIOS {\n imageQuality: IMAGE_QUALITY;\n requireEyesOpen: boolean;\n requireValidAngle: boolean;\n requiredStableFrames: number;\n requireBrightEnvironment: boolean;\n faceCenter: Array<number>;\n onFaceCaptureAnalyzedImage: (\n faceCaptureResult: NativeFaceCaptureResult\n ) => void;\n onFaceCaptureImageAnalysisFailed: (\n faceCaptureAnalysisFailure: NativeFaceCaptureAnalysisFailure\n ) => void;\n onFaceCaptureStateChanged: (faceCaptureState: NativeFaceCaptureState) => void;\n onFaceCaptureStateFailed: (\n faceCaptureStateFailure: NativeFaceCaptureStateFailure\n ) => void;\n}\n\nconst YotiFaceCaptureView = requireNativeComponent<NativeFaceCaptureViewIOS>(\n 'YotiFaceCaptureView'\n);\n\nexport default class RNYotiCapture extends React.Component<ComponentProps> {\n _faceCaptureHandle: number | null;\n\n constructor(props: ComponentProps) {\n super(props);\n this._faceCaptureHandle = null;\n }\n\n _setReference = (ref: any) => {\n if (ref) {\n this._faceCaptureHandle = findNodeHandle(ref);\n } else {\n this._faceCaptureHandle = null;\n }\n };\n\n startAnalyzing() {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(this),\n UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands\n .startAnalyzing,\n []\n );\n }\n\n stopAnalyzing() {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(this),\n UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands\n .stopAnalyzing,\n []\n );\n }\n\n public startCamera = () => {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(this._faceCaptureHandle),\n UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands\n .startCamera,\n []\n );\n };\n\n stopCamera() {\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(this._faceCaptureHandle),\n UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands.stopCamera,\n []\n );\n }\n\n render() {\n const {\n requireEyesOpen = false,\n requireValidAngle = false,\n requiredStableFrames = 3,\n requireBrightEnvironment = true,\n imageQuality = IMAGE_QUALITY_MEDIUM,\n faceCenter = [\n 0.5,\n 0.5\n ],\n } = this.props;\n return (\n <YotiFaceCaptureView\n {...this.props}\n requireEyesOpen={requireEyesOpen}\n requireValidAngle={requireValidAngle}\n requiredStableFrames={requiredStableFrames}\n requireBrightEnvironment={requireBrightEnvironment}\n imageQuality={imageQuality}\n faceCenter={faceCenter}\n onFaceCaptureAnalyzedImage={({\n nativeEvent: faceCaptureResult,\n }: NativeFaceCaptureResult) =>\n this.props.onFaceCaptureAnalyzedImage(faceCaptureResult)\n }\n onFaceCaptureImageAnalysisFailed={({\n nativeEvent: faceCaptureAnalysisFailure,\n }: NativeFaceCaptureAnalysisFailure) =>\n this.props.onFaceCaptureImageAnalysisFailed(\n faceCaptureAnalysisFailure\n )\n }\n onFaceCaptureStateChanged={({\n nativeEvent: { state: faceCaptureState },\n }: NativeFaceCaptureState) =>\n this.props.onFaceCaptureStateChanged(faceCaptureState)\n }\n onFaceCaptureStateFailed={({\n nativeEvent: { state: faceCaptureStateFailure },\n }: NativeFaceCaptureStateFailure) =>\n this.props.onFaceCaptureStateFailed(faceCaptureStateFailure)\n }\n ref={this._setReference}\n />\n );\n }\n}\n"]}
1
+ {"version":3,"names":["React","forwardRef","useCallback","useImperativeHandle","useRef","findNodeHandle","requireNativeComponent","UIManager","IMAGE_QUALITY_MEDIUM","YotiFaceCaptureView","RNYotiCapture","props","ref","requireEyesOpen","requireValidAngle","requiredStableFrames","requireBrightEnvironment","imageQuality","faceCenter","onFaceCaptureAnalyzedImage","onFaceCaptureImageAnalysisFailed","onFaceCaptureStateChanged","onFaceCaptureStateFailed","faceCaptureHandleRef","setReference","nativeRef","current","startAnalyzing","dispatchViewManagerCommand","getViewManagerConfig","Commands","stopAnalyzing","startCamera","stopCamera","handleFaceCaptureAnalyzedImage","nativeEvent","faceCaptureResult","handleFaceCaptureImageAnalysisFailed","faceCaptureAnalysisFailure","handleFaceCaptureStateChanged","state","faceCaptureState","handleFaceCaptureStateFailed","faceCaptureStateFailure","createElement","_extends"],"sources":["RNYotiCapture.ios.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport {\n findNodeHandle,\n requireNativeComponent,\n UIManager,\n} from 'react-native';\n\nimport type {\n ANALYSIS_FAILURE_CAUSE,\n ComponentProps,\n FaceCaptureResult,\n FaceCaptureSuccessState,\n FaceCaptureFailureState,\n IMAGE_QUALITY,\n} from './RNYotiCaptureTypes';\n\nimport { IMAGE_QUALITY_MEDIUM } from './RNYotiCaptureTypes';\n\ntype NativeFaceCaptureResult = {\n nativeEvent: FaceCaptureResult;\n};\n\ntype NativeFaceCaptureState = {\n nativeEvent: {\n state: FaceCaptureSuccessState;\n };\n};\n\ntype NativeFaceCaptureStateFailure = {\n nativeEvent: {\n state: FaceCaptureFailureState;\n };\n};\n\ntype NativeFaceCaptureAnalysisFailure = {\n nativeEvent: {\n cause: ANALYSIS_FAILURE_CAUSE;\n originalImage: string;\n };\n};\n\ninterface NativeFaceCaptureViewIOS {\n imageQuality: IMAGE_QUALITY;\n requireEyesOpen: boolean;\n requireValidAngle: boolean;\n requiredStableFrames: number;\n requireBrightEnvironment: boolean;\n faceCenter: Array<number>;\n onFaceCaptureAnalyzedImage: (\n faceCaptureResult: NativeFaceCaptureResult\n ) => void;\n onFaceCaptureImageAnalysisFailed: (\n faceCaptureAnalysisFailure: NativeFaceCaptureAnalysisFailure\n ) => void;\n onFaceCaptureStateChanged: (faceCaptureState: NativeFaceCaptureState) => void;\n onFaceCaptureStateFailed: (\n faceCaptureStateFailure: NativeFaceCaptureStateFailure\n ) => void;\n}\n\nconst YotiFaceCaptureView = requireNativeComponent<NativeFaceCaptureViewIOS>(\n 'YotiFaceCaptureView'\n);\n\nexport type RNYotiCaptureRef = {\n startAnalyzing: () => void;\n stopAnalyzing: () => void;\n startCamera: () => void;\n stopCamera: () => void;\n};\n\nconst RNYotiCapture = forwardRef<RNYotiCaptureRef, ComponentProps>(\n (props, ref) => {\n const {\n requireEyesOpen = false,\n requireValidAngle = false,\n requiredStableFrames = 3,\n requireBrightEnvironment = true,\n imageQuality = IMAGE_QUALITY_MEDIUM,\n faceCenter = [0.5, 0.5],\n onFaceCaptureAnalyzedImage,\n onFaceCaptureImageAnalysisFailed,\n onFaceCaptureStateChanged,\n onFaceCaptureStateFailed,\n } = props;\n\n const faceCaptureHandleRef = useRef<number | null>(null);\n\n const setReference = useCallback((nativeRef: any) => {\n if (nativeRef) {\n faceCaptureHandleRef.current = findNodeHandle(nativeRef);\n } else {\n faceCaptureHandleRef.current = null;\n }\n }, []);\n\n useImperativeHandle(ref, () => ({\n startAnalyzing: () => {\n UIManager.dispatchViewManagerCommand(\n faceCaptureHandleRef.current,\n UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands\n .startAnalyzing,\n []\n );\n },\n stopAnalyzing: () => {\n UIManager.dispatchViewManagerCommand(\n faceCaptureHandleRef.current,\n UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands\n .stopAnalyzing,\n []\n );\n },\n startCamera: () => {\n UIManager.dispatchViewManagerCommand(\n faceCaptureHandleRef.current,\n UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands\n .startCamera,\n []\n );\n },\n stopCamera: () => {\n UIManager.dispatchViewManagerCommand(\n faceCaptureHandleRef.current,\n UIManager.getViewManagerConfig('YotiFaceCaptureView').Commands\n .stopCamera,\n []\n );\n },\n }));\n\n const handleFaceCaptureAnalyzedImage = useCallback(\n ({ nativeEvent: faceCaptureResult }: NativeFaceCaptureResult) => {\n onFaceCaptureAnalyzedImage(faceCaptureResult);\n },\n [onFaceCaptureAnalyzedImage]\n );\n\n const handleFaceCaptureImageAnalysisFailed = useCallback(\n ({\n nativeEvent: faceCaptureAnalysisFailure,\n }: NativeFaceCaptureAnalysisFailure) => {\n onFaceCaptureImageAnalysisFailed(faceCaptureAnalysisFailure);\n },\n [onFaceCaptureImageAnalysisFailed]\n );\n\n const handleFaceCaptureStateChanged = useCallback(\n ({\n nativeEvent: { state: faceCaptureState },\n }: NativeFaceCaptureState) => {\n onFaceCaptureStateChanged(faceCaptureState);\n },\n [onFaceCaptureStateChanged]\n );\n\n const handleFaceCaptureStateFailed = useCallback(\n ({\n nativeEvent: { state: faceCaptureStateFailure },\n }: NativeFaceCaptureStateFailure) => {\n onFaceCaptureStateFailed(faceCaptureStateFailure);\n },\n [onFaceCaptureStateFailed]\n );\n\n return (\n <YotiFaceCaptureView\n {...props}\n requireEyesOpen={requireEyesOpen}\n requireValidAngle={requireValidAngle}\n requiredStableFrames={requiredStableFrames}\n requireBrightEnvironment={requireBrightEnvironment}\n imageQuality={imageQuality}\n faceCenter={faceCenter}\n onFaceCaptureAnalyzedImage={handleFaceCaptureAnalyzedImage}\n onFaceCaptureImageAnalysisFailed={handleFaceCaptureImageAnalysisFailed}\n onFaceCaptureStateChanged={handleFaceCaptureStateChanged}\n onFaceCaptureStateFailed={handleFaceCaptureStateFailed}\n ref={setReference}\n />\n );\n }\n);\n\nexport default RNYotiCapture;\n"],"mappings":";AAAA,OAAOA,KAAK,IACVC,UAAU,EACVC,WAAW,EACXC,mBAAmB,EACnBC,MAAM,QACD,OAAO;AACd,SACEC,cAAc,EACdC,sBAAsB,EACtBC,SAAS,QACJ,cAAc;AAWrB,SAASC,oBAAoB,QAAQ,sBAAsB;AA4C3D,MAAMC,mBAAmB,GAAGH,sBAAsB,CAChD,qBACF,CAAC;AASD,MAAMI,aAAa,gBAAGT,UAAU,CAC9B,CAACU,KAAK,EAAEC,GAAG,KAAK;EACd,MAAM;IACJC,eAAe,GAAG,KAAK;IACvBC,iBAAiB,GAAG,KAAK;IACzBC,oBAAoB,GAAG,CAAC;IACxBC,wBAAwB,GAAG,IAAI;IAC/BC,YAAY,GAAGT,oBAAoB;IACnCU,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;IACvBC,0BAA0B;IAC1BC,gCAAgC;IAChCC,yBAAyB;IACzBC;EACF,CAAC,GAAGX,KAAK;EAET,MAAMY,oBAAoB,GAAGnB,MAAM,CAAgB,IAAI,CAAC;EAExD,MAAMoB,YAAY,GAAGtB,WAAW,CAAEuB,SAA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,WAAW,CACtD,CAAC;IACCiC,WAAW,EAAEG;EACmB,CAAC,KAAK;IACtClB,gCAAgC,CAACkB,0BAA0B,CAAC;EAC9D,CAAC,EACD,CAAClB,gCAAgC,CACnC,CAAC;EAED,MAAMmB,6BAA6B,GAAGrC,WAAW,CAC/C,CAAC;IACCiC,WAAW,EAAE;MAAEK,KAAK,EAAEC;IAAiB;EACjB,CAAC,KAAK;IAC5BpB,yBAAyB,CAACoB,gBAAgB,CAAC;EAC7C,CAAC,EACD,CAACpB,yBAAyB,CAC5B,CAAC;EAED,MAAMqB,4BAA4B,GAAGxC,WAAW,CAC9C,CAAC;IACCiC,WAAW,EAAE;MAAEK,KAAK,EAAEG;IAAwB;EACjB,CAAC,KAAK;IACnCrB,wBAAwB,CAACqB,uBAAuB,CAAC;EACnD,CAAC,EACD,CAACrB,wBAAwB,CAC3B,CAAC;EAED,oBACEtB,KAAA,CAAA4C,aAAA,CAACnC,mBAAmB,EAAAoC,QAAA,KACdlC,KAAK;IACTE,eAAe,EAAEA,eAAgB;IACjCC,iBAAiB,EAAEA,iBAAkB;IACrCC,oBAAoB,EAAEA,oBAAqB;IAC3CC,wBAAwB,EAAEA,wBAAyB;IACnDC,YAAY,EAAEA,YAAa;IAC3BC,UAAU,EAAEA,UAAW;IACvBC,0BAA0B,EAAEe,8BAA+B;IAC3Dd,gCAAgC,EAAEiB,oCAAqC;IACvEhB,yBAAyB,EAAEkB,6BAA8B;IACzDjB,wBAAwB,EAAEoB,4BAA6B;IACvD9B,GAAG,EAAEY;EAAa,EACnB,CAAC;AAEN,CACF,CAAC;AAED,eAAed,aAAa","ignoreList":[]}
@@ -4,9 +4,9 @@ let qualityConstants = {
4
4
  IMAGE_QUALITY_MEDIUM: 0,
5
5
  IMAGE_QUALITY_HIGH: 0
6
6
  };
7
-
8
7
  if (Platform.OS === 'ios') {
9
- const iOSConstants = // @ts-ignore UIManagerStatic
8
+ const iOSConstants =
9
+ // @ts-ignore UIManagerStatic
10
10
  UIManager.YotiFaceCaptureView.Constants;
11
11
  qualityConstants.IMAGE_QUALITY_LOW = iOSConstants.IMAGE_QUALITY_LOW;
12
12
  qualityConstants.IMAGE_QUALITY_MEDIUM = iOSConstants.IMAGE_QUALITY_MEDIUM;
@@ -18,15 +18,13 @@ if (Platform.OS === 'ios') {
18
18
  qualityConstants.IMAGE_QUALITY_MEDIUM = androidConstants.IMAGE_QUALITY_MEDIUM;
19
19
  qualityConstants.IMAGE_QUALITY_HIGH = androidConstants.IMAGE_QUALITY_HIGH;
20
20
  }
21
-
22
21
  export let IMAGE_QUALITY_LOW = qualityConstants.IMAGE_QUALITY_LOW;
23
22
  export let IMAGE_QUALITY_MEDIUM = qualityConstants.IMAGE_QUALITY_MEDIUM;
24
23
  export let IMAGE_QUALITY_HIGH = qualityConstants.IMAGE_QUALITY_HIGH;
25
- export let IMAGE_QUALITY;
26
-
27
- (function (IMAGE_QUALITY) {
24
+ export let IMAGE_QUALITY = /*#__PURE__*/function (IMAGE_QUALITY) {
28
25
  IMAGE_QUALITY[IMAGE_QUALITY["IMAGE_QUALITY_HIGH"] = 0] = "IMAGE_QUALITY_HIGH";
29
26
  IMAGE_QUALITY[IMAGE_QUALITY["IMAGE_QUALITY_MEDIUM"] = 1] = "IMAGE_QUALITY_MEDIUM";
30
27
  IMAGE_QUALITY[IMAGE_QUALITY["IMAGE_QUALITY_LOW"] = 2] = "IMAGE_QUALITY_LOW";
31
- })(IMAGE_QUALITY || (IMAGE_QUALITY = {}));
28
+ return IMAGE_QUALITY;
29
+ }({});
32
30
  //# sourceMappingURL=RNYotiCaptureTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["RNYotiCaptureTypes.tsx"],"names":["NativeModules","Platform","UIManager","qualityConstants","IMAGE_QUALITY_LOW","IMAGE_QUALITY_MEDIUM","IMAGE_QUALITY_HIGH","OS","iOSConstants","YotiFaceCaptureView","Constants","YotiFaceCaptureModule","androidConstants","getConstants","IMAGE_QUALITY"],"mappings":"AACA,SACEA,aADF,EAEEC,QAFF,EAIEC,SAJF,QAMO,cANP;AAcA,IAAIC,gBAAgB,GAAG;AACrBC,EAAAA,iBAAiB,EAAE,CADE;AAErBC,EAAAA,oBAAoB,EAAE,CAFD;AAGrBC,EAAAA,kBAAkB,EAAE;AAHC,CAAvB;;AAMA,IAAIL,QAAQ,CAACM,EAAT,KAAgB,KAApB,EAA2B;AACzB,QAAMC,YAA+B,GACnC;AACAN,EAAAA,SAAS,CAACO,mBAAV,CAA8BC,SAFhC;AAGAP,EAAAA,gBAAgB,CAACC,iBAAjB,GAAqCI,YAAY,CAACJ,iBAAlD;AACAD,EAAAA,gBAAgB,CAACE,oBAAjB,GAAwCG,YAAY,CAACH,oBAArD;AACAF,EAAAA,gBAAgB,CAACG,kBAAjB,GAAsCE,YAAY,CAACF,kBAAnD;AACD,CAPD,MAOO;AACL,QAAMK,qBAAqB,GAAGX,aAAa,CAACW,qBAA5C;AACA,QAAMC,gBAAmC,GACvCD,qBAAqB,CAACE,YAAtB,EADF;AAEAV,EAAAA,gBAAgB,CAACC,iBAAjB,GAAqCQ,gBAAgB,CAACR,iBAAtD;AACAD,EAAAA,gBAAgB,CAACE,oBAAjB,GAAwCO,gBAAgB,CAACP,oBAAzD;AACAF,EAAAA,gBAAgB,CAACG,kBAAjB,GAAsCM,gBAAgB,CAACN,kBAAvD;AACD;;AAED,OAAO,IAAIF,iBAAiB,GAAGD,gBAAgB,CAACC,iBAAzC;AACP,OAAO,IAAIC,oBAAoB,GAAGF,gBAAgB,CAACE,oBAA5C;AACP,OAAO,IAAIC,kBAAkB,GAAGH,gBAAgB,CAACG,kBAA1C;AAEP,WAAYQ,aAAZ;;WAAYA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;AAAAA,EAAAA,a,CAAAA,a;GAAAA,a,KAAAA,a","sourcesContent":["import type { Component } from 'react';\nimport {\n NativeModules,\n Platform,\n StyleProp,\n UIManager,\n ViewStyle,\n} from 'react-native';\n\ninterface PlatformConstants {\n IMAGE_QUALITY_LOW: number;\n IMAGE_QUALITY_MEDIUM: number;\n IMAGE_QUALITY_HIGH: number;\n}\n\nlet qualityConstants = {\n IMAGE_QUALITY_LOW: 0,\n IMAGE_QUALITY_MEDIUM: 0,\n IMAGE_QUALITY_HIGH: 0,\n};\n\nif (Platform.OS === 'ios') {\n const iOSConstants: PlatformConstants =\n // @ts-ignore UIManagerStatic\n UIManager.YotiFaceCaptureView.Constants;\n qualityConstants.IMAGE_QUALITY_LOW = iOSConstants.IMAGE_QUALITY_LOW;\n qualityConstants.IMAGE_QUALITY_MEDIUM = iOSConstants.IMAGE_QUALITY_MEDIUM;\n qualityConstants.IMAGE_QUALITY_HIGH = iOSConstants.IMAGE_QUALITY_HIGH;\n} else {\n const YotiFaceCaptureModule = NativeModules.YotiFaceCaptureModule;\n const androidConstants: PlatformConstants =\n YotiFaceCaptureModule.getConstants();\n qualityConstants.IMAGE_QUALITY_LOW = androidConstants.IMAGE_QUALITY_LOW;\n qualityConstants.IMAGE_QUALITY_MEDIUM = androidConstants.IMAGE_QUALITY_MEDIUM;\n qualityConstants.IMAGE_QUALITY_HIGH = androidConstants.IMAGE_QUALITY_HIGH;\n}\n\nexport let IMAGE_QUALITY_LOW = qualityConstants.IMAGE_QUALITY_LOW;\nexport let IMAGE_QUALITY_MEDIUM = qualityConstants.IMAGE_QUALITY_MEDIUM;\nexport let IMAGE_QUALITY_HIGH = qualityConstants.IMAGE_QUALITY_HIGH;\n\nexport enum IMAGE_QUALITY {\n IMAGE_QUALITY_HIGH,\n IMAGE_QUALITY_MEDIUM,\n IMAGE_QUALITY_LOW,\n}\n\nexport type FaceCaptureResult = {\n croppedImage: string;\n croppedFaceBoundingBox: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n faceBoundingBox: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n originalImage: string;\n};\n\nexport type ANALYSIS_FAILURE_CAUSE =\n | 'FaceCaptureAnalysisErrorFaceTooBig'\n | 'FaceCaptureAnalysisErrorEyesNotOpen'\n | 'FaceCaptureAnalysisErrorFaceTooSmall'\n | 'FaceCaptureAnalysisErrorFaceNotStable'\n | 'FaceCaptureAnalysisErrorNoFaceDetected'\n | 'FaceCaptureAnalysisErrorFaceNotCentered'\n | 'FaceCaptureAnalysisErrorFaceNotStraight'\n | 'FaceCaptureAnalysisErrorEnvironmentTooDark'\n | 'FaceCaptureAnalysisErrorFaceAnalysisFailed'\n | 'FaceCaptureAnalysisErrorMultipleFaces';\n\nexport type FaceCaptureAnalysisFailure = {\n cause: ANALYSIS_FAILURE_CAUSE;\n originalImage: string;\n};\n\nexport type FaceCaptureSuccessState =\n | 'FaceCaptureStateAnalyzing'\n | 'FaceCaptureStateCameraReady'\n | 'FaceCaptureStateCameraStopped';\n\nexport type FaceCaptureFailureState =\n | 'FaceCaptureStateErrorCameraInitializingError'\n | 'FaceCaptureStateErrorInvalidState'\n | 'FaceCaptureStateErrorCameraNotAccessible';\n\nexport type ComponentProps = {\n requireEyesOpen?: boolean;\n requireValidAngle?: boolean;\n requiredStableFrames?: number;\n requireBrightEnvironment?: boolean;\n imageQuality?: IMAGE_QUALITY;\n faceCenter?: Array<number>;\n onFaceCaptureAnalyzedImage: (faceCaptureResult: FaceCaptureResult) => void;\n onFaceCaptureImageAnalysisFailed: (\n faceCaptureAnalysisFailure: FaceCaptureAnalysisFailure\n ) => void;\n onFaceCaptureStateChanged: (\n faceCaptureState: FaceCaptureSuccessState\n ) => void;\n onFaceCaptureStateFailed: (\n faceCaptureStateFailure: FaceCaptureFailureState\n ) => void;\n style?: StyleProp<ViewStyle>;\n ref: Component;\n};\n"]}
1
+ {"version":3,"names":["NativeModules","Platform","UIManager","qualityConstants","IMAGE_QUALITY_LOW","IMAGE_QUALITY_MEDIUM","IMAGE_QUALITY_HIGH","OS","iOSConstants","YotiFaceCaptureView","Constants","YotiFaceCaptureModule","androidConstants","getConstants","IMAGE_QUALITY"],"sources":["RNYotiCaptureTypes.tsx"],"sourcesContent":["import type { Component } from 'react';\nimport {\n NativeModules,\n Platform,\n StyleProp,\n UIManager,\n ViewStyle,\n} from 'react-native';\n\ninterface PlatformConstants {\n IMAGE_QUALITY_LOW: number;\n IMAGE_QUALITY_MEDIUM: number;\n IMAGE_QUALITY_HIGH: number;\n}\n\nlet qualityConstants = {\n IMAGE_QUALITY_LOW: 0,\n IMAGE_QUALITY_MEDIUM: 0,\n IMAGE_QUALITY_HIGH: 0,\n};\n\nif (Platform.OS === 'ios') {\n const iOSConstants: PlatformConstants =\n // @ts-ignore UIManagerStatic\n UIManager.YotiFaceCaptureView.Constants;\n qualityConstants.IMAGE_QUALITY_LOW = iOSConstants.IMAGE_QUALITY_LOW;\n qualityConstants.IMAGE_QUALITY_MEDIUM = iOSConstants.IMAGE_QUALITY_MEDIUM;\n qualityConstants.IMAGE_QUALITY_HIGH = iOSConstants.IMAGE_QUALITY_HIGH;\n} else {\n const YotiFaceCaptureModule = NativeModules.YotiFaceCaptureModule;\n const androidConstants: PlatformConstants =\n YotiFaceCaptureModule.getConstants();\n qualityConstants.IMAGE_QUALITY_LOW = androidConstants.IMAGE_QUALITY_LOW;\n qualityConstants.IMAGE_QUALITY_MEDIUM = androidConstants.IMAGE_QUALITY_MEDIUM;\n qualityConstants.IMAGE_QUALITY_HIGH = androidConstants.IMAGE_QUALITY_HIGH;\n}\n\nexport let IMAGE_QUALITY_LOW = qualityConstants.IMAGE_QUALITY_LOW;\nexport let IMAGE_QUALITY_MEDIUM = qualityConstants.IMAGE_QUALITY_MEDIUM;\nexport let IMAGE_QUALITY_HIGH = qualityConstants.IMAGE_QUALITY_HIGH;\n\nexport enum IMAGE_QUALITY {\n IMAGE_QUALITY_HIGH,\n IMAGE_QUALITY_MEDIUM,\n IMAGE_QUALITY_LOW,\n}\n\nexport type FaceCaptureResult = {\n croppedImage: string;\n croppedFaceBoundingBox: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n faceBoundingBox: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n originalImage: string;\n};\n\nexport type ANALYSIS_FAILURE_CAUSE =\n | 'FaceCaptureAnalysisErrorFaceTooBig'\n | 'FaceCaptureAnalysisErrorEyesNotOpen'\n | 'FaceCaptureAnalysisErrorFaceTooSmall'\n | 'FaceCaptureAnalysisErrorFaceNotStable'\n | 'FaceCaptureAnalysisErrorNoFaceDetected'\n | 'FaceCaptureAnalysisErrorFaceNotCentered'\n | 'FaceCaptureAnalysisErrorFaceNotStraight'\n | 'FaceCaptureAnalysisErrorEnvironmentTooDark'\n | 'FaceCaptureAnalysisErrorFaceAnalysisFailed'\n | 'FaceCaptureAnalysisErrorMultipleFaces';\n\nexport type FaceCaptureAnalysisFailure = {\n cause: ANALYSIS_FAILURE_CAUSE;\n originalImage: string;\n};\n\nexport type FaceCaptureSuccessState =\n | 'FaceCaptureStateAnalyzing'\n | 'FaceCaptureStateCameraReady'\n | 'FaceCaptureStateCameraStopped';\n\nexport type FaceCaptureFailureState =\n | 'FaceCaptureStateErrorCameraInitializingError'\n | 'FaceCaptureStateErrorInvalidState'\n | 'FaceCaptureStateErrorCameraNotAccessible';\n\nexport type ComponentProps = {\n requireEyesOpen?: boolean;\n requireValidAngle?: boolean;\n requiredStableFrames?: number;\n requireBrightEnvironment?: boolean;\n imageQuality?: IMAGE_QUALITY;\n faceCenter?: Array<number>;\n onFaceCaptureAnalyzedImage: (faceCaptureResult: FaceCaptureResult) => void;\n onFaceCaptureImageAnalysisFailed: (\n faceCaptureAnalysisFailure: FaceCaptureAnalysisFailure\n ) => void;\n onFaceCaptureStateChanged: (\n faceCaptureState: FaceCaptureSuccessState\n ) => void;\n onFaceCaptureStateFailed: (\n faceCaptureStateFailure: FaceCaptureFailureState\n ) => void;\n style?: StyleProp<ViewStyle>;\n ref: Component;\n};\n"],"mappings":"AACA,SACEA,aAAa,EACbC,QAAQ,EAERC,SAAS,QAEJ,cAAc;AAQrB,IAAIC,gBAAgB,GAAG;EACrBC,iBAAiB,EAAE,CAAC;EACpBC,oBAAoB,EAAE,CAAC;EACvBC,kBAAkB,EAAE;AACtB,CAAC;AAED,IAAIL,QAAQ,CAACM,EAAE,KAAK,KAAK,EAAE;EACzB,MAAMC,YAA+B;EACnC;EACAN,SAAS,CAACO,mBAAmB,CAACC,SAAS;EACzCP,gBAAgB,CAACC,iBAAiB,GAAGI,YAAY,CAACJ,iBAAiB;EACnED,gBAAgB,CAACE,oBAAoB,GAAGG,YAAY,CAACH,oBAAoB;EACzEF,gBAAgB,CAACG,kBAAkB,GAAGE,YAAY,CAACF,kBAAkB;AACvE,CAAC,MAAM;EACL,MAAMK,qBAAqB,GAAGX,aAAa,CAACW,qBAAqB;EACjE,MAAMC,gBAAmC,GACvCD,qBAAqB,CAACE,YAAY,CAAC,CAAC;EACtCV,gBAAgB,CAACC,iBAAiB,GAAGQ,gBAAgB,CAACR,iBAAiB;EACvED,gBAAgB,CAACE,oBAAoB,GAAGO,gBAAgB,CAACP,oBAAoB;EAC7EF,gBAAgB,CAACG,kBAAkB,GAAGM,gBAAgB,CAACN,kBAAkB;AAC3E;AAEA,OAAO,IAAIF,iBAAiB,GAAGD,gBAAgB,CAACC,iBAAiB;AACjE,OAAO,IAAIC,oBAAoB,GAAGF,gBAAgB,CAACE,oBAAoB;AACvE,OAAO,IAAIC,kBAAkB,GAAGH,gBAAgB,CAACG,kBAAkB;AAEnE,WAAYQ,aAAa,0BAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  // @ts-ignore
2
2
  import RNYotiCapture from './RNYotiCapture';
3
+ export { IMAGE_QUALITY_LOW, IMAGE_QUALITY_MEDIUM, IMAGE_QUALITY_HIGH } from './RNYotiCaptureTypes';
3
4
  export default RNYotiCapture;
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["RNYotiCapture"],"mappings":"AAAA;AACA,OAAOA,aAAP,MAA0B,iBAA1B;AAEA,eAAeA,aAAf","sourcesContent":["// @ts-ignore\nimport RNYotiCapture from './RNYotiCapture';\n\nexport default RNYotiCapture;\n"]}
1
+ {"version":3,"names":["RNYotiCapture","IMAGE_QUALITY_LOW","IMAGE_QUALITY_MEDIUM","IMAGE_QUALITY_HIGH"],"sources":["index.tsx"],"sourcesContent":["// @ts-ignore\nimport RNYotiCapture from './RNYotiCapture';\n\nexport {\n IMAGE_QUALITY_LOW,\n IMAGE_QUALITY_MEDIUM,\n IMAGE_QUALITY_HIGH,\n} from './RNYotiCaptureTypes';\n\nexport default RNYotiCapture;\n"],"mappings":"AAAA;AACA,OAAOA,aAAa,MAAM,iBAAiB;AAE3C,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,kBAAkB,QACb,sBAAsB;AAE7B,eAAeH,aAAa","ignoreList":[]}
@@ -1,49 +1,10 @@
1
1
  import React from 'react';
2
2
  import type { ComponentProps } from './RNYotiCaptureTypes';
3
- declare type NativeCaptureResultState = 'ValidFace' | 'InvalidFace';
4
- declare type NATIVE_ANALYSIS_FAILURE_CAUSE = 'FaceTooBig' | 'EyesClosed' | 'FaceTooSmall' | 'FaceNotStable' | 'NoFaceDetected' | 'FaceNotCentered' | 'FaceNotStraight' | 'EnvironmentTooDark' | 'AnalysisError' | 'MultipleFacesDetected';
5
- declare type NativeCaptureResult = {
6
- nativeEvent: {
7
- cause?: NATIVE_ANALYSIS_FAILURE_CAUSE;
8
- croppedImage?: string;
9
- croppedFaceBoundingBox?: {
10
- x: number;
11
- y: number;
12
- width: number;
13
- height: number;
14
- };
15
- faceBoundingBox?: {
16
- x: number;
17
- y: number;
18
- width: number;
19
- height: number;
20
- };
21
- originalImage?: string;
22
- state: NativeCaptureResultState;
23
- };
3
+ export type RNYotiCaptureRef = {
4
+ startAnalyzing: () => void;
5
+ stopAnalyzing: () => void;
6
+ startCamera: () => void;
7
+ stopCamera: () => void;
24
8
  };
25
- declare type NativeFaceCaptureSuccessState = 'Analyzing' | 'CameraReady' | 'CameraStopped';
26
- declare type NativeFaceCaptureFailureState = 'CameraInitializationError' | 'MissingPermissions';
27
- declare type NativeFaceCaptureState = {
28
- nativeEvent: {
29
- state: NativeFaceCaptureSuccessState;
30
- };
31
- };
32
- declare type NativeFaceCaptureStateFailure = {
33
- nativeEvent: {
34
- state: NativeFaceCaptureFailureState;
35
- };
36
- };
37
- export default class RNYotiCapture extends React.Component<ComponentProps> {
38
- _faceCaptureHandle: number | null;
39
- constructor(props: ComponentProps);
40
- _setReference: (ref: any) => void;
41
- startAnalyzing(): void;
42
- stopAnalyzing(): void;
43
- startCamera(): void;
44
- stopCamera(): void;
45
- onCameraStateChange(cameraState: NativeFaceCaptureState | NativeFaceCaptureStateFailure): void;
46
- onFaceCaptureResult(faceCaptureResult: NativeCaptureResult): void;
47
- render(): JSX.Element;
48
- }
49
- export {};
9
+ declare const RNYotiCapture: React.ForwardRefExoticComponent<Omit<ComponentProps, "ref"> & React.RefAttributes<RNYotiCaptureRef>>;
10
+ export default RNYotiCapture;
@@ -1,12 +1,10 @@
1
1
  import React from 'react';
2
2
  import type { ComponentProps } from './RNYotiCaptureTypes';
3
- export default class RNYotiCapture extends React.Component<ComponentProps> {
4
- _faceCaptureHandle: number | null;
5
- constructor(props: ComponentProps);
6
- _setReference: (ref: any) => void;
7
- startAnalyzing(): void;
8
- stopAnalyzing(): void;
3
+ export type RNYotiCaptureRef = {
4
+ startAnalyzing: () => void;
5
+ stopAnalyzing: () => void;
9
6
  startCamera: () => void;
10
- stopCamera(): void;
11
- render(): JSX.Element;
12
- }
7
+ stopCamera: () => void;
8
+ };
9
+ declare const RNYotiCapture: React.ForwardRefExoticComponent<Omit<ComponentProps, "ref"> & React.RefAttributes<RNYotiCaptureRef>>;
10
+ export default RNYotiCapture;