idmission-web-sdk 2.2.47 → 2.2.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CompositeWizard.d.ts +1 -2
- package/dist/components/CompositeWizard.d.ts.map +1 -1
- package/dist/components/camera/CameraAccessDeniedOverlay.d.ts.map +1 -1
- package/dist/components/camera/CameraVideoTag.d.ts +2 -4
- package/dist/components/camera/CameraVideoTag.d.ts.map +1 -1
- package/dist/components/camera/MicrophoneAccessDeniedOverlay.d.ts.map +1 -1
- package/dist/components/customer_flows/CustomerBiometricsEnrollment.d.ts.map +1 -1
- package/dist/components/customer_flows/CustomerIdAndBiometricsEnrollment.d.ts.map +1 -1
- package/dist/components/customer_flows/CustomerIdentification.d.ts.map +1 -1
- package/dist/components/customer_flows/CustomerVerification.d.ts.map +1 -1
- package/dist/components/customer_flows/DocumentCapture.d.ts.map +1 -1
- package/dist/components/customer_flows/FaceValidation.d.ts.map +1 -1
- package/dist/components/customer_flows/IdAndFaceValidation.d.ts.map +1 -1
- package/dist/components/customer_flows/IdValidation.d.ts.map +1 -1
- package/dist/components/customer_flows/VideoIdValidation.d.ts.map +1 -1
- package/dist/components/customer_identification/CustomerIdentificationWizard.d.ts +1 -1
- package/dist/components/customer_identification/CustomerIdentificationWizard.d.ts.map +1 -1
- package/dist/components/customer_verification/CustomerVerificationWizard.d.ts.map +1 -1
- package/dist/components/document_capture/DocumentCaptureScreen.d.ts.map +1 -1
- package/dist/components/document_capture/DocumentCaptureStateProvider.d.ts.map +1 -1
- package/dist/components/face_liveness/FaceLivenessWizard.d.ts.map +1 -1
- package/dist/components/id_capture/DocumentDetectionModelProvider.d.ts.map +1 -1
- package/dist/components/id_capture/FocusModelProvider.d.ts.map +1 -1
- package/dist/components/id_capture/IdCapture.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureGuides.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureLoadingOverlayDefault.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureLoadingOverlayLegacy.d.ts.map +1 -1
- package/dist/components/id_capture/IdCaptureWizard.d.ts.map +1 -1
- package/dist/components/selfie_capture/SelfieCapture.d.ts.map +1 -1
- package/dist/components/selfie_capture/SelfieCaptureLoadingOverlayDefault.d.ts.map +1 -1
- package/dist/components/selfie_capture/SelfieCaptureLoadingOverlayLegacy.d.ts.map +1 -1
- package/dist/components/selfie_capture/SelfieGuidanceModelsProvider.d.ts.map +1 -1
- package/dist/components/video_id/IdVideoCapture.d.ts.map +1 -1
- package/dist/components/video_id/IdVideoCaptureFlipIdPrompt.d.ts.map +1 -1
- package/dist/components/video_id/IdVideoCaptureGuides.d.ts.map +1 -1
- package/dist/components/video_id/IdVideoCaptureWizard.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureCapture.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts.map +1 -1
- package/dist/lib/camera/Camera.d.ts +4 -0
- package/dist/lib/camera/Camera.d.ts.map +1 -1
- package/dist/lib/camera/cameraStore.d.ts +52 -0
- package/dist/lib/camera/cameraStore.d.ts.map +1 -0
- package/dist/lib/camera/videoRefStack.d.ts +6 -0
- package/dist/lib/camera/videoRefStack.d.ts.map +1 -0
- package/dist/lib/models/DocumentDetection.d.ts +3 -1
- package/dist/lib/models/DocumentDetection.d.ts.map +1 -1
- package/dist/lib/models/FaceDetection.d.ts +3 -1
- package/dist/lib/models/FaceDetection.d.ts.map +1 -1
- package/dist/lib/models/Focus.d.ts +3 -1
- package/dist/lib/models/Focus.d.ts.map +1 -1
- package/dist/sdk2.cjs.development.js +1031 -1089
- package/dist/sdk2.cjs.development.js.map +1 -1
- package/dist/sdk2.cjs.production.js +1 -1
- package/dist/sdk2.cjs.production.js.map +1 -1
- package/dist/sdk2.esm.js +1031 -1089
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +1155 -1087
- package/dist/sdk2.umd.development.js.map +1 -1
- package/dist/sdk2.umd.production.js +1 -1
- package/dist/sdk2.umd.production.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +5 -4
- package/dist/components/camera/CameraProvider.d.ts +0 -17
- package/dist/components/camera/CameraProvider.d.ts.map +0 -1
|
@@ -9,10 +9,12 @@ var tusJsClient = require('tus-js-client');
|
|
|
9
9
|
var SparkMD5 = require('spark-md5');
|
|
10
10
|
var useResizeObserver = require('use-resize-observer');
|
|
11
11
|
var tasksVision = require('@mediapipe/tasks-vision');
|
|
12
|
+
var zustand = require('zustand');
|
|
12
13
|
var useDebounce = require('use-debounce');
|
|
13
14
|
var reactDom = require('react-dom');
|
|
14
15
|
var LanguageDetector = require('i18next-browser-languagedetector');
|
|
15
16
|
var i18n = require('i18next');
|
|
17
|
+
var shallow = require('zustand/react/shallow');
|
|
16
18
|
var SignatureCanvas = require('react-signature-canvas');
|
|
17
19
|
|
|
18
20
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -232,7 +234,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
232
234
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
233
235
|
};
|
|
234
236
|
|
|
235
|
-
var webSdkVersion = '2.2.
|
|
237
|
+
var webSdkVersion = '2.2.49';
|
|
236
238
|
|
|
237
239
|
function getPlatform() {
|
|
238
240
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -801,11 +803,11 @@ function setDefaultAuthUrl(url) {
|
|
|
801
803
|
if (!allowedAuthUrls.includes(url)) throw new Error('invalid auth url');
|
|
802
804
|
exports.defaultAuthUrl = url;
|
|
803
805
|
}
|
|
804
|
-
var initialState$
|
|
806
|
+
var initialState$6 = {
|
|
805
807
|
authUrl: exports.defaultAuthUrl,
|
|
806
808
|
sessionCheckState: 'READY'
|
|
807
809
|
};
|
|
808
|
-
var AuthStateContext = /*#__PURE__*/React.createContext(initialState$
|
|
810
|
+
var AuthStateContext = /*#__PURE__*/React.createContext(initialState$6);
|
|
809
811
|
var AuthDispatchContext = /*#__PURE__*/React.createContext(function () {});
|
|
810
812
|
var reducer$4 = function reducer(state, action) {
|
|
811
813
|
switch (action.type) {
|
|
@@ -837,7 +839,7 @@ function useAuthReducer(authUrl, sessionId) {
|
|
|
837
839
|
if (authUrl === void 0) {
|
|
838
840
|
authUrl = exports.defaultAuthUrl;
|
|
839
841
|
}
|
|
840
|
-
var _a = React.useReducer(reducer$4, _assign(_assign({}, initialState$
|
|
842
|
+
var _a = React.useReducer(reducer$4, _assign(_assign({}, initialState$6), {
|
|
841
843
|
authUrl: authUrl
|
|
842
844
|
})),
|
|
843
845
|
state = _a[0],
|
|
@@ -1918,608 +1920,6 @@ function calculateMd5(blob) {
|
|
|
1918
1920
|
});
|
|
1919
1921
|
}
|
|
1920
1922
|
|
|
1921
|
-
function getFrameDimensions(frame) {
|
|
1922
|
-
var frameWidth = frame.width,
|
|
1923
|
-
frameHeight = frame.height;
|
|
1924
|
-
if (frame instanceof HTMLImageElement) {
|
|
1925
|
-
frameWidth = frame.naturalWidth;
|
|
1926
|
-
frameHeight = frame.naturalHeight;
|
|
1927
|
-
}
|
|
1928
|
-
if (frame instanceof HTMLVideoElement) {
|
|
1929
|
-
frameWidth = frame.videoWidth;
|
|
1930
|
-
frameHeight = frame.videoHeight;
|
|
1931
|
-
}
|
|
1932
|
-
return [frameWidth, frameHeight];
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
var InvisibleCanvas = styled__default.default.canvas(templateObject_1$G || (templateObject_1$G = __makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
|
|
1936
|
-
function drawToCanvas(canvas, frame, width, height) {
|
|
1937
|
-
if (!canvas) return;
|
|
1938
|
-
var ctx = canvas.getContext('2d');
|
|
1939
|
-
if (!ctx) return;
|
|
1940
|
-
if (!width || !height) {
|
|
1941
|
-
var _a = getFrameDimensions(frame),
|
|
1942
|
-
frameWidth = _a[0],
|
|
1943
|
-
frameHeight = _a[1];
|
|
1944
|
-
width || (width = frameWidth);
|
|
1945
|
-
height || (height = frameHeight);
|
|
1946
|
-
}
|
|
1947
|
-
canvas.width = width;
|
|
1948
|
-
canvas.height = height;
|
|
1949
|
-
ctx.drawImage(frame, 0, 0, width, height);
|
|
1950
|
-
}
|
|
1951
|
-
function clearCanvas(canvas) {
|
|
1952
|
-
var _a;
|
|
1953
|
-
(_a = canvas === null || canvas === void 0 ? void 0 : canvas.getContext('2d')) === null || _a === void 0 ? void 0 : _a.clearRect(0, 0, canvas === null || canvas === void 0 ? void 0 : canvas.width, canvas === null || canvas === void 0 ? void 0 : canvas.height);
|
|
1954
|
-
}
|
|
1955
|
-
var templateObject_1$G;
|
|
1956
|
-
|
|
1957
|
-
function listAvailableCameras(facingMode_1) {
|
|
1958
|
-
return __awaiter(this, arguments, void 0, function (facingMode, requestMicAccess) {
|
|
1959
|
-
var cameraEnumerationStream, videoDevices;
|
|
1960
|
-
if (requestMicAccess === void 0) {
|
|
1961
|
-
requestMicAccess = false;
|
|
1962
|
-
}
|
|
1963
|
-
return __generator(this, function (_a) {
|
|
1964
|
-
switch (_a.label) {
|
|
1965
|
-
case 0:
|
|
1966
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
1967
|
-
video: {
|
|
1968
|
-
facingMode: {
|
|
1969
|
-
exact: facingMode
|
|
1970
|
-
}
|
|
1971
|
-
},
|
|
1972
|
-
audio: requestMicAccess
|
|
1973
|
-
})
|
|
1974
|
-
// This lists all available cameras attached to the user's device.
|
|
1975
|
-
];
|
|
1976
|
-
case 1:
|
|
1977
|
-
cameraEnumerationStream = _a.sent();
|
|
1978
|
-
return [4 /*yield*/, navigator.mediaDevices.enumerateDevices()];
|
|
1979
|
-
case 2:
|
|
1980
|
-
videoDevices = _a.sent().filter(function (_a) {
|
|
1981
|
-
var kind = _a.kind;
|
|
1982
|
-
return kind === 'videoinput';
|
|
1983
|
-
});
|
|
1984
|
-
// Release the access to the user's camera that we obtained for enumeration purposes.
|
|
1985
|
-
cameraEnumerationStream.getVideoTracks().forEach(function (track) {
|
|
1986
|
-
track.enabled = false;
|
|
1987
|
-
track.stop();
|
|
1988
|
-
});
|
|
1989
|
-
cameraEnumerationStream = null;
|
|
1990
|
-
return [2 /*return*/, videoDevices];
|
|
1991
|
-
}
|
|
1992
|
-
});
|
|
1993
|
-
});
|
|
1994
|
-
}
|
|
1995
|
-
var frontLabels = ['front', 'avant', 'anteriore', 'cameraaanvoorzijde', 'kamerapåframsidan', 'forsidekamera', 'kamerapåforsiden', 'aparatprzedni', 'etukamera', 'kameradepan', 'ÖnKamera', 'cameramặttrước', 'camerăfață', 'prednákamera', 'prednjakamera', 'előlapikamera', 'přednífotoaparát', 'μπροστινήκάμερα', 'переднякамера', 'передняякамера', 'преднакамера', 'алдыңғыкамера', 'מצלמה קדמית', 'الكاميرا الأمامية', 'फ़्रंटकैमरा', '前置相机', '前置鏡頭', '前面カメラ', '전면카메라', 'กล้องด้านหน้า'].map(function (s) {
|
|
1996
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
1997
|
-
});
|
|
1998
|
-
var rearLabels = ['back', 'rear', 'posterior', 'trasera', 'traseira', 'arrière', 'rückkamera', 'fotocamera(posteriore)', 'cameraaanachterzijde', 'kamerapåbaksidan', 'kamerapåbaksiden', 'bagsidekamera', 'aparattylny', 'takakamera', 'arkakamera', 'kamerabelakang', 'cameramặtsau', 'camerăspate', 'stražnjakamera', 'zadnákamera', 'hátoldalikamera', 'zadnífotoaparát', 'πίσωκάμερα', 'заднякамера', 'Задняякамера', 'заднакамера', 'артқыкамера', 'מצלמה אחורית', 'الكاميرا الخلفية', 'बैककैमरा', '后置相机', '後置鏡頭', '背面カメラ', '후면카메라', 'กล้องด้านหลัง'].map(function (s) {
|
|
1999
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
2000
|
-
});
|
|
2001
|
-
var backUltraWideLabels = ['backdualwidecamera', 'backultrawidecamera', 'ultraampliaposterior', 'ultra-angulartraseira', 'ultragrandeangulartraseira', 'ultragrandangle', 'ultragranangular', 'ultra-weitwinkelkamera', 'ultra-grandangolo', 'ultrabredecameraaanachterzijde', 'ultravidvinkelkamerapåbaksidan', 'ultravidvinkelkameraetpåbagsiden', 'ultravidvinkelkamerabak', 'ultragenişkameraarkayüzü', 'ultralaajakulmainentakakamera', 'tylnyaparatultraszerokokątny', 'cameracựcrộngmặtsau', 'camerăcuobiectivultra‑superangularspate', 'ultraszéleslátószögűkamera', 'kameraultralebarbelakang', 'stražnjaultraširokakamera', 'zadníultraširokoúhlýfotoaparát', 'ultraširokouhlá', 'πίσωυπερευρείακάμερα', 'заднянадширококутнакамера', 'Задняясверхширокоугольнаякамера', 'Задна свръх широкоъгълна камера', 'артқыультракеңбұрыштыкамера', 'מצלמה אולטרה רחבה אחורית', 'كاميرا خلفية عريضة جدًا', 'बैकअल्ट्रावाइडकैमरा', '后置超广角相机', '後置超廣角鏡頭相機', '背面超広角カメラ', '후면울트라와이드카메라', 'กล้องด้านหลังอัลตร้าไวด์'].map(function (s) {
|
|
2002
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
2003
|
-
});
|
|
2004
|
-
var labelMatches = function labelMatches(labelOrDevice, labelSetOrLabel) {
|
|
2005
|
-
var label = labelOrDevice instanceof MediaDeviceInfo ? getDeviceLabel(labelOrDevice) : labelOrDevice;
|
|
2006
|
-
var labelSet = typeof labelSetOrLabel === 'string' ? [labelSetOrLabel] : labelSetOrLabel;
|
|
2007
|
-
return labelSet.some(function (l) {
|
|
2008
|
-
return label.includes(l);
|
|
2009
|
-
});
|
|
2010
|
-
};
|
|
2011
|
-
var getDeviceLabel = function getDeviceLabel(deviceInfo) {
|
|
2012
|
-
return deviceInfo.label.toLocaleLowerCase().split(' ').join('');
|
|
2013
|
-
};
|
|
2014
|
-
var currentCamera;
|
|
2015
|
-
var currentAudioStream;
|
|
2016
|
-
function obtainCameraAccess(stream, deviceLabel, video) {
|
|
2017
|
-
releaseCameraAccess();
|
|
2018
|
-
log('obtaining camera access...');
|
|
2019
|
-
var _a = stream.getVideoTracks()[0].getSettings(),
|
|
2020
|
-
width = _a.width,
|
|
2021
|
-
height = _a.height;
|
|
2022
|
-
var label = deviceLabel.toLocaleLowerCase().split(' ').join('');
|
|
2023
|
-
var isRearFacing = labelMatches(label, __spreadArray(__spreadArray(__spreadArray([], rearLabels, true), backUltraWideLabels, true), ['iphone'], false));
|
|
2024
|
-
var release = function release() {
|
|
2025
|
-
stream.getTracks().forEach(function (track) {
|
|
2026
|
-
track.enabled = false;
|
|
2027
|
-
track.stop();
|
|
2028
|
-
});
|
|
2029
|
-
if (video) {
|
|
2030
|
-
video.pause();
|
|
2031
|
-
video.srcObject = null;
|
|
2032
|
-
video.src = '';
|
|
2033
|
-
}
|
|
2034
|
-
};
|
|
2035
|
-
width || (width = 0);
|
|
2036
|
-
height || (height = 0);
|
|
2037
|
-
currentCamera = {
|
|
2038
|
-
label: deviceLabel,
|
|
2039
|
-
stream: stream,
|
|
2040
|
-
width: width,
|
|
2041
|
-
height: height,
|
|
2042
|
-
isRearFacing: isRearFacing,
|
|
2043
|
-
release: release
|
|
2044
|
-
};
|
|
2045
|
-
if (video) video.srcObject = stream;
|
|
2046
|
-
return currentCamera;
|
|
2047
|
-
}
|
|
2048
|
-
function releaseCameraAccess() {
|
|
2049
|
-
if (!currentCamera) return;
|
|
2050
|
-
log('releasing camera access...');
|
|
2051
|
-
currentCamera.release();
|
|
2052
|
-
currentCamera = undefined;
|
|
2053
|
-
}
|
|
2054
|
-
function releaseMicrophoneAccess() {
|
|
2055
|
-
var _a;
|
|
2056
|
-
if (!currentAudioStream) return;
|
|
2057
|
-
log('releasing microphone access...');
|
|
2058
|
-
(_a = currentAudioStream.stop) === null || _a === void 0 ? void 0 : _a.call(currentAudioStream);
|
|
2059
|
-
currentAudioStream.getAudioTracks().forEach(function (t) {
|
|
2060
|
-
var _a;
|
|
2061
|
-
(_a = t.stop) === null || _a === void 0 ? void 0 : _a.call(t);
|
|
2062
|
-
});
|
|
2063
|
-
currentAudioStream = undefined;
|
|
2064
|
-
}
|
|
2065
|
-
function usePreferredCaptureDevice(_a) {
|
|
2066
|
-
var _b = _a === void 0 ? {} : _a,
|
|
2067
|
-
_c = _b.requestAccessAutomatically,
|
|
2068
|
-
requestAccessAutomatically = _c === void 0 ? true : _c,
|
|
2069
|
-
_d = _b.preferFrontFacingCamera,
|
|
2070
|
-
preferFrontFacingCamera = _d === void 0 ? false : _d,
|
|
2071
|
-
_e = _b.preferContinuityCamera,
|
|
2072
|
-
preferContinuityCamera = _e === void 0 ? true : _e,
|
|
2073
|
-
_f = _b.requireMicrophoneAccess,
|
|
2074
|
-
requireMicrophoneAccess = _f === void 0 ? false : _f,
|
|
2075
|
-
_g = _b.maxVideoWidth,
|
|
2076
|
-
maxVideoWidth = _g === void 0 ? 1920 : _g,
|
|
2077
|
-
maxFps = _b.maxFps,
|
|
2078
|
-
_h = _b.debugMode,
|
|
2079
|
-
debugMode = _h === void 0 ? false : _h;
|
|
2080
|
-
var videoRef = React.useRef(null);
|
|
2081
|
-
var videoRefStack = React.useRef([]);
|
|
2082
|
-
var cameraRef = React.useRef(null);
|
|
2083
|
-
var _j = React.useState(false),
|
|
2084
|
-
cameraReady = _j[0],
|
|
2085
|
-
setCameraReady = _j[1];
|
|
2086
|
-
var _k = React.useState(false),
|
|
2087
|
-
microphoneReady = _k[0],
|
|
2088
|
-
setMicrophoneReady = _k[1];
|
|
2089
|
-
var _l = React.useState(null),
|
|
2090
|
-
videoDevice = _l[0],
|
|
2091
|
-
setVideoDevice = _l[1];
|
|
2092
|
-
var _m = React.useState(null),
|
|
2093
|
-
audioStream = _m[0],
|
|
2094
|
-
setAudioStream = _m[1];
|
|
2095
|
-
var _o = React.useState(false),
|
|
2096
|
-
videoLoaded = _o[0],
|
|
2097
|
-
setVideoLoaded = _o[1];
|
|
2098
|
-
var _p = React.useState(false),
|
|
2099
|
-
iphoneContinuityCameraAvailable = _p[0],
|
|
2100
|
-
setIphoneContinuityCameraAvailable = _p[1];
|
|
2101
|
-
var _q = React.useState(preferContinuityCamera),
|
|
2102
|
-
iphoneContinuityCameraAllowed = _q[0],
|
|
2103
|
-
setIphoneContinuityCameraAllowed = _q[1];
|
|
2104
|
-
var _r = React.useState(false),
|
|
2105
|
-
iphoneContinuityCameraDenied = _r[0],
|
|
2106
|
-
setIphoneContinuityCameraDenied = _r[1];
|
|
2107
|
-
var _s = React.useState(false),
|
|
2108
|
-
cameraAccessDenied = _s[0],
|
|
2109
|
-
setCameraAccessDenied = _s[1];
|
|
2110
|
-
var _t = React.useState(false),
|
|
2111
|
-
microphoneAccessDenied = _t[0],
|
|
2112
|
-
setMicrophoneAccessDenied = _t[1];
|
|
2113
|
-
var videoRefElement = videoRef.current;
|
|
2114
|
-
React.useEffect(function pushVideoRefToStackWhenChanged() {
|
|
2115
|
-
// proceed if the video element being mounted is not already at the top of the videoRefStack.
|
|
2116
|
-
var topOfStack = videoRefStack.current.slice(-1)[0];
|
|
2117
|
-
if (videoRefElement && videoRefElement !== topOfStack) {
|
|
2118
|
-
log('adding video to stack', videoRefElement);
|
|
2119
|
-
videoRefStack.current.push(videoRefElement);
|
|
2120
|
-
}
|
|
2121
|
-
}, [videoRefElement]);
|
|
2122
|
-
var onVideoUnmounted = React.useCallback(function (videoElement) {
|
|
2123
|
-
log('removing video from stack', videoElement);
|
|
2124
|
-
videoRefStack.current = videoRefStack.current.filter(function (v) {
|
|
2125
|
-
return v !== videoElement;
|
|
2126
|
-
});
|
|
2127
|
-
videoRef.current = videoRefStack.current.slice(-1)[0]; // top of stack.
|
|
2128
|
-
log('new videoRef is', videoRef.current);
|
|
2129
|
-
}, []);
|
|
2130
|
-
React.useEffect(function resetCameraOnContinuityPreferenceChanged() {
|
|
2131
|
-
if (debugMode) {
|
|
2132
|
-
log('iphone continuity camera allowed changed', iphoneContinuityCameraAllowed);
|
|
2133
|
-
}
|
|
2134
|
-
releaseCameraAccess();
|
|
2135
|
-
cameraRef.current = null;
|
|
2136
|
-
setVideoLoaded(false);
|
|
2137
|
-
}, [debugMode, iphoneContinuityCameraAllowed]);
|
|
2138
|
-
// NOTE: the bound callback function here is called requestCameraAccess, because
|
|
2139
|
-
// it initiates the useEffect chain that results in camera access being requested
|
|
2140
|
-
// (requestCameraAccessAutomatically -> chooseFromAvailableCameras -> accessChosenCamera).
|
|
2141
|
-
//
|
|
2142
|
-
// We chose to title the inner function "chooseFromAvailableCameras" because
|
|
2143
|
-
// that's all it literally does -- the available cameras are enumerated, and then
|
|
2144
|
-
// the result is parsed to decide which one we like best, which is then passed to
|
|
2145
|
-
// setVideoDevice, which causes accessChosenCamera to trigger.
|
|
2146
|
-
//
|
|
2147
|
-
// I am not a huge fan of getUserMedia's design -- you need to call it twice in order
|
|
2148
|
-
// to select the "best" camera for your application's purposes.
|
|
2149
|
-
var requestCameraAccess = React.useCallback(function chooseFromAvailableCameras() {
|
|
2150
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2151
|
-
var availableCameras, selectedCamera, platform_1, iphoneContinuityCamera, e_1;
|
|
2152
|
-
var _a, _b;
|
|
2153
|
-
return __generator(this, function (_c) {
|
|
2154
|
-
switch (_c.label) {
|
|
2155
|
-
case 0:
|
|
2156
|
-
setCameraReady(false);
|
|
2157
|
-
setCameraAccessDenied(false);
|
|
2158
|
-
_c.label = 1;
|
|
2159
|
-
case 1:
|
|
2160
|
-
_c.trys.push([1, 3,, 4]);
|
|
2161
|
-
return [4 /*yield*/, listAvailableCameras()];
|
|
2162
|
-
case 2:
|
|
2163
|
-
availableCameras = _c.sent();
|
|
2164
|
-
selectedCamera = void 0;
|
|
2165
|
-
if (debugMode) {
|
|
2166
|
-
log('availableCameras', availableCameras);
|
|
2167
|
-
}
|
|
2168
|
-
platform_1 = getPlatform();
|
|
2169
|
-
if (debugMode) {
|
|
2170
|
-
log('platformDetails', platform_1);
|
|
2171
|
-
}
|
|
2172
|
-
if (!iphoneContinuityCameraDenied && (!(platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) || platform_1.os.family === 'OS X')) {
|
|
2173
|
-
iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
|
|
2174
|
-
return labelMatches(deviceInfo, 'iphone');
|
|
2175
|
-
});
|
|
2176
|
-
setIphoneContinuityCameraAvailable(!!iphoneContinuityCamera);
|
|
2177
|
-
if (iphoneContinuityCamera && iphoneContinuityCameraAllowed) {
|
|
2178
|
-
selectedCamera = iphoneContinuityCamera;
|
|
2179
|
-
}
|
|
2180
|
-
} else if (((_a = platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) === null || _a === void 0 ? void 0 : _a.family) === 'Android' || availableCameras.every(function (c) {
|
|
2181
|
-
return c.label.startsWith('camera2 ');
|
|
2182
|
-
})) {
|
|
2183
|
-
availableCameras = availableCameras.sort(function (a, b) {
|
|
2184
|
-
return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
|
|
2185
|
-
});
|
|
2186
|
-
if (debugMode) {
|
|
2187
|
-
log('cameras have been sorted', availableCameras);
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
if (preferFrontFacingCamera) {
|
|
2191
|
-
selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
2192
|
-
return labelMatches(deviceInfo, frontLabels);
|
|
2193
|
-
});
|
|
2194
|
-
}
|
|
2195
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
2196
|
-
return labelMatches(deviceInfo, 'backtriplecamera');
|
|
2197
|
-
}));
|
|
2198
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
2199
|
-
return labelMatches(deviceInfo, 'backdualcamera');
|
|
2200
|
-
}));
|
|
2201
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
2202
|
-
return labelMatches(deviceInfo, rearLabels) && !labelMatches(deviceInfo, backUltraWideLabels);
|
|
2203
|
-
}));
|
|
2204
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
2205
|
-
return labelMatches(deviceInfo, rearLabels);
|
|
2206
|
-
}));
|
|
2207
|
-
// on iOS, the front facing camera always is at the first position in the list, so we skip it if all else fails.
|
|
2208
|
-
if (!preferFrontFacingCamera && ((_b = platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) === null || _b === void 0 ? void 0 : _b.family) === 'iOS' && availableCameras.length > 0) {
|
|
2209
|
-
selectedCamera || (selectedCamera = availableCameras[1]);
|
|
2210
|
-
}
|
|
2211
|
-
selectedCamera || (selectedCamera = availableCameras[0]);
|
|
2212
|
-
if (debugMode) log('selectedCamera', selectedCamera);
|
|
2213
|
-
setVideoDevice(selectedCamera);
|
|
2214
|
-
return [3 /*break*/, 4];
|
|
2215
|
-
case 3:
|
|
2216
|
-
e_1 = _c.sent();
|
|
2217
|
-
if (e_1.name === 'NotAllowedError') {
|
|
2218
|
-
error('camera access has been blocked by the user', e_1);
|
|
2219
|
-
setCameraAccessDenied(true);
|
|
2220
|
-
} else {
|
|
2221
|
-
error('camera access encountered some other error', e_1);
|
|
2222
|
-
throw e_1;
|
|
2223
|
-
}
|
|
2224
|
-
return [3 /*break*/, 4];
|
|
2225
|
-
case 4:
|
|
2226
|
-
return [2 /*return*/];
|
|
2227
|
-
}
|
|
2228
|
-
});
|
|
2229
|
-
});
|
|
2230
|
-
}, [debugMode, iphoneContinuityCameraAllowed, iphoneContinuityCameraDenied, preferFrontFacingCamera]);
|
|
2231
|
-
React.useEffect(function requestCameraAccessAutomatically() {
|
|
2232
|
-
if (requestAccessAutomatically && !cameraAccessDenied) {
|
|
2233
|
-
requestCameraAccess()["catch"](error);
|
|
2234
|
-
}
|
|
2235
|
-
}, [cameraAccessDenied, requestAccessAutomatically, requestCameraAccess]);
|
|
2236
|
-
React.useEffect(function accessChosenCamera() {
|
|
2237
|
-
var _this = this;
|
|
2238
|
-
var _a;
|
|
2239
|
-
if (!videoDevice) return;
|
|
2240
|
-
var cleanup = function cleanup() {
|
|
2241
|
-
releaseCameraAccess();
|
|
2242
|
-
cameraRef.current = null;
|
|
2243
|
-
setVideoLoaded(false);
|
|
2244
|
-
};
|
|
2245
|
-
if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) return cleanup;
|
|
2246
|
-
(function () {
|
|
2247
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
2248
|
-
var constraints, stream, e_2, handleStreamEnded;
|
|
2249
|
-
var _a;
|
|
2250
|
-
return __generator(this, function (_b) {
|
|
2251
|
-
switch (_b.label) {
|
|
2252
|
-
case 0:
|
|
2253
|
-
constraints = {
|
|
2254
|
-
audio: false,
|
|
2255
|
-
video: {
|
|
2256
|
-
deviceId: {
|
|
2257
|
-
exact: videoDevice.deviceId
|
|
2258
|
-
},
|
|
2259
|
-
width: {
|
|
2260
|
-
ideal: maxVideoWidth
|
|
2261
|
-
},
|
|
2262
|
-
aspectRatio: 1.777777778,
|
|
2263
|
-
frameRate: {}
|
|
2264
|
-
}
|
|
2265
|
-
};
|
|
2266
|
-
if (maxFps) {
|
|
2267
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2268
|
-
// @ts-ignore
|
|
2269
|
-
constraints.video.frameRate = {
|
|
2270
|
-
max: maxFps
|
|
2271
|
-
};
|
|
2272
|
-
}
|
|
2273
|
-
stream = null;
|
|
2274
|
-
_b.label = 1;
|
|
2275
|
-
case 1:
|
|
2276
|
-
_b.trys.push([1, 3,, 4]);
|
|
2277
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
|
|
2278
|
-
case 2:
|
|
2279
|
-
stream = _b.sent();
|
|
2280
|
-
return [3 /*break*/, 4];
|
|
2281
|
-
case 3:
|
|
2282
|
-
e_2 = _b.sent();
|
|
2283
|
-
if (e_2.name === 'NotAllowedError') {
|
|
2284
|
-
if (iphoneContinuityCameraAllowed) {
|
|
2285
|
-
setIphoneContinuityCameraAvailable(false);
|
|
2286
|
-
setIphoneContinuityCameraDenied(true);
|
|
2287
|
-
} else {
|
|
2288
|
-
setCameraAccessDenied(true);
|
|
2289
|
-
}
|
|
2290
|
-
return [2 /*return*/];
|
|
2291
|
-
}
|
|
2292
|
-
return [3 /*break*/, 4];
|
|
2293
|
-
case 4:
|
|
2294
|
-
if (!!stream) return [3 /*break*/, 8];
|
|
2295
|
-
_b.label = 5;
|
|
2296
|
-
case 5:
|
|
2297
|
-
_b.trys.push([5, 7,, 8]);
|
|
2298
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
2299
|
-
audio: false,
|
|
2300
|
-
video: true
|
|
2301
|
-
})];
|
|
2302
|
-
case 6:
|
|
2303
|
-
stream = _b.sent();
|
|
2304
|
-
log('opened stream with no width and height constraints');
|
|
2305
|
-
return [3 /*break*/, 8];
|
|
2306
|
-
case 7:
|
|
2307
|
-
_b.sent();
|
|
2308
|
-
log('cannot open stream at all');
|
|
2309
|
-
return [3 /*break*/, 8];
|
|
2310
|
-
case 8:
|
|
2311
|
-
if (!stream) {
|
|
2312
|
-
throw new Error('failed to open camera');
|
|
2313
|
-
}
|
|
2314
|
-
handleStreamEnded = function handleStreamEnded() {
|
|
2315
|
-
if (iphoneContinuityCameraAvailable && iphoneContinuityCameraAllowed) {
|
|
2316
|
-
log('someone unplugged the continuity camera');
|
|
2317
|
-
releaseCameraAccess();
|
|
2318
|
-
cameraRef.current = null;
|
|
2319
|
-
setIphoneContinuityCameraAvailable(false);
|
|
2320
|
-
setIphoneContinuityCameraDenied(true);
|
|
2321
|
-
setVideoDevice(null);
|
|
2322
|
-
} else {
|
|
2323
|
-
log('someone unplugged the webcam');
|
|
2324
|
-
releaseCameraAccess();
|
|
2325
|
-
cameraRef.current = null;
|
|
2326
|
-
setVideoLoaded(false);
|
|
2327
|
-
setCameraAccessDenied(true);
|
|
2328
|
-
}
|
|
2329
|
-
};
|
|
2330
|
-
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', handleStreamEnded);
|
|
2331
|
-
stream.getVideoTracks().forEach(function (track) {
|
|
2332
|
-
track.onended = handleStreamEnded;
|
|
2333
|
-
});
|
|
2334
|
-
cameraRef.current = obtainCameraAccess(stream, videoDevice.label, videoRef.current);
|
|
2335
|
-
return [2 /*return*/];
|
|
2336
|
-
}
|
|
2337
|
-
});
|
|
2338
|
-
});
|
|
2339
|
-
})();
|
|
2340
|
-
return cleanup;
|
|
2341
|
-
}, [iphoneContinuityCameraAllowed, iphoneContinuityCameraAvailable, maxFps, maxVideoWidth, videoDevice]);
|
|
2342
|
-
React.useEffect(function triggerCameraReady() {
|
|
2343
|
-
// TODO: in the future let's evaluate whether we can simplify this to just
|
|
2344
|
-
// setCameraReady(!!videoDevice && videoLoaded) -- we are wondering whether
|
|
2345
|
-
// we somehow depend on this being set twice.
|
|
2346
|
-
setCameraReady(false);
|
|
2347
|
-
if (videoDevice && videoLoaded) {
|
|
2348
|
-
setCameraReady(videoDevice && videoLoaded);
|
|
2349
|
-
}
|
|
2350
|
-
}, [videoLoaded, videoDevice]);
|
|
2351
|
-
var requestMicrophoneAccess = React.useCallback(function _requestMicrophoneAccess() {
|
|
2352
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2353
|
-
var stream;
|
|
2354
|
-
return __generator(this, function (_a) {
|
|
2355
|
-
switch (_a.label) {
|
|
2356
|
-
case 0:
|
|
2357
|
-
setMicrophoneReady(false);
|
|
2358
|
-
setMicrophoneAccessDenied(false);
|
|
2359
|
-
_a.label = 1;
|
|
2360
|
-
case 1:
|
|
2361
|
-
_a.trys.push([1, 3,, 4]);
|
|
2362
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
2363
|
-
audio: true,
|
|
2364
|
-
video: false
|
|
2365
|
-
})];
|
|
2366
|
-
case 2:
|
|
2367
|
-
stream = _a.sent();
|
|
2368
|
-
currentAudioStream = stream;
|
|
2369
|
-
setAudioStream(stream);
|
|
2370
|
-
setMicrophoneReady(true);
|
|
2371
|
-
stream.getAudioTracks().forEach(function (track) {
|
|
2372
|
-
track.onended = function () {
|
|
2373
|
-
setMicrophoneAccessDenied(true);
|
|
2374
|
-
};
|
|
2375
|
-
});
|
|
2376
|
-
return [3 /*break*/, 4];
|
|
2377
|
-
case 3:
|
|
2378
|
-
_a.sent();
|
|
2379
|
-
setMicrophoneAccessDenied(true);
|
|
2380
|
-
return [3 /*break*/, 4];
|
|
2381
|
-
case 4:
|
|
2382
|
-
return [2 /*return*/];
|
|
2383
|
-
}
|
|
2384
|
-
});
|
|
2385
|
-
});
|
|
2386
|
-
}, []);
|
|
2387
|
-
React.useEffect(function requestMicrophoneAccessIfNeeded() {
|
|
2388
|
-
if (!requireMicrophoneAccess || microphoneAccessDenied) return;
|
|
2389
|
-
requestMicrophoneAccess()["catch"](error);
|
|
2390
|
-
return function () {
|
|
2391
|
-
releaseMicrophoneAccess();
|
|
2392
|
-
setAudioStream(null);
|
|
2393
|
-
setMicrophoneReady(false);
|
|
2394
|
-
};
|
|
2395
|
-
}, [microphoneAccessDenied, requestMicrophoneAccess, requireMicrophoneAccess]);
|
|
2396
|
-
var takePhoto = React.useCallback(function _takePhoto() {
|
|
2397
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2398
|
-
var canvas;
|
|
2399
|
-
return __generator(this, function (_a) {
|
|
2400
|
-
switch (_a.label) {
|
|
2401
|
-
case 0:
|
|
2402
|
-
if (!cameraRef.current) return [2 /*return*/, null];
|
|
2403
|
-
if (!(typeof ImageCapture !== 'undefined')) return [3 /*break*/, 2];
|
|
2404
|
-
return [4 /*yield*/, new ImageCapture(cameraRef.current.stream.getTracks()[0]).takePhoto()];
|
|
2405
|
-
case 1:
|
|
2406
|
-
return [2 /*return*/, _a.sent()];
|
|
2407
|
-
case 2:
|
|
2408
|
-
if (!videoRef.current) return [2 /*return*/, null];
|
|
2409
|
-
canvas = document.createElement('canvas');
|
|
2410
|
-
drawToCanvas(canvas, videoRef.current);
|
|
2411
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
2412
|
-
return canvas.toBlob(resolve);
|
|
2413
|
-
})];
|
|
2414
|
-
}
|
|
2415
|
-
});
|
|
2416
|
-
});
|
|
2417
|
-
}, []);
|
|
2418
|
-
return React.useMemo(function () {
|
|
2419
|
-
return {
|
|
2420
|
-
videoRef: videoRef,
|
|
2421
|
-
videoDevice: videoDevice,
|
|
2422
|
-
videoLoaded: videoLoaded,
|
|
2423
|
-
setVideoLoaded: setVideoLoaded,
|
|
2424
|
-
onVideoUnmounted: onVideoUnmounted,
|
|
2425
|
-
cameraRef: cameraRef,
|
|
2426
|
-
cameraReady: cameraReady,
|
|
2427
|
-
cameraAccessDenied: cameraAccessDenied,
|
|
2428
|
-
requestCameraAccess: requestCameraAccess,
|
|
2429
|
-
releaseCameraAccess: releaseCameraAccess,
|
|
2430
|
-
iphoneContinuityCameraAvailable: iphoneContinuityCameraAvailable,
|
|
2431
|
-
iphoneContinuityCameraAllowed: iphoneContinuityCameraAllowed,
|
|
2432
|
-
setIphoneContinuityCameraAllowed: setIphoneContinuityCameraAllowed,
|
|
2433
|
-
takePhoto: takePhoto,
|
|
2434
|
-
audioStream: audioStream,
|
|
2435
|
-
microphoneReady: microphoneReady,
|
|
2436
|
-
microphoneAccessDenied: microphoneAccessDenied,
|
|
2437
|
-
requestMicrophoneAccess: requestMicrophoneAccess
|
|
2438
|
-
};
|
|
2439
|
-
}, [audioStream, cameraAccessDenied, cameraReady, iphoneContinuityCameraAllowed, iphoneContinuityCameraAvailable, microphoneAccessDenied, microphoneReady, onVideoUnmounted, requestCameraAccess, requestMicrophoneAccess, takePhoto, videoDevice, videoLoaded]);
|
|
2440
|
-
}
|
|
2441
|
-
|
|
2442
|
-
var CameraStateContext = /*#__PURE__*/React.createContext({
|
|
2443
|
-
videoRef: {
|
|
2444
|
-
current: null
|
|
2445
|
-
},
|
|
2446
|
-
videoDevice: null,
|
|
2447
|
-
videoLoaded: false,
|
|
2448
|
-
cameraRef: {
|
|
2449
|
-
current: null
|
|
2450
|
-
},
|
|
2451
|
-
cameraReady: false,
|
|
2452
|
-
cameraAccessDenied: false,
|
|
2453
|
-
requestCameraAccess: function requestCameraAccess() {
|
|
2454
|
-
return null;
|
|
2455
|
-
},
|
|
2456
|
-
releaseCameraAccess: function releaseCameraAccess() {
|
|
2457
|
-
return null;
|
|
2458
|
-
},
|
|
2459
|
-
iphoneContinuityCameraAvailable: false,
|
|
2460
|
-
iphoneContinuityCameraAllowed: true,
|
|
2461
|
-
setIphoneContinuityCameraAllowed: function setIphoneContinuityCameraAllowed() {
|
|
2462
|
-
return null;
|
|
2463
|
-
},
|
|
2464
|
-
takePhoto: function takePhoto() {
|
|
2465
|
-
return Promise.resolve(null);
|
|
2466
|
-
},
|
|
2467
|
-
setVideoLoaded: function setVideoLoaded() {
|
|
2468
|
-
return null;
|
|
2469
|
-
},
|
|
2470
|
-
onVideoUnmounted: function onVideoUnmounted() {
|
|
2471
|
-
return null;
|
|
2472
|
-
},
|
|
2473
|
-
audioStream: null,
|
|
2474
|
-
microphoneReady: false,
|
|
2475
|
-
microphoneAccessDenied: false,
|
|
2476
|
-
requestMicrophoneAccess: function requestMicrophoneAccess() {
|
|
2477
|
-
return null;
|
|
2478
|
-
}
|
|
2479
|
-
});
|
|
2480
|
-
var CameraProvider = function CameraProvider(_a) {
|
|
2481
|
-
var children = _a.children,
|
|
2482
|
-
_b = _a.requestAccessAutomatically,
|
|
2483
|
-
requestAccessAutomatically = _b === void 0 ? true : _b,
|
|
2484
|
-
_c = _a.preferFrontFacingCamera,
|
|
2485
|
-
preferFrontFacingCamera = _c === void 0 ? false : _c,
|
|
2486
|
-
_d = _a.preferContinuityCamera,
|
|
2487
|
-
preferContinuityCamera = _d === void 0 ? true : _d,
|
|
2488
|
-
_e = _a.requireMicrophoneAccess,
|
|
2489
|
-
requireMicrophoneAccess = _e === void 0 ? false : _e,
|
|
2490
|
-
_f = _a.maxVideoWidth,
|
|
2491
|
-
maxVideoWidth = _f === void 0 ? 1920 : _f,
|
|
2492
|
-
maxFps = _a.maxFps,
|
|
2493
|
-
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
2494
|
-
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
|
|
2495
|
-
_g = _a.debugMode,
|
|
2496
|
-
debugMode = _g === void 0 ? false : _g;
|
|
2497
|
-
var captureDevice = usePreferredCaptureDevice({
|
|
2498
|
-
requestAccessAutomatically: requestAccessAutomatically,
|
|
2499
|
-
preferFrontFacingCamera: preferFrontFacingCamera,
|
|
2500
|
-
preferContinuityCamera: preferContinuityCamera,
|
|
2501
|
-
requireMicrophoneAccess: requireMicrophoneAccess,
|
|
2502
|
-
maxVideoWidth: maxVideoWidth,
|
|
2503
|
-
maxFps: maxFps,
|
|
2504
|
-
debugMode: debugMode
|
|
2505
|
-
});
|
|
2506
|
-
React.useEffect(function () {
|
|
2507
|
-
if (captureDevice.cameraAccessDenied) onCameraAccessDenied === null || onCameraAccessDenied === void 0 ? void 0 : onCameraAccessDenied();
|
|
2508
|
-
}, [captureDevice.cameraAccessDenied, onCameraAccessDenied]);
|
|
2509
|
-
React.useEffect(function () {
|
|
2510
|
-
if (captureDevice.microphoneAccessDenied) onMicrophoneAccessDenied === null || onMicrophoneAccessDenied === void 0 ? void 0 : onMicrophoneAccessDenied();
|
|
2511
|
-
}, [captureDevice.microphoneAccessDenied, onMicrophoneAccessDenied]);
|
|
2512
|
-
var releaseCameraAccess = captureDevice.releaseCameraAccess;
|
|
2513
|
-
React.useEffect(function () {
|
|
2514
|
-
return function () {
|
|
2515
|
-
releaseCameraAccess();
|
|
2516
|
-
};
|
|
2517
|
-
}, [releaseCameraAccess]);
|
|
2518
|
-
return /*#__PURE__*/React__namespace.default.createElement(CameraStateContext.Provider, {
|
|
2519
|
-
value: captureDevice
|
|
2520
|
-
}, children);
|
|
2521
|
-
};
|
|
2522
|
-
|
|
2523
1923
|
var visionTasksBasePath = "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.7/wasm";
|
|
2524
1924
|
var visionRuntimePreloading = false;
|
|
2525
1925
|
function preloadVisionRuntime() {
|
|
@@ -2562,6 +1962,42 @@ function preloadVisionRuntime() {
|
|
|
2562
1962
|
});
|
|
2563
1963
|
}
|
|
2564
1964
|
|
|
1965
|
+
function getFrameDimensions(frame) {
|
|
1966
|
+
var frameWidth = frame.width,
|
|
1967
|
+
frameHeight = frame.height;
|
|
1968
|
+
if (frame instanceof HTMLImageElement) {
|
|
1969
|
+
frameWidth = frame.naturalWidth;
|
|
1970
|
+
frameHeight = frame.naturalHeight;
|
|
1971
|
+
}
|
|
1972
|
+
if (frame instanceof HTMLVideoElement) {
|
|
1973
|
+
frameWidth = frame.videoWidth;
|
|
1974
|
+
frameHeight = frame.videoHeight;
|
|
1975
|
+
}
|
|
1976
|
+
return [frameWidth, frameHeight];
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
var InvisibleCanvas = styled__default.default.canvas(templateObject_1$G || (templateObject_1$G = __makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
|
|
1980
|
+
function drawToCanvas(canvas, frame, width, height) {
|
|
1981
|
+
if (!canvas) return;
|
|
1982
|
+
var ctx = canvas.getContext('2d');
|
|
1983
|
+
if (!ctx) return;
|
|
1984
|
+
if (!width || !height) {
|
|
1985
|
+
var _a = getFrameDimensions(frame),
|
|
1986
|
+
frameWidth = _a[0],
|
|
1987
|
+
frameHeight = _a[1];
|
|
1988
|
+
width || (width = frameWidth);
|
|
1989
|
+
height || (height = frameHeight);
|
|
1990
|
+
}
|
|
1991
|
+
canvas.width = width;
|
|
1992
|
+
canvas.height = height;
|
|
1993
|
+
ctx.drawImage(frame, 0, 0, width, height);
|
|
1994
|
+
}
|
|
1995
|
+
function clearCanvas(canvas) {
|
|
1996
|
+
var _a;
|
|
1997
|
+
(_a = canvas === null || canvas === void 0 ? void 0 : canvas.getContext('2d')) === null || _a === void 0 ? void 0 : _a.clearRect(0, 0, canvas === null || canvas === void 0 ? void 0 : canvas.width, canvas === null || canvas === void 0 ? void 0 : canvas.height);
|
|
1998
|
+
}
|
|
1999
|
+
var templateObject_1$G;
|
|
2000
|
+
|
|
2565
2001
|
function cropToShoulders(rawCanvas, cropCanvas, resizeCanvas, frame, face, quality, maxHeight) {
|
|
2566
2002
|
if (quality === void 0) {
|
|
2567
2003
|
quality = 0.92;
|
|
@@ -2865,7 +2301,8 @@ function useLoadFocusModel(_a) {
|
|
|
2865
2301
|
modelPath = _b === void 0 ? defaultFocusModelPath : _b,
|
|
2866
2302
|
_c = _a.modelLoadTimeoutMs,
|
|
2867
2303
|
modelLoadTimeoutMs = _c === void 0 ? defaultFocusModelLoadTimeoutMs : _c,
|
|
2868
|
-
onModelError = _a.onModelError
|
|
2304
|
+
onModelError = _a.onModelError,
|
|
2305
|
+
videoRef = _a.videoRef;
|
|
2869
2306
|
var _d = React.useState(false),
|
|
2870
2307
|
ready = _d[0],
|
|
2871
2308
|
setReady = _d[1];
|
|
@@ -2875,7 +2312,6 @@ function useLoadFocusModel(_a) {
|
|
|
2875
2312
|
var _f = React.useState(null),
|
|
2876
2313
|
modelError = _f[0],
|
|
2877
2314
|
setModelError = _f[1];
|
|
2878
|
-
var videoRef = React.useContext(CameraStateContext).videoRef;
|
|
2879
2315
|
React.useEffect(function loadModel() {
|
|
2880
2316
|
var _this = this;
|
|
2881
2317
|
setReady(false);
|
|
@@ -3013,7 +2449,8 @@ function closeFaceDetector() {
|
|
|
3013
2449
|
function useLoadFaceDetector(_a) {
|
|
3014
2450
|
var onModelError = _a.onModelError,
|
|
3015
2451
|
_b = _a.modelLoadTimeoutMs,
|
|
3016
|
-
modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b
|
|
2452
|
+
modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b,
|
|
2453
|
+
videoRef = _a.videoRef;
|
|
3017
2454
|
var _c = React.useState(false),
|
|
3018
2455
|
ready = _c[0],
|
|
3019
2456
|
setReady = _c[1];
|
|
@@ -3023,7 +2460,6 @@ function useLoadFaceDetector(_a) {
|
|
|
3023
2460
|
var _e = React.useState(null),
|
|
3024
2461
|
modelError = _e[0],
|
|
3025
2462
|
setModelError = _e[1];
|
|
3026
|
-
var videoRef = React.useContext(CameraStateContext).videoRef;
|
|
3027
2463
|
React.useEffect(function loadModel() {
|
|
3028
2464
|
var _this = this;
|
|
3029
2465
|
setReady(false);
|
|
@@ -3504,7 +2940,8 @@ function useLoadDocumentDetector(_a) {
|
|
|
3504
2940
|
modelLoadTimeoutMs = _c === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _c,
|
|
3505
2941
|
_d = _a.scoreThreshold,
|
|
3506
2942
|
scoreThreshold = _d === void 0 ? defaultDocumentDetectionScoreThreshold : _d,
|
|
3507
|
-
onModelError = _a.onModelError
|
|
2943
|
+
onModelError = _a.onModelError,
|
|
2944
|
+
videoRef = _a.videoRef;
|
|
3508
2945
|
var _e = React.useState(false),
|
|
3509
2946
|
ready = _e[0],
|
|
3510
2947
|
setReady = _e[1];
|
|
@@ -3514,7 +2951,6 @@ function useLoadDocumentDetector(_a) {
|
|
|
3514
2951
|
var _g = React.useState(null),
|
|
3515
2952
|
modelError = _g[0],
|
|
3516
2953
|
setModelError = _g[1];
|
|
3517
|
-
var videoRef = React.useContext(CameraStateContext).videoRef;
|
|
3518
2954
|
React.useEffect(function loadModel() {
|
|
3519
2955
|
var _this = this;
|
|
3520
2956
|
setReady(false);
|
|
@@ -3750,77 +3186,567 @@ function applyNonMaxSuppression(detectedObjects, isGoodBox) {
|
|
|
3750
3186
|
if (obj.score > maxes[obj.label][0] && (isGoodBox === null || isGoodBox === void 0 ? void 0 : isGoodBox(obj))) maxes[obj.label] = [obj.score, i];
|
|
3751
3187
|
}
|
|
3752
3188
|
});
|
|
3753
|
-
return Object.keys(maxes).map(function (label) {
|
|
3754
|
-
return detectedObjects[maxes[label][1]];
|
|
3755
|
-
}).filter(function (obj) {
|
|
3756
|
-
return !!obj;
|
|
3189
|
+
return Object.keys(maxes).map(function (label) {
|
|
3190
|
+
return detectedObjects[maxes[label][1]];
|
|
3191
|
+
}).filter(function (obj) {
|
|
3192
|
+
return !!obj;
|
|
3193
|
+
});
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3196
|
+
function useFrameLoop(fn, _a) {
|
|
3197
|
+
var _b = _a.throttleMs,
|
|
3198
|
+
throttleMs = _b === void 0 ? 0 : _b,
|
|
3199
|
+
_c = _a.autoStart,
|
|
3200
|
+
autoStart = _c === void 0 ? false : _c;
|
|
3201
|
+
var _d = React.useState(false),
|
|
3202
|
+
running = _d[0],
|
|
3203
|
+
setRunning = _d[1];
|
|
3204
|
+
var startedAtRef = React.useRef(null);
|
|
3205
|
+
var loopId = React.useRef(0);
|
|
3206
|
+
var frameId = React.useRef(0);
|
|
3207
|
+
React.useEffect(function runFrameLoop() {
|
|
3208
|
+
if (!running) return;
|
|
3209
|
+
var timer;
|
|
3210
|
+
var currentLoopId = loopId.current;
|
|
3211
|
+
function renderPrediction() {
|
|
3212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3213
|
+
var start, timeRunning, took, amountToThrottle;
|
|
3214
|
+
var _a, _b;
|
|
3215
|
+
return __generator(this, function (_c) {
|
|
3216
|
+
switch (_c.label) {
|
|
3217
|
+
case 0:
|
|
3218
|
+
if (currentLoopId !== loopId.current) return [2 /*return*/];
|
|
3219
|
+
start = new Date().getTime();
|
|
3220
|
+
timeRunning = start - ((_b = (_a = startedAtRef.current) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0);
|
|
3221
|
+
return [4 /*yield*/, fn(frameId.current, timeRunning)];
|
|
3222
|
+
case 1:
|
|
3223
|
+
_c.sent();
|
|
3224
|
+
took = new Date().getTime() - start;
|
|
3225
|
+
amountToThrottle = Math.max((throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0) - took, 0);
|
|
3226
|
+
timer = setTimeout(function () {
|
|
3227
|
+
frameId.current = requestAnimationFrame(renderPrediction);
|
|
3228
|
+
}, amountToThrottle);
|
|
3229
|
+
return [2 /*return*/];
|
|
3230
|
+
}
|
|
3231
|
+
});
|
|
3232
|
+
});
|
|
3233
|
+
}
|
|
3234
|
+
renderPrediction().then();
|
|
3235
|
+
return function () {
|
|
3236
|
+
loopId.current += 1;
|
|
3237
|
+
frameId.current && cancelAnimationFrame(frameId.current);
|
|
3238
|
+
timer && clearTimeout(timer);
|
|
3239
|
+
};
|
|
3240
|
+
}, [fn, running, throttleMs]);
|
|
3241
|
+
var start = React.useCallback(function () {
|
|
3242
|
+
startedAtRef.current = new Date();
|
|
3243
|
+
setRunning(true);
|
|
3244
|
+
}, []);
|
|
3245
|
+
var stop = React.useCallback(function () {
|
|
3246
|
+
loopId.current += 1; // force the loop to stop immediately.
|
|
3247
|
+
setRunning(false);
|
|
3248
|
+
startedAtRef.current = null;
|
|
3249
|
+
}, []);
|
|
3250
|
+
React.useEffect(function startAutomatically() {
|
|
3251
|
+
if (autoStart) start();
|
|
3252
|
+
return function () {
|
|
3253
|
+
stop();
|
|
3254
|
+
};
|
|
3255
|
+
}, [autoStart, start, stop]);
|
|
3256
|
+
return {
|
|
3257
|
+
start: start,
|
|
3258
|
+
stop: stop
|
|
3259
|
+
};
|
|
3260
|
+
}
|
|
3261
|
+
|
|
3262
|
+
function listAvailableCameras(facingMode_1) {
|
|
3263
|
+
return __awaiter(this, arguments, void 0, function (facingMode, requestMicAccess) {
|
|
3264
|
+
var cameraEnumerationStream, videoDevices;
|
|
3265
|
+
if (requestMicAccess === void 0) {
|
|
3266
|
+
requestMicAccess = false;
|
|
3267
|
+
}
|
|
3268
|
+
return __generator(this, function (_a) {
|
|
3269
|
+
switch (_a.label) {
|
|
3270
|
+
case 0:
|
|
3271
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3272
|
+
video: {
|
|
3273
|
+
facingMode: {
|
|
3274
|
+
exact: facingMode
|
|
3275
|
+
}
|
|
3276
|
+
},
|
|
3277
|
+
audio: requestMicAccess
|
|
3278
|
+
})
|
|
3279
|
+
// This lists all available cameras attached to the user's device.
|
|
3280
|
+
];
|
|
3281
|
+
case 1:
|
|
3282
|
+
cameraEnumerationStream = _a.sent();
|
|
3283
|
+
return [4 /*yield*/, navigator.mediaDevices.enumerateDevices()];
|
|
3284
|
+
case 2:
|
|
3285
|
+
videoDevices = _a.sent().filter(function (_a) {
|
|
3286
|
+
var kind = _a.kind;
|
|
3287
|
+
return kind === 'videoinput';
|
|
3288
|
+
});
|
|
3289
|
+
// Release the access to the user's camera that we obtained for enumeration purposes.
|
|
3290
|
+
cameraEnumerationStream.getVideoTracks().forEach(function (track) {
|
|
3291
|
+
track.enabled = false;
|
|
3292
|
+
track.stop();
|
|
3293
|
+
});
|
|
3294
|
+
cameraEnumerationStream = null;
|
|
3295
|
+
return [2 /*return*/, videoDevices];
|
|
3296
|
+
}
|
|
3297
|
+
});
|
|
3298
|
+
});
|
|
3299
|
+
}
|
|
3300
|
+
var frontCameraLabels = ['front', 'avant', 'anteriore', 'cameraaanvoorzijde', 'kamerapåframsidan', 'forsidekamera', 'kamerapåforsiden', 'aparatprzedni', 'etukamera', 'kameradepan', 'ÖnKamera', 'cameramặttrước', 'camerăfață', 'prednákamera', 'prednjakamera', 'előlapikamera', 'přednífotoaparát', 'μπροστινήκάμερα', 'переднякамера', 'передняякамера', 'преднакамера', 'алдыңғыкамера', 'מצלמה קדמית', 'الكاميرا الأمامية', 'फ़्रंटकैमरा', '前置相机', '前置鏡頭', '前面カメラ', '전면카메라', 'กล้องด้านหน้า'].map(function (s) {
|
|
3301
|
+
return s.toLocaleLowerCase().split(' ').join('');
|
|
3302
|
+
});
|
|
3303
|
+
var rearCameraLabels = ['back', 'rear', 'posterior', 'trasera', 'traseira', 'arrière', 'rückkamera', 'fotocamera(posteriore)', 'cameraaanachterzijde', 'kamerapåbaksidan', 'kamerapåbaksiden', 'bagsidekamera', 'aparattylny', 'takakamera', 'arkakamera', 'kamerabelakang', 'cameramặtsau', 'camerăspate', 'stražnjakamera', 'zadnákamera', 'hátoldalikamera', 'zadnífotoaparát', 'πίσωκάμερα', 'заднякамера', 'Задняякамера', 'заднакамера', 'артқыкамера', 'מצלמה אחורית', 'الكاميرا الخلفية', 'बैककैमरा', '后置相机', '後置鏡頭', '背面カメラ', '후면카메라', 'กล้องด้านหลัง'].map(function (s) {
|
|
3304
|
+
return s.toLocaleLowerCase().split(' ').join('');
|
|
3305
|
+
});
|
|
3306
|
+
var backUltraWideCameraLabels = ['backdualwidecamera', 'backultrawidecamera', 'ultraampliaposterior', 'ultra-angulartraseira', 'ultragrandeangulartraseira', 'ultragrandangle', 'ultragranangular', 'ultra-weitwinkelkamera', 'ultra-grandangolo', 'ultrabredecameraaanachterzijde', 'ultravidvinkelkamerapåbaksidan', 'ultravidvinkelkameraetpåbagsiden', 'ultravidvinkelkamerabak', 'ultragenişkameraarkayüzü', 'ultralaajakulmainentakakamera', 'tylnyaparatultraszerokokątny', 'cameracựcrộngmặtsau', 'camerăcuobiectivultra‑superangularspate', 'ultraszéleslátószögűkamera', 'kameraultralebarbelakang', 'stražnjaultraširokakamera', 'zadníultraširokoúhlýfotoaparát', 'ultraširokouhlá', 'πίσωυπερευρείακάμερα', 'заднянадширококутнакамера', 'Задняясверхширокоугольнаякамера', 'Задна свръх широкоъгълна камера', 'артқыультракеңбұрыштыкамера', 'מצלמה אולטרה רחבה אחורית', 'كاميرا خلفية عريضة جدًا', 'बैकअल्ट्रावाइडकैमरा', '后置超广角相机', '後置超廣角鏡頭相機', '背面超広角カメラ', '후면울트라와이드카메라', 'กล้องด้านหลังอัลตร้าไวด์'].map(function (s) {
|
|
3307
|
+
return s.toLocaleLowerCase().split(' ').join('');
|
|
3308
|
+
});
|
|
3309
|
+
var cameraLabelMatches = function cameraLabelMatches(labelOrDevice, labelSetOrLabel) {
|
|
3310
|
+
var label = labelOrDevice instanceof MediaDeviceInfo ? getDeviceLabel(labelOrDevice) : labelOrDevice;
|
|
3311
|
+
var labelSet = typeof labelSetOrLabel === 'string' ? [labelSetOrLabel] : labelSetOrLabel;
|
|
3312
|
+
return labelSet.some(function (l) {
|
|
3313
|
+
return label.includes(l);
|
|
3314
|
+
});
|
|
3315
|
+
};
|
|
3316
|
+
var getDeviceLabel = function getDeviceLabel(deviceInfo) {
|
|
3317
|
+
return deviceInfo.label.toLocaleLowerCase().split(' ').join('');
|
|
3318
|
+
};
|
|
3319
|
+
var currentCamera;
|
|
3320
|
+
function obtainCameraAccess(stream, deviceLabel, video) {
|
|
3321
|
+
releaseCameraAccess();
|
|
3322
|
+
log('obtaining camera access...');
|
|
3323
|
+
var _a = stream.getVideoTracks()[0].getSettings(),
|
|
3324
|
+
width = _a.width,
|
|
3325
|
+
height = _a.height;
|
|
3326
|
+
log('camera dimensions', width, height);
|
|
3327
|
+
var label = deviceLabel.toLocaleLowerCase().split(' ').join('');
|
|
3328
|
+
log('camera label', label);
|
|
3329
|
+
var isRearFacing = cameraLabelMatches(label, __spreadArray(__spreadArray(__spreadArray([], rearCameraLabels, true), backUltraWideCameraLabels, true), ['iphone'], false));
|
|
3330
|
+
log('is rear facing?', isRearFacing);
|
|
3331
|
+
var release = function release() {
|
|
3332
|
+
stream.getTracks().forEach(function (track) {
|
|
3333
|
+
track.enabled = false;
|
|
3334
|
+
track.stop();
|
|
3335
|
+
});
|
|
3336
|
+
if (video) {
|
|
3337
|
+
video.pause();
|
|
3338
|
+
video.srcObject = null;
|
|
3339
|
+
video.src = '';
|
|
3340
|
+
}
|
|
3341
|
+
};
|
|
3342
|
+
width || (width = 0);
|
|
3343
|
+
height || (height = 0);
|
|
3344
|
+
currentCamera = {
|
|
3345
|
+
label: deviceLabel,
|
|
3346
|
+
stream: stream,
|
|
3347
|
+
width: width,
|
|
3348
|
+
height: height,
|
|
3349
|
+
isRearFacing: isRearFacing,
|
|
3350
|
+
release: release
|
|
3351
|
+
};
|
|
3352
|
+
log('camera access granted');
|
|
3353
|
+
if (video) video.srcObject = stream;
|
|
3354
|
+
log('video source initialized');
|
|
3355
|
+
return currentCamera;
|
|
3356
|
+
}
|
|
3357
|
+
function releaseCameraAccess() {
|
|
3358
|
+
if (!currentCamera) return;
|
|
3359
|
+
log('releasing camera access...');
|
|
3360
|
+
currentCamera.release();
|
|
3361
|
+
currentCamera = undefined;
|
|
3362
|
+
}
|
|
3363
|
+
|
|
3364
|
+
var initialState$5 = {
|
|
3365
|
+
videoRef: {
|
|
3366
|
+
current: null
|
|
3367
|
+
},
|
|
3368
|
+
videoLoaded: false,
|
|
3369
|
+
videoStream: null,
|
|
3370
|
+
videoDevice: null,
|
|
3371
|
+
isRearFacing: false,
|
|
3372
|
+
camera: null,
|
|
3373
|
+
cameraReady: false,
|
|
3374
|
+
cameraAccessDenied: false,
|
|
3375
|
+
iphoneContinuityCameraAvailable: false,
|
|
3376
|
+
iphoneContinuityCameraDenied: false,
|
|
3377
|
+
preferIphoneContinuityCamera: true,
|
|
3378
|
+
audioStream: null,
|
|
3379
|
+
microphoneReady: false,
|
|
3380
|
+
microphoneAccessDenied: false
|
|
3381
|
+
};
|
|
3382
|
+
var createCameraStore = function createCameraStore(config) {
|
|
3383
|
+
var store = zustand.createStore(function (set, get) {
|
|
3384
|
+
return _assign(_assign(_assign({}, initialState$5), config), {
|
|
3385
|
+
reset: function reset() {
|
|
3386
|
+
return set(_assign(_assign({}, initialState$5), config));
|
|
3387
|
+
},
|
|
3388
|
+
setConfig: function setConfig(config) {
|
|
3389
|
+
return set(config);
|
|
3390
|
+
},
|
|
3391
|
+
onVideoMounted: function onVideoMounted() {
|
|
3392
|
+
return set({
|
|
3393
|
+
videoLoaded: true
|
|
3394
|
+
});
|
|
3395
|
+
},
|
|
3396
|
+
setIphoneContinuityCameraAllowed: function setIphoneContinuityCameraAllowed(value) {
|
|
3397
|
+
return set({
|
|
3398
|
+
preferIphoneContinuityCamera: value
|
|
3399
|
+
});
|
|
3400
|
+
},
|
|
3401
|
+
requestCameraAccess: function requestCameraAccess() {
|
|
3402
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3403
|
+
var _a, videoRef, releaseCameraAccess, preferFrontFacingCamera, preferIphoneContinuityCamera, iphoneContinuityCameraDenied, availableCameras, selectedCamera, platform_1, iphoneContinuityCamera, constraints, stream_1, e_1, handleStreamEnded_1, videoTrack_1, camera_1, e_3;
|
|
3404
|
+
var _b, _c, _d;
|
|
3405
|
+
return __generator(this, function (_e) {
|
|
3406
|
+
switch (_e.label) {
|
|
3407
|
+
case 0:
|
|
3408
|
+
_a = get(), videoRef = _a.videoRef, releaseCameraAccess = _a.releaseCameraAccess, preferFrontFacingCamera = _a.preferFrontFacingCamera, preferIphoneContinuityCamera = _a.preferIphoneContinuityCamera, iphoneContinuityCameraDenied = _a.iphoneContinuityCameraDenied;
|
|
3409
|
+
releaseCameraAccess();
|
|
3410
|
+
_e.label = 1;
|
|
3411
|
+
case 1:
|
|
3412
|
+
_e.trys.push([1, 11,, 12]);
|
|
3413
|
+
return [4 /*yield*/, listAvailableCameras()];
|
|
3414
|
+
case 2:
|
|
3415
|
+
availableCameras = _e.sent();
|
|
3416
|
+
selectedCamera = void 0;
|
|
3417
|
+
debug('availableCameras', availableCameras);
|
|
3418
|
+
platform_1 = getPlatform();
|
|
3419
|
+
debug('platformDetails', platform_1);
|
|
3420
|
+
if (!iphoneContinuityCameraDenied && (!(platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) || platform_1.os.family === 'OS X')) {
|
|
3421
|
+
iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
|
|
3422
|
+
return cameraLabelMatches(deviceInfo, 'iphone');
|
|
3423
|
+
});
|
|
3424
|
+
set({
|
|
3425
|
+
iphoneContinuityCameraAvailable: !!iphoneContinuityCamera
|
|
3426
|
+
});
|
|
3427
|
+
if (iphoneContinuityCamera && preferIphoneContinuityCamera) {
|
|
3428
|
+
selectedCamera = iphoneContinuityCamera;
|
|
3429
|
+
}
|
|
3430
|
+
} else if (((_b = platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) === null || _b === void 0 ? void 0 : _b.family) === 'Android' || availableCameras.every(function (c) {
|
|
3431
|
+
return c.label.startsWith('camera2 ');
|
|
3432
|
+
})) {
|
|
3433
|
+
availableCameras = availableCameras.sort(function (a, b) {
|
|
3434
|
+
return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
|
|
3435
|
+
});
|
|
3436
|
+
debug('cameras have been sorted', availableCameras);
|
|
3437
|
+
}
|
|
3438
|
+
if (preferFrontFacingCamera) {
|
|
3439
|
+
selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3440
|
+
return cameraLabelMatches(deviceInfo, frontCameraLabels);
|
|
3441
|
+
});
|
|
3442
|
+
}
|
|
3443
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3444
|
+
return cameraLabelMatches(deviceInfo, 'backtriplecamera');
|
|
3445
|
+
}));
|
|
3446
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3447
|
+
return cameraLabelMatches(deviceInfo, 'backdualcamera');
|
|
3448
|
+
}));
|
|
3449
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3450
|
+
return cameraLabelMatches(deviceInfo, rearCameraLabels) && !cameraLabelMatches(deviceInfo, backUltraWideCameraLabels);
|
|
3451
|
+
}));
|
|
3452
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3453
|
+
return cameraLabelMatches(deviceInfo, rearCameraLabels);
|
|
3454
|
+
}));
|
|
3455
|
+
// on iOS, the front facing camera always is at the first position in the list, so we skip it if all else fails.
|
|
3456
|
+
if (!preferFrontFacingCamera && ((_c = platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) === null || _c === void 0 ? void 0 : _c.family) === 'iOS' && availableCameras.length > 0) {
|
|
3457
|
+
selectedCamera || (selectedCamera = availableCameras[1]);
|
|
3458
|
+
}
|
|
3459
|
+
selectedCamera || (selectedCamera = availableCameras[0]);
|
|
3460
|
+
debug('selectedCamera', selectedCamera);
|
|
3461
|
+
set({
|
|
3462
|
+
videoDevice: selectedCamera
|
|
3463
|
+
});
|
|
3464
|
+
constraints = {
|
|
3465
|
+
audio: false,
|
|
3466
|
+
video: {
|
|
3467
|
+
deviceId: {
|
|
3468
|
+
exact: selectedCamera.deviceId
|
|
3469
|
+
},
|
|
3470
|
+
width: {
|
|
3471
|
+
ideal: config.maxVideoWidth
|
|
3472
|
+
},
|
|
3473
|
+
aspectRatio: 1.777777778,
|
|
3474
|
+
frameRate: {}
|
|
3475
|
+
}
|
|
3476
|
+
};
|
|
3477
|
+
if (config.maxFps) {
|
|
3478
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3479
|
+
// @ts-ignore
|
|
3480
|
+
constraints.video.frameRate = {
|
|
3481
|
+
max: config.maxFps
|
|
3482
|
+
};
|
|
3483
|
+
}
|
|
3484
|
+
stream_1 = null;
|
|
3485
|
+
_e.label = 3;
|
|
3486
|
+
case 3:
|
|
3487
|
+
_e.trys.push([3, 5,, 6]);
|
|
3488
|
+
debug('obtaining camera access with constraints', constraints);
|
|
3489
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
|
|
3490
|
+
case 4:
|
|
3491
|
+
stream_1 = _e.sent();
|
|
3492
|
+
return [3 /*break*/, 6];
|
|
3493
|
+
case 5:
|
|
3494
|
+
e_1 = _e.sent();
|
|
3495
|
+
if (e_1.name === 'NotAllowedError') {
|
|
3496
|
+
if (preferIphoneContinuityCamera) {
|
|
3497
|
+
set({
|
|
3498
|
+
iphoneContinuityCameraAvailable: false,
|
|
3499
|
+
iphoneContinuityCameraDenied: true
|
|
3500
|
+
});
|
|
3501
|
+
} else {
|
|
3502
|
+
set({
|
|
3503
|
+
cameraAccessDenied: true
|
|
3504
|
+
});
|
|
3505
|
+
}
|
|
3506
|
+
return [2 /*return*/];
|
|
3507
|
+
}
|
|
3508
|
+
return [3 /*break*/, 6];
|
|
3509
|
+
case 6:
|
|
3510
|
+
if (!!stream_1) return [3 /*break*/, 10];
|
|
3511
|
+
_e.label = 7;
|
|
3512
|
+
case 7:
|
|
3513
|
+
_e.trys.push([7, 9,, 10]);
|
|
3514
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3515
|
+
audio: false,
|
|
3516
|
+
video: true
|
|
3517
|
+
})];
|
|
3518
|
+
case 8:
|
|
3519
|
+
stream_1 = _e.sent();
|
|
3520
|
+
debug('opened stream with no width and height constraints');
|
|
3521
|
+
return [3 /*break*/, 10];
|
|
3522
|
+
case 9:
|
|
3523
|
+
_e.sent();
|
|
3524
|
+
debug('cannot open stream at all');
|
|
3525
|
+
return [3 /*break*/, 10];
|
|
3526
|
+
case 10:
|
|
3527
|
+
if (!stream_1) {
|
|
3528
|
+
error('failed to open camera');
|
|
3529
|
+
throw new Error('failed to open camera');
|
|
3530
|
+
}
|
|
3531
|
+
debug('camera access granted with constraints', constraints);
|
|
3532
|
+
handleStreamEnded_1 = function handleStreamEnded_1() {
|
|
3533
|
+
if (preferIphoneContinuityCamera && get().iphoneContinuityCameraAvailable) {
|
|
3534
|
+
debug('someone unplugged the continuity camera');
|
|
3535
|
+
set({
|
|
3536
|
+
videoStream: null,
|
|
3537
|
+
videoDevice: null,
|
|
3538
|
+
cameraReady: false,
|
|
3539
|
+
iphoneContinuityCameraAvailable: false,
|
|
3540
|
+
iphoneContinuityCameraDenied: true
|
|
3541
|
+
});
|
|
3542
|
+
get().requestCameraAccess();
|
|
3543
|
+
} else {
|
|
3544
|
+
debug('someone unplugged the webcam');
|
|
3545
|
+
releaseCameraAccess();
|
|
3546
|
+
set({
|
|
3547
|
+
videoStream: null,
|
|
3548
|
+
videoDevice: null,
|
|
3549
|
+
videoLoaded: false,
|
|
3550
|
+
cameraReady: false,
|
|
3551
|
+
cameraAccessDenied: true
|
|
3552
|
+
});
|
|
3553
|
+
}
|
|
3554
|
+
};
|
|
3555
|
+
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', handleStreamEnded_1);
|
|
3556
|
+
videoTrack_1 = stream_1.getVideoTracks()[0];
|
|
3557
|
+
videoTrack_1.onended = handleStreamEnded_1;
|
|
3558
|
+
camera_1 = obtainCameraAccess(stream_1, selectedCamera.label, videoRef.current);
|
|
3559
|
+
setTimeout(function () {
|
|
3560
|
+
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
3561
|
+
// when the camera access is being requested. This delay is a workaround for that.
|
|
3562
|
+
videoTrack_1.onmute = function () {
|
|
3563
|
+
if (videoTrack_1.readyState !== 'live') handleStreamEnded_1();
|
|
3564
|
+
};
|
|
3565
|
+
set({
|
|
3566
|
+
camera: camera_1,
|
|
3567
|
+
cameraReady: true,
|
|
3568
|
+
cameraAccessDenied: false,
|
|
3569
|
+
isRearFacing: camera_1.isRearFacing,
|
|
3570
|
+
videoStream: stream_1
|
|
3571
|
+
});
|
|
3572
|
+
}, 500);
|
|
3573
|
+
return [3 /*break*/, 12];
|
|
3574
|
+
case 11:
|
|
3575
|
+
e_3 = _e.sent();
|
|
3576
|
+
if (e_3.name === 'NotAllowedError') {
|
|
3577
|
+
error('camera access has been blocked by the user', e_3);
|
|
3578
|
+
set({
|
|
3579
|
+
cameraAccessDenied: true
|
|
3580
|
+
});
|
|
3581
|
+
} else {
|
|
3582
|
+
error('camera access encountered some other error', e_3);
|
|
3583
|
+
throw e_3;
|
|
3584
|
+
}
|
|
3585
|
+
return [3 /*break*/, 12];
|
|
3586
|
+
case 12:
|
|
3587
|
+
return [2 /*return*/];
|
|
3588
|
+
}
|
|
3589
|
+
});
|
|
3590
|
+
});
|
|
3591
|
+
},
|
|
3592
|
+
releaseCameraAccess: function releaseCameraAccess() {
|
|
3593
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3594
|
+
var camera;
|
|
3595
|
+
return __generator(this, function (_a) {
|
|
3596
|
+
camera = get().camera;
|
|
3597
|
+
if (!camera) return [2 /*return*/];
|
|
3598
|
+
camera.release();
|
|
3599
|
+
set({
|
|
3600
|
+
camera: null,
|
|
3601
|
+
cameraReady: false,
|
|
3602
|
+
cameraAccessDenied: false
|
|
3603
|
+
});
|
|
3604
|
+
return [2 /*return*/];
|
|
3605
|
+
});
|
|
3606
|
+
});
|
|
3607
|
+
},
|
|
3608
|
+
requestMicrophoneAccess: function requestMicrophoneAccess() {
|
|
3609
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3610
|
+
var stream_2;
|
|
3611
|
+
return __generator(this, function (_a) {
|
|
3612
|
+
switch (_a.label) {
|
|
3613
|
+
case 0:
|
|
3614
|
+
get().releaseMicrophoneAccess();
|
|
3615
|
+
_a.label = 1;
|
|
3616
|
+
case 1:
|
|
3617
|
+
_a.trys.push([1, 3,, 4]);
|
|
3618
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3619
|
+
audio: true,
|
|
3620
|
+
video: false
|
|
3621
|
+
})
|
|
3622
|
+
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
3623
|
+
// when the camera access is being requested. This delay is a workaround for that.
|
|
3624
|
+
];
|
|
3625
|
+
case 2:
|
|
3626
|
+
stream_2 = _a.sent();
|
|
3627
|
+
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
3628
|
+
// when the camera access is being requested. This delay is a workaround for that.
|
|
3629
|
+
setTimeout(function () {
|
|
3630
|
+
set({
|
|
3631
|
+
audioStream: stream_2,
|
|
3632
|
+
microphoneReady: true,
|
|
3633
|
+
microphoneAccessDenied: false
|
|
3634
|
+
});
|
|
3635
|
+
var handleStreamEnded = function handleStreamEnded() {
|
|
3636
|
+
set({
|
|
3637
|
+
microphoneReady: false,
|
|
3638
|
+
microphoneAccessDenied: true
|
|
3639
|
+
});
|
|
3640
|
+
};
|
|
3641
|
+
var track = stream_2.getAudioTracks()[0];
|
|
3642
|
+
track.onended = handleStreamEnded;
|
|
3643
|
+
track.onmute = function () {
|
|
3644
|
+
if (track.readyState !== 'live') handleStreamEnded();
|
|
3645
|
+
};
|
|
3646
|
+
}, 500);
|
|
3647
|
+
return [3 /*break*/, 4];
|
|
3648
|
+
case 3:
|
|
3649
|
+
_a.sent();
|
|
3650
|
+
set({
|
|
3651
|
+
microphoneAccessDenied: true
|
|
3652
|
+
});
|
|
3653
|
+
return [3 /*break*/, 4];
|
|
3654
|
+
case 4:
|
|
3655
|
+
return [2 /*return*/];
|
|
3656
|
+
}
|
|
3657
|
+
});
|
|
3658
|
+
});
|
|
3659
|
+
},
|
|
3660
|
+
releaseMicrophoneAccess: function releaseMicrophoneAccess() {
|
|
3661
|
+
var _a;
|
|
3662
|
+
var audioStream = get().audioStream;
|
|
3663
|
+
(_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
|
|
3664
|
+
audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks().forEach(function (track) {
|
|
3665
|
+
var _a;
|
|
3666
|
+
(_a = track.stop) === null || _a === void 0 ? void 0 : _a.call(track);
|
|
3667
|
+
});
|
|
3668
|
+
set({
|
|
3669
|
+
audioStream: null,
|
|
3670
|
+
microphoneReady: false,
|
|
3671
|
+
microphoneAccessDenied: false
|
|
3672
|
+
});
|
|
3673
|
+
}
|
|
3674
|
+
});
|
|
3675
|
+
});
|
|
3676
|
+
if (config.requestAccessAutomatically) {
|
|
3677
|
+
void store.getState().requestCameraAccess();
|
|
3678
|
+
}
|
|
3679
|
+
return _assign(_assign({}, store), {
|
|
3680
|
+
destroy: function destroy() {
|
|
3681
|
+
store.getState().releaseCameraAccess();
|
|
3682
|
+
store.getState().releaseMicrophoneAccess();
|
|
3683
|
+
}
|
|
3757
3684
|
});
|
|
3758
|
-
}
|
|
3759
|
-
|
|
3760
|
-
function
|
|
3761
|
-
var
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3685
|
+
};
|
|
3686
|
+
var CameraStoreContext = /*#__PURE__*/React.createContext(undefined);
|
|
3687
|
+
function CameraStoreProvider(_a) {
|
|
3688
|
+
var children = _a.children,
|
|
3689
|
+
_b = _a.requestAccessAutomatically,
|
|
3690
|
+
requestAccessAutomatically = _b === void 0 ? true : _b,
|
|
3691
|
+
_c = _a.preferIphoneContinuityCamera,
|
|
3692
|
+
preferIphoneContinuityCamera = _c === void 0 ? true : _c,
|
|
3693
|
+
_d = _a.preferFrontFacingCamera,
|
|
3694
|
+
preferFrontFacingCamera = _d === void 0 ? false : _d,
|
|
3695
|
+
_e = _a.maxVideoWidth,
|
|
3696
|
+
maxVideoWidth = _e === void 0 ? 1920 : _e,
|
|
3697
|
+
maxFps = _a.maxFps,
|
|
3698
|
+
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
3699
|
+
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
|
|
3700
|
+
_f = _a.requireMicrophoneAccess,
|
|
3701
|
+
requireMicrophoneAccess = _f === void 0 ? false : _f;
|
|
3702
|
+
var videoRef = React.useRef(null);
|
|
3703
|
+
var store = React.useRef();
|
|
3704
|
+
store.current || (store.current = createCameraStore({
|
|
3705
|
+
videoRef: videoRef,
|
|
3706
|
+
requestAccessAutomatically: requestAccessAutomatically,
|
|
3707
|
+
preferIphoneContinuityCamera: preferIphoneContinuityCamera,
|
|
3708
|
+
preferFrontFacingCamera: preferFrontFacingCamera,
|
|
3709
|
+
maxVideoWidth: maxVideoWidth,
|
|
3710
|
+
maxFps: maxFps,
|
|
3711
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
3712
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
3713
|
+
requireMicrophoneAccess: requireMicrophoneAccess
|
|
3714
|
+
}));
|
|
3715
|
+
React.useEffect(function () {
|
|
3716
|
+
var _a, _b, _c;
|
|
3717
|
+
var state = (_a = store.current) === null || _a === void 0 ? void 0 : _a.getState();
|
|
3718
|
+
if (!state) return;
|
|
3719
|
+
if (preferIphoneContinuityCamera !== (state === null || state === void 0 ? void 0 : state.preferIphoneContinuityCamera) || preferFrontFacingCamera !== (state === null || state === void 0 ? void 0 : state.preferFrontFacingCamera)) {
|
|
3720
|
+
(_b = store.current) === null || _b === void 0 ? void 0 : _b.setState({
|
|
3721
|
+
preferIphoneContinuityCamera: preferIphoneContinuityCamera,
|
|
3722
|
+
preferFrontFacingCamera: preferFrontFacingCamera
|
|
3796
3723
|
});
|
|
3724
|
+
(_c = store.current) === null || _c === void 0 ? void 0 : _c.getState().requestCameraAccess();
|
|
3797
3725
|
}
|
|
3798
|
-
|
|
3726
|
+
}, [preferFrontFacingCamera, preferIphoneContinuityCamera]);
|
|
3727
|
+
React.useEffect(function () {
|
|
3728
|
+
var _a;
|
|
3729
|
+
if (!requireMicrophoneAccess) return;
|
|
3730
|
+
(_a = store.current) === null || _a === void 0 ? void 0 : _a.getState().requestMicrophoneAccess();
|
|
3799
3731
|
return function () {
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
timer && clearTimeout(timer);
|
|
3732
|
+
var _a;
|
|
3733
|
+
return (_a = store.current) === null || _a === void 0 ? void 0 : _a.getState().releaseMicrophoneAccess();
|
|
3803
3734
|
};
|
|
3804
|
-
}, [
|
|
3805
|
-
|
|
3806
|
-
startedAtRef.current = new Date();
|
|
3807
|
-
setRunning(true);
|
|
3808
|
-
}, []);
|
|
3809
|
-
var stop = React.useCallback(function () {
|
|
3810
|
-
loopId.current += 1; // force the loop to stop immediately.
|
|
3811
|
-
setRunning(false);
|
|
3812
|
-
startedAtRef.current = null;
|
|
3813
|
-
}, []);
|
|
3814
|
-
React.useEffect(function startAutomatically() {
|
|
3815
|
-
if (autoStart) start();
|
|
3735
|
+
}, [requireMicrophoneAccess]);
|
|
3736
|
+
React.useEffect(function () {
|
|
3816
3737
|
return function () {
|
|
3817
|
-
|
|
3738
|
+
var _a;
|
|
3739
|
+
return (_a = store.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
3818
3740
|
};
|
|
3819
|
-
}, [
|
|
3820
|
-
return {
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3741
|
+
}, []);
|
|
3742
|
+
return /*#__PURE__*/React__namespace.default.createElement(CameraStoreContext.Provider, {
|
|
3743
|
+
value: store.current
|
|
3744
|
+
}, children);
|
|
3745
|
+
}
|
|
3746
|
+
function useCameraStore(selector) {
|
|
3747
|
+
var store = React.useContext(CameraStoreContext);
|
|
3748
|
+
if (!store) throw new Error('useCameraStore cannot be used without Provider');
|
|
3749
|
+
return zustand.useStore(store, selector);
|
|
3824
3750
|
}
|
|
3825
3751
|
|
|
3826
3752
|
var DocumentDetectionModelContext = /*#__PURE__*/React.createContext({
|
|
@@ -3868,7 +3794,7 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
3868
3794
|
_g = _a.documentDetectionModelLoadTimeoutMs,
|
|
3869
3795
|
documentDetectionModelLoadTimeoutMs = _g === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _g,
|
|
3870
3796
|
onDocumentDetectionModelError = _a.onDocumentDetectionModelError;
|
|
3871
|
-
var _h =
|
|
3797
|
+
var _h = useCameraStore(),
|
|
3872
3798
|
videoRef = _h.videoRef,
|
|
3873
3799
|
videoLoaded = _h.videoLoaded,
|
|
3874
3800
|
cameraReady = _h.cameraReady;
|
|
@@ -3891,7 +3817,8 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
3891
3817
|
modelPath: documentDetectionModelPath,
|
|
3892
3818
|
modelLoadTimeoutMs: documentDetectionModelLoadTimeoutMs,
|
|
3893
3819
|
scoreThreshold: documentDetectionModelScoreThreshold,
|
|
3894
|
-
onModelError: onDocumentDetectionModelError
|
|
3820
|
+
onModelError: onDocumentDetectionModelError,
|
|
3821
|
+
videoRef: videoRef
|
|
3895
3822
|
}),
|
|
3896
3823
|
ready = _o.ready,
|
|
3897
3824
|
modelDownloadProgress = _o.modelDownloadProgress,
|
|
@@ -4008,10 +3935,12 @@ function FocusModelProvider(_a) {
|
|
|
4008
3935
|
var _e = React.useState({}),
|
|
4009
3936
|
focusThresholds = _e[0],
|
|
4010
3937
|
setFocusThresholds = _e[1];
|
|
3938
|
+
var videoRef = useCameraStore().videoRef;
|
|
4011
3939
|
var _f = useLoadFocusModel({
|
|
4012
3940
|
modelPath: focusModelPath,
|
|
4013
3941
|
modelLoadTimeoutMs: focusModelLoadTimeoutMs,
|
|
4014
|
-
onModelError: onFocusModelError
|
|
3942
|
+
onModelError: onFocusModelError,
|
|
3943
|
+
videoRef: videoRef
|
|
4015
3944
|
}),
|
|
4016
3945
|
ready = _f.ready,
|
|
4017
3946
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
@@ -5133,31 +5062,33 @@ var Button = styled__default.default(LoaderButton)(templateObject_5$b || (templa
|
|
|
5133
5062
|
var templateObject_1$D, templateObject_2$w, templateObject_3$o, templateObject_4$i, templateObject_5$b;
|
|
5134
5063
|
|
|
5135
5064
|
var IdCapture = function IdCapture(_a) {
|
|
5136
|
-
var _b, _c, _d, _e, _f, _g, _h
|
|
5065
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
5137
5066
|
var requiredDocumentType = _a.requiredDocumentType,
|
|
5138
|
-
|
|
5139
|
-
thresholds =
|
|
5067
|
+
_j = _a.thresholds,
|
|
5068
|
+
thresholds = _j === void 0 ? defaultIdCaptureThresholds : _j,
|
|
5140
5069
|
guidanceMessage = _a.guidanceMessage,
|
|
5141
5070
|
guidanceSatisfied = _a.guidanceSatisfied,
|
|
5142
5071
|
onCapture = _a.onCapture,
|
|
5143
|
-
|
|
5144
|
-
classNames =
|
|
5145
|
-
|
|
5146
|
-
colors =
|
|
5147
|
-
|
|
5148
|
-
rawVerbiage =
|
|
5149
|
-
|
|
5150
|
-
debugMode =
|
|
5151
|
-
var
|
|
5152
|
-
ref =
|
|
5153
|
-
|
|
5154
|
-
width =
|
|
5155
|
-
|
|
5156
|
-
height =
|
|
5157
|
-
var
|
|
5158
|
-
state =
|
|
5159
|
-
dispatch =
|
|
5160
|
-
var
|
|
5072
|
+
_k = _a.classNames,
|
|
5073
|
+
classNames = _k === void 0 ? {} : _k,
|
|
5074
|
+
_l = _a.colors,
|
|
5075
|
+
colors = _l === void 0 ? {} : _l,
|
|
5076
|
+
_m = _a.verbiage,
|
|
5077
|
+
rawVerbiage = _m === void 0 ? {} : _m,
|
|
5078
|
+
_o = _a.debugMode,
|
|
5079
|
+
debugMode = _o === void 0 ? false : _o;
|
|
5080
|
+
var _p = useResizeObserver__default.default(),
|
|
5081
|
+
ref = _p.ref,
|
|
5082
|
+
_q = _p.width,
|
|
5083
|
+
width = _q === void 0 ? 1 : _q,
|
|
5084
|
+
_r = _p.height,
|
|
5085
|
+
height = _r === void 0 ? 1 : _r;
|
|
5086
|
+
var _s = useIdCaptureState(),
|
|
5087
|
+
state = _s[0],
|
|
5088
|
+
dispatch = _s[1];
|
|
5089
|
+
var _t = useCameraStore(),
|
|
5090
|
+
camera = _t.camera,
|
|
5091
|
+
isRearFacing = _t.isRearFacing;
|
|
5161
5092
|
var _u = React.useContext(IdCaptureModelsContext),
|
|
5162
5093
|
modelsReady = _u.ready,
|
|
5163
5094
|
setThresholds = _u.setThresholds,
|
|
@@ -5269,17 +5200,16 @@ var IdCapture = function IdCapture(_a) {
|
|
|
5269
5200
|
classNames: classNames.overrideWrongDocumentTypeGuidanceDialog,
|
|
5270
5201
|
verbiage: rawVerbiage.overrideWrongDocumentTypeGuidanceDialog
|
|
5271
5202
|
}))), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugBoundingBoxOverlay, {
|
|
5272
|
-
"$flipX": !
|
|
5203
|
+
"$flipX": !isRearFacing,
|
|
5273
5204
|
scaling: debugScalingDetails
|
|
5274
5205
|
}, state.detectedObjects.map(function (obj, i) {
|
|
5275
|
-
var _a;
|
|
5276
5206
|
return /*#__PURE__*/React__namespace.default.createElement(IdCaptureDetectedObjectDebugBox, {
|
|
5277
5207
|
key: i,
|
|
5278
5208
|
obj: obj,
|
|
5279
5209
|
scaling: debugScalingDetails,
|
|
5280
|
-
flipX: !
|
|
5210
|
+
flipX: !isRearFacing
|
|
5281
5211
|
});
|
|
5282
|
-
}))), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null,
|
|
5212
|
+
}))), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__namespace.default.createElement("br", null), state.frameCaptureRate > 0.75 ? '✅' : '👎', " Frame Rate:", ' ', Math.round((state.frameCaptureRate + Number.EPSILON) * 1000) / 1000, ' ', "fps (", detectionTime, "ms doc detect, ", focusPredictionTime, "ms focus)", /*#__PURE__*/React__namespace.default.createElement("br", null), modelsReady ? ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React__namespace.default.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__namespace.default.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React__namespace.default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, "\u274C Models not ready")))));
|
|
5283
5213
|
};
|
|
5284
5214
|
var timeSince = function timeSince(t) {
|
|
5285
5215
|
if (!t) return 0;
|
|
@@ -5296,7 +5226,9 @@ var CameraAccessDeniedOverlay = function CameraAccessDeniedOverlay(_a) {
|
|
|
5296
5226
|
colors = _e === void 0 ? {} : _e,
|
|
5297
5227
|
_f = _a.verbiage,
|
|
5298
5228
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
5299
|
-
var requestCameraAccess =
|
|
5229
|
+
var requestCameraAccess = useCameraStore(function (state) {
|
|
5230
|
+
return state.requestCameraAccess;
|
|
5231
|
+
});
|
|
5300
5232
|
assets.imageUrl || (assets.imageUrl = DEFAULT_CDN_URL + '/camera-disable-icon.png');
|
|
5301
5233
|
var verbiage = useTranslations(rawVerbiage, {
|
|
5302
5234
|
headingText: 'Your camera permission is disabled',
|
|
@@ -5944,7 +5876,7 @@ var IdCaptureLoadingOverlayDefault = function IdCaptureLoadingOverlayDefault(_a)
|
|
|
5944
5876
|
var _o = React.useContext(IdCaptureModelsContext),
|
|
5945
5877
|
modelsReady = _o.ready,
|
|
5946
5878
|
modelDownloadProgress = _o.modelDownloadProgress;
|
|
5947
|
-
var _p =
|
|
5879
|
+
var _p = useCameraStore(),
|
|
5948
5880
|
cameraReady = _p.cameraReady,
|
|
5949
5881
|
cameraAccessDenied = _p.cameraAccessDenied,
|
|
5950
5882
|
iphoneContinuityCameraAvailable = _p.iphoneContinuityCameraAvailable,
|
|
@@ -6142,7 +6074,14 @@ var IdCaptureLoadingOverlayLegacy = function IdCaptureLoadingOverlayLegacy(_a) {
|
|
|
6142
6074
|
var _l = React.useContext(IdCaptureModelsContext),
|
|
6143
6075
|
modelsReady = _l.ready,
|
|
6144
6076
|
modelDownloadProgress = _l.modelDownloadProgress;
|
|
6145
|
-
var _m =
|
|
6077
|
+
var _m = useCameraStore(shallow.useShallow(function (state) {
|
|
6078
|
+
return {
|
|
6079
|
+
cameraReady: state.cameraReady,
|
|
6080
|
+
cameraAccessDenied: state.cameraAccessDenied,
|
|
6081
|
+
iphoneContinuityCameraAvailable: state.iphoneContinuityCameraAvailable,
|
|
6082
|
+
setIphoneContinuityCameraAllowed: state.setIphoneContinuityCameraAllowed
|
|
6083
|
+
};
|
|
6084
|
+
})),
|
|
6146
6085
|
cameraReady = _m.cameraReady,
|
|
6147
6086
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
6148
6087
|
iphoneContinuityCameraAvailable = _m.iphoneContinuityCameraAvailable,
|
|
@@ -6688,23 +6627,24 @@ function getOrientation(allowPortraitOnMobile) {
|
|
|
6688
6627
|
}
|
|
6689
6628
|
|
|
6690
6629
|
var IdVideoCaptureFlipIdPrompt = function IdVideoCaptureFlipIdPrompt(_a) {
|
|
6691
|
-
var _b
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
classNames = _d === void 0 ? {} : _d,
|
|
6630
|
+
var _b = _a.idCaptureGuideImages,
|
|
6631
|
+
idCaptureGuideImages = _b === void 0 ? defaultIdCaptureGuideImages : _b,
|
|
6632
|
+
_c = _a.classNames,
|
|
6633
|
+
classNames = _c === void 0 ? {} : _c,
|
|
6696
6634
|
borderWidth = _a.borderWidth,
|
|
6697
6635
|
borderColor = _a.borderColor,
|
|
6698
6636
|
borderRadius = _a.borderRadius,
|
|
6699
6637
|
imageStyle = _a.imageStyle;
|
|
6700
|
-
var
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6638
|
+
var isRearFacing = useCameraStore(function (state) {
|
|
6639
|
+
return state.isRearFacing;
|
|
6640
|
+
});
|
|
6641
|
+
var isMirrored = !isRearFacing;
|
|
6642
|
+
var _d = React.useState(1),
|
|
6643
|
+
transitionTime = _d[0],
|
|
6644
|
+
setTransitionTime = _d[1];
|
|
6645
|
+
var _e = React.useState(0),
|
|
6646
|
+
rotationAngle = _e[0],
|
|
6647
|
+
setRotationAngle = _e[1];
|
|
6708
6648
|
var frontTransforms = ["rotateY(".concat(rotationAngle, "deg)")];
|
|
6709
6649
|
if (isMirrored) frontTransforms.push('scaleX(-1)');
|
|
6710
6650
|
var backTransforms = ["rotateY(".concat(180 - rotationAngle, "deg)")];
|
|
@@ -7228,29 +7168,30 @@ var Canvas$1 = styled__default.default.canvas(templateObject_2$n || (templateObj
|
|
|
7228
7168
|
var templateObject_1$r, templateObject_2$n;
|
|
7229
7169
|
|
|
7230
7170
|
function IdCaptureGuides(_a) {
|
|
7231
|
-
var _b,
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
rawVerbiage = _o === void 0 ? {} : _o;
|
|
7171
|
+
var _b = _a.guideType,
|
|
7172
|
+
guideType = _b === void 0 ? 'fit' : _b,
|
|
7173
|
+
_c = _a.status,
|
|
7174
|
+
status = _c === void 0 ? 'ready' : _c,
|
|
7175
|
+
_d = _a.progress,
|
|
7176
|
+
progress = _d === void 0 ? 0 : _d,
|
|
7177
|
+
_e = _a.portraitGuidesOnMobile,
|
|
7178
|
+
portraitGuidesOnMobile = _e === void 0 ? true : _e,
|
|
7179
|
+
_f = _a.requestedAction,
|
|
7180
|
+
requestedAction = _f === void 0 ? 'SHOW_ID_FRONT' : _f,
|
|
7181
|
+
_g = _a.isBackToFront,
|
|
7182
|
+
isBackToFront = _g === void 0 ? false : _g,
|
|
7183
|
+
_h = _a.images,
|
|
7184
|
+
images = _h === void 0 ? defaultIdCaptureGuideImages : _h,
|
|
7185
|
+
_j = _a.classNames,
|
|
7186
|
+
classNames = _j === void 0 ? {} : _j,
|
|
7187
|
+
_k = _a.colors,
|
|
7188
|
+
colors = _k === void 0 ? {} : _k,
|
|
7189
|
+
_l = _a.verbiage,
|
|
7190
|
+
rawVerbiage = _l === void 0 ? {} : _l;
|
|
7252
7191
|
var state = useIdCaptureState()[0];
|
|
7253
|
-
var
|
|
7192
|
+
var isRearFacing = useCameraStore(function (state) {
|
|
7193
|
+
return state.isRearFacing;
|
|
7194
|
+
});
|
|
7254
7195
|
var verbiage = useTranslations(rawVerbiage, {
|
|
7255
7196
|
instructionText: 'Scan the front of ID',
|
|
7256
7197
|
capturingText: 'Capturing...',
|
|
@@ -7262,7 +7203,7 @@ function IdCaptureGuides(_a) {
|
|
|
7262
7203
|
status: status,
|
|
7263
7204
|
progress: progress,
|
|
7264
7205
|
instruction: state.captureFailed ? verbiage.captureFailedText : state.capturing ? verbiage === null || verbiage === void 0 ? void 0 : verbiage.capturingText : verbiage.instructionText,
|
|
7265
|
-
isMirrored: !
|
|
7206
|
+
isMirrored: !isRearFacing,
|
|
7266
7207
|
borderColor: state.isGoodFrame ? colors.guideBoxSatisfiedColor : colors.guideBoxUnsatisfiedColor,
|
|
7267
7208
|
imageVisible: requestedAction === 'FLIP_ID' || !state.idCardFrontDetectionThresholdMet || !state.documentInBounds || state.documentTooClose
|
|
7268
7209
|
})), guideType === 'fit' && ( /*#__PURE__*/React__namespace.default.createElement(IdCaptureFitGuide, {
|
|
@@ -7272,7 +7213,7 @@ function IdCaptureGuides(_a) {
|
|
|
7272
7213
|
status: status,
|
|
7273
7214
|
progress: progress,
|
|
7274
7215
|
instruction: state.captureFailed ? verbiage.captureFailedText : state.capturing ? verbiage === null || verbiage === void 0 ? void 0 : verbiage.capturingText : verbiage.instructionText,
|
|
7275
|
-
isMirrored: !
|
|
7216
|
+
isMirrored: !isRearFacing,
|
|
7276
7217
|
isBackToFront: isBackToFront,
|
|
7277
7218
|
portraitGuidesOnMobile: portraitGuidesOnMobile,
|
|
7278
7219
|
borderColor: state.isGoodFrame ? colors.guideBoxSatisfiedColor : colors.guideBoxUnsatisfiedColor,
|
|
@@ -7371,48 +7312,6 @@ var ImagePreviewText = styled__default.default.div(templateObject_3$h || (templa
|
|
|
7371
7312
|
var ImagePreviewImageWrapper = styled__default.default.div(templateObject_4$b || (templateObject_4$b = __makeTemplateObject(["\n position: relative;\n height: calc(100% - 8px);\n padding: 4px;\n border-radius: 4px;\n background: white;\n\n & > img {\n border-radius: 4px;\n width: auto;\n max-height: 100%;\n }\n"], ["\n position: relative;\n height: calc(100% - 8px);\n padding: 4px;\n border-radius: 4px;\n background: white;\n\n & > img {\n border-radius: 4px;\n width: auto;\n max-height: 100%;\n }\n"])));
|
|
7372
7313
|
var templateObject_1$q, templateObject_2$m, templateObject_3$h, templateObject_4$b;
|
|
7373
7314
|
|
|
7374
|
-
var CameraVideoTag = function CameraVideoTag(_a) {
|
|
7375
|
-
var _b;
|
|
7376
|
-
var className = _a.className;
|
|
7377
|
-
var _c = React.useContext(CameraStateContext),
|
|
7378
|
-
videoRef = _c.videoRef,
|
|
7379
|
-
setVideoLoaded = _c.setVideoLoaded,
|
|
7380
|
-
onVideoUnmounted = _c.onVideoUnmounted,
|
|
7381
|
-
cameraRef = _c.cameraRef;
|
|
7382
|
-
React.useEffect(function notifyCameraProviderOfUnmount() {
|
|
7383
|
-
var videoElement = videoRef.current;
|
|
7384
|
-
if (!videoElement) return;
|
|
7385
|
-
return function () {
|
|
7386
|
-
onVideoUnmounted(videoElement);
|
|
7387
|
-
};
|
|
7388
|
-
}, [onVideoUnmounted, videoRef]);
|
|
7389
|
-
React.useEffect(function setVideoLoadedToFalseOnMount() {
|
|
7390
|
-
setVideoLoaded(false);
|
|
7391
|
-
}, [setVideoLoaded]);
|
|
7392
|
-
React.useEffect(function attachCameraStreamToVideoTagWhenReady() {
|
|
7393
|
-
var _a;
|
|
7394
|
-
if (videoRef.current && ((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.stream)) {
|
|
7395
|
-
videoRef.current.srcObject = cameraRef.current.stream;
|
|
7396
|
-
}
|
|
7397
|
-
}, [cameraRef, videoRef]);
|
|
7398
|
-
var onLoadedData = React.useCallback(function () {
|
|
7399
|
-
setVideoLoaded(true);
|
|
7400
|
-
}, [setVideoLoaded]);
|
|
7401
|
-
return /*#__PURE__*/React__namespace.default.createElement(FullscreenVideoTag, {
|
|
7402
|
-
className: className,
|
|
7403
|
-
autoPlay: true,
|
|
7404
|
-
playsInline: true,
|
|
7405
|
-
muted: true,
|
|
7406
|
-
ref: videoRef,
|
|
7407
|
-
onLoadedData: onLoadedData,
|
|
7408
|
-
"$isRearFacing": (_b = cameraRef.current) === null || _b === void 0 ? void 0 : _b.isRearFacing
|
|
7409
|
-
});
|
|
7410
|
-
};
|
|
7411
|
-
var FullscreenVideoTag = styled__default.default.video(templateObject_1$p || (templateObject_1$p = __makeTemplateObject(["\n transform: ", ";\n transform-style: preserve-3d;\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n max-width: 100%;\n max-height: 100%;\n object-fit: cover;\n background: black;\n z-index: -2;\n"], ["\n transform: ", ";\n transform-style: preserve-3d;\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n max-width: 100%;\n max-height: 100%;\n object-fit: cover;\n background: black;\n z-index: -2;\n"])), function (props) {
|
|
7412
|
-
return props.$isRearFacing ? '' : 'scaleX(-1)';
|
|
7413
|
-
});
|
|
7414
|
-
var templateObject_1$p;
|
|
7415
|
-
|
|
7416
7315
|
var documentCaptureInitialState = {
|
|
7417
7316
|
documents: [],
|
|
7418
7317
|
currentDocumentIndex: 0,
|
|
@@ -7531,8 +7430,8 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7531
7430
|
var _c = React.useReducer(documentCaptureStateReducer, documentCaptureInitialState),
|
|
7532
7431
|
state = _c[0],
|
|
7533
7432
|
dispatch = _c[1];
|
|
7534
|
-
var _d =
|
|
7535
|
-
|
|
7433
|
+
var _d = useCameraStore(),
|
|
7434
|
+
videoStream = _d.videoStream,
|
|
7536
7435
|
videoRef = _d.videoRef;
|
|
7537
7436
|
var uploadDocument = React.useContext(SubmissionContext).uploadDocument;
|
|
7538
7437
|
var uploadCapturedDocument = React.useCallback(function (content, filetype) {
|
|
@@ -7623,8 +7522,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7623
7522
|
}, [onResize]);
|
|
7624
7523
|
var videoTag = videoRef.current;
|
|
7625
7524
|
React.useEffect(function () {
|
|
7626
|
-
if (!state.capturing) return;
|
|
7627
|
-
if (!cameraRef.current) return;
|
|
7525
|
+
if (!state.capturing || !(videoStream === null || videoStream === void 0 ? void 0 : videoStream.active)) return;
|
|
7628
7526
|
function onComplete(content) {
|
|
7629
7527
|
if (!content) return;
|
|
7630
7528
|
var contentUrl = URL.createObjectURL(content);
|
|
@@ -7637,7 +7535,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7637
7535
|
});
|
|
7638
7536
|
}
|
|
7639
7537
|
if (typeof ImageCapture !== 'undefined') {
|
|
7640
|
-
var tracks =
|
|
7538
|
+
var tracks = videoStream.getTracks();
|
|
7641
7539
|
var videoCameraTrack = tracks.find(function (track) {
|
|
7642
7540
|
return track.kind === 'video';
|
|
7643
7541
|
});
|
|
@@ -7652,7 +7550,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7652
7550
|
drawToCanvas(canvas, videoTag);
|
|
7653
7551
|
canvas.toBlob(onComplete);
|
|
7654
7552
|
}
|
|
7655
|
-
}, [
|
|
7553
|
+
}, [state.capturing, videoStream, videoTag]);
|
|
7656
7554
|
var stateWithActions = React.useMemo(function () {
|
|
7657
7555
|
return _assign(_assign({}, state), {
|
|
7658
7556
|
uploadCapturedDocument: uploadCapturedDocument
|
|
@@ -7767,52 +7665,85 @@ var DocumentCaptureGuideOverlay = function DocumentCaptureGuideOverlay(_a) {
|
|
|
7767
7665
|
ref: canvasRef
|
|
7768
7666
|
}));
|
|
7769
7667
|
};
|
|
7770
|
-
var CanvasWrapper = styled__default.default.div(templateObject_1$
|
|
7668
|
+
var CanvasWrapper = styled__default.default.div(templateObject_1$p || (templateObject_1$p = __makeTemplateObject(["\n flex-grow: 1;\n background-clip: padding-box;\n box-shadow: inset 0 0 0 2px ", ";\n"], ["\n flex-grow: 1;\n background-clip: padding-box;\n box-shadow: inset 0 0 0 2px ", ";\n"])), function (props) {
|
|
7771
7669
|
return props.$maskColor;
|
|
7772
7670
|
});
|
|
7773
7671
|
var Canvas = styled__default.default.canvas(templateObject_2$l || (templateObject_2$l = __makeTemplateObject(["\n display: block;\n"], ["\n display: block;\n"])));
|
|
7774
|
-
var templateObject_1$
|
|
7672
|
+
var templateObject_1$p, templateObject_2$l;
|
|
7775
7673
|
|
|
7776
|
-
var CameraFeedWrapper = styled__default.default.div(templateObject_1$
|
|
7674
|
+
var CameraFeedWrapper = styled__default.default.div(templateObject_1$o || (templateObject_1$o = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (props) {
|
|
7777
7675
|
return props.$mode === 'snapToGuides' ? "display: flex;\n position: absolute;\n left: ".concat(props.$x, "px;\n top: ").concat(props.$y, "px;\n width: ").concat(props.$w, "px;\n height: ").concat(props.$h, "px;") : "";
|
|
7778
7676
|
});
|
|
7677
|
+
var templateObject_1$o;
|
|
7678
|
+
|
|
7679
|
+
var CameraVideoTag = function CameraVideoTag(props) {
|
|
7680
|
+
var _a = useCameraStore(shallow.useShallow(function (store) {
|
|
7681
|
+
return {
|
|
7682
|
+
videoRef: store.videoRef,
|
|
7683
|
+
videoStream: store.videoStream,
|
|
7684
|
+
onVideoMounted: store.onVideoMounted,
|
|
7685
|
+
isRearFacing: store.isRearFacing
|
|
7686
|
+
};
|
|
7687
|
+
})),
|
|
7688
|
+
videoRef = _a.videoRef,
|
|
7689
|
+
videoStream = _a.videoStream,
|
|
7690
|
+
onVideoMounted = _a.onVideoMounted,
|
|
7691
|
+
isRearFacing = _a.isRearFacing;
|
|
7692
|
+
React.useEffect(function attachCameraStreamToVideoTagWhenReady() {
|
|
7693
|
+
if (videoRef.current && videoStream) {
|
|
7694
|
+
debug('attaching camera stream to video tag');
|
|
7695
|
+
videoRef.current.srcObject = videoStream;
|
|
7696
|
+
}
|
|
7697
|
+
}, [videoStream, videoRef]);
|
|
7698
|
+
return /*#__PURE__*/React__namespace.default.createElement(FullscreenVideoTag, _assign({
|
|
7699
|
+
autoPlay: true,
|
|
7700
|
+
playsInline: true,
|
|
7701
|
+
muted: true,
|
|
7702
|
+
ref: videoRef,
|
|
7703
|
+
onLoadedData: onVideoMounted,
|
|
7704
|
+
"$isRearFacing": isRearFacing
|
|
7705
|
+
}, props));
|
|
7706
|
+
};
|
|
7707
|
+
var FullscreenVideoTag = styled__default.default.video(templateObject_1$n || (templateObject_1$n = __makeTemplateObject(["\n transform: ", ";\n transform-style: preserve-3d;\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n max-width: 100%;\n max-height: 100%;\n object-fit: cover;\n background: black;\n z-index: -2;\n"], ["\n transform: ", ";\n transform-style: preserve-3d;\n min-width: 100%;\n min-height: 100%;\n width: auto;\n height: auto;\n max-width: 100%;\n max-height: 100%;\n object-fit: cover;\n background: black;\n z-index: -2;\n"])), function (props) {
|
|
7708
|
+
return props.$isRearFacing ? '' : 'scaleX(-1)';
|
|
7709
|
+
});
|
|
7779
7710
|
var templateObject_1$n;
|
|
7780
7711
|
|
|
7781
7712
|
var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
|
|
7782
|
-
var _b, _c, _d, _e, _f
|
|
7713
|
+
var _b, _c, _d, _e, _f;
|
|
7783
7714
|
var onCaptureClicked = _a.onCaptureClicked,
|
|
7784
|
-
|
|
7785
|
-
classNames =
|
|
7786
|
-
|
|
7787
|
-
rawVerbiage =
|
|
7788
|
-
var
|
|
7789
|
-
|
|
7790
|
-
documents =
|
|
7791
|
-
currentDocumentIndex =
|
|
7792
|
-
rectX =
|
|
7793
|
-
rectY =
|
|
7794
|
-
rectWidth =
|
|
7795
|
-
rectHeight =
|
|
7796
|
-
rectOffsetTop =
|
|
7797
|
-
capturing =
|
|
7798
|
-
uploadCapturedDocument =
|
|
7799
|
-
dispatch =
|
|
7800
|
-
var
|
|
7801
|
-
title =
|
|
7802
|
-
aspectRatio =
|
|
7803
|
-
cameraFeedMode =
|
|
7804
|
-
instructions =
|
|
7805
|
-
contentUrl =
|
|
7806
|
-
content =
|
|
7807
|
-
uploadState =
|
|
7808
|
-
var
|
|
7809
|
-
|
|
7810
|
-
cameraReady =
|
|
7811
|
-
cameraAccessDenied =
|
|
7812
|
-
requestCameraAccess =
|
|
7813
|
-
var
|
|
7814
|
-
cameraAccessRequested =
|
|
7815
|
-
setCameraAccessRequested =
|
|
7715
|
+
_g = _a.classNames,
|
|
7716
|
+
classNames = _g === void 0 ? {} : _g,
|
|
7717
|
+
_h = _a.verbiage,
|
|
7718
|
+
rawVerbiage = _h === void 0 ? {} : _h;
|
|
7719
|
+
var _j = useDocumentCaptureState(),
|
|
7720
|
+
_k = _j[0],
|
|
7721
|
+
documents = _k.documents,
|
|
7722
|
+
currentDocumentIndex = _k.currentDocumentIndex,
|
|
7723
|
+
rectX = _k.rectX,
|
|
7724
|
+
rectY = _k.rectY,
|
|
7725
|
+
rectWidth = _k.rectWidth,
|
|
7726
|
+
rectHeight = _k.rectHeight,
|
|
7727
|
+
rectOffsetTop = _k.rectOffsetTop,
|
|
7728
|
+
capturing = _k.capturing,
|
|
7729
|
+
uploadCapturedDocument = _k.uploadCapturedDocument,
|
|
7730
|
+
dispatch = _j[1];
|
|
7731
|
+
var _l = (_b = documents[currentDocumentIndex]) !== null && _b !== void 0 ? _b : {},
|
|
7732
|
+
title = _l.title,
|
|
7733
|
+
aspectRatio = _l.aspectRatio,
|
|
7734
|
+
cameraFeedMode = _l.cameraFeedMode,
|
|
7735
|
+
instructions = _l.instructions,
|
|
7736
|
+
contentUrl = _l.contentUrl,
|
|
7737
|
+
content = _l.content,
|
|
7738
|
+
uploadState = _l.uploadState;
|
|
7739
|
+
var _m = useCameraStore(),
|
|
7740
|
+
videoStream = _m.videoStream,
|
|
7741
|
+
cameraReady = _m.cameraReady,
|
|
7742
|
+
cameraAccessDenied = _m.cameraAccessDenied,
|
|
7743
|
+
requestCameraAccess = _m.requestCameraAccess;
|
|
7744
|
+
var _o = React.useState(false),
|
|
7745
|
+
cameraAccessRequested = _o[0],
|
|
7746
|
+
setCameraAccessRequested = _o[1];
|
|
7816
7747
|
var cameraAccessNeeded =
|
|
7817
7748
|
// we should force the browser to ask for camera access if...
|
|
7818
7749
|
uploadState === 'not_started' &&
|
|
@@ -7821,14 +7752,14 @@ var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
|
|
|
7821
7752
|
// and the user hasn't passed a media blob for the current document...
|
|
7822
7753
|
!cameraAccessRequested &&
|
|
7823
7754
|
// and we haven't already tried to force a camera request...
|
|
7824
|
-
!(
|
|
7755
|
+
!(videoStream === null || videoStream === void 0 ? void 0 : videoStream.active); // and we don't already have camera access.
|
|
7825
7756
|
React.useEffect(function requestCameraAccessIfNeeded() {
|
|
7826
7757
|
if (!cameraAccessNeeded) return;
|
|
7827
7758
|
setCameraAccessRequested(true);
|
|
7828
7759
|
requestCameraAccess();
|
|
7829
7760
|
}, [cameraAccessNeeded, requestCameraAccess]);
|
|
7830
7761
|
var theme = styled.useTheme();
|
|
7831
|
-
var maskColor = (
|
|
7762
|
+
var maskColor = (_e = (_d = (_c = theme.documentCapture) === null || _c === void 0 ? void 0 : _c.guideBox) === null || _d === void 0 ? void 0 : _d.maskColor) !== null && _e !== void 0 ? _e : cameraFeedMode === 'snapToGuides' ? '#708090' : "rgba(0, 0, 0, 0.5)";
|
|
7832
7763
|
var verbiage = useTranslations(rawVerbiage, {
|
|
7833
7764
|
headingText: title,
|
|
7834
7765
|
loadingBtnText: 'Camera initializing...',
|
|
@@ -7861,7 +7792,7 @@ var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
|
|
|
7861
7792
|
});
|
|
7862
7793
|
}
|
|
7863
7794
|
return /*#__PURE__*/React__namespace.default.createElement(PageContainer, {
|
|
7864
|
-
className: "flex ".concat((
|
|
7795
|
+
className: "flex ".concat((_f = classNames.container) !== null && _f !== void 0 ? _f : '')
|
|
7865
7796
|
}, /*#__PURE__*/React__namespace.default.createElement(CameraFeedWrapper, {
|
|
7866
7797
|
className: classNames.cameraFeedWrapper,
|
|
7867
7798
|
"$mode": cameraFeedMode !== null && cameraFeedMode !== void 0 ? cameraFeedMode : 'snapToGuides',
|
|
@@ -8286,7 +8217,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
8286
8217
|
var _3 = useIdCaptureState(),
|
|
8287
8218
|
state = _3[0],
|
|
8288
8219
|
dispatch = _3[1];
|
|
8289
|
-
var _4 =
|
|
8220
|
+
var _4 = useCameraStore(),
|
|
8290
8221
|
cameraAccessDenied = _4.cameraAccessDenied,
|
|
8291
8222
|
requestCameraAccess = _4.requestCameraAccess,
|
|
8292
8223
|
releaseCameraAccess = _4.releaseCameraAccess;
|
|
@@ -8411,7 +8342,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
8411
8342
|
type: 'resetWizard'
|
|
8412
8343
|
});
|
|
8413
8344
|
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
8414
|
-
requestCameraAccess();
|
|
8345
|
+
void requestCameraAccess();
|
|
8415
8346
|
}, [dispatch, onExitCapture, releaseCameraAccess, requestCameraAccess]);
|
|
8416
8347
|
React.useEffect(function () {
|
|
8417
8348
|
if (submissionStatus !== SubmissionStatus.READY) {
|
|
@@ -9234,7 +9165,13 @@ function SelfieGuidanceModelsProvider(_a) {
|
|
|
9234
9165
|
modelLoadTimeoutMs = _c === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _c,
|
|
9235
9166
|
_d = _a.requireVerticalFaceCentering,
|
|
9236
9167
|
requireVerticalFaceCentering = _d === void 0 ? true : _d;
|
|
9237
|
-
var _e =
|
|
9168
|
+
var _e = useCameraStore(shallow.useShallow(function (state) {
|
|
9169
|
+
return {
|
|
9170
|
+
videoRef: state.videoRef,
|
|
9171
|
+
videoLoaded: state.videoLoaded,
|
|
9172
|
+
cameraReady: state.cameraReady
|
|
9173
|
+
};
|
|
9174
|
+
})),
|
|
9238
9175
|
videoRef = _e.videoRef,
|
|
9239
9176
|
videoLoaded = _e.videoLoaded,
|
|
9240
9177
|
cameraReady = _e.cameraReady;
|
|
@@ -9242,7 +9179,8 @@ function SelfieGuidanceModelsProvider(_a) {
|
|
|
9242
9179
|
var onPredictionHandler = React.useRef();
|
|
9243
9180
|
var _f = useLoadFaceDetector({
|
|
9244
9181
|
onModelError: onModelError,
|
|
9245
|
-
modelLoadTimeoutMs: modelLoadTimeoutMs
|
|
9182
|
+
modelLoadTimeoutMs: modelLoadTimeoutMs,
|
|
9183
|
+
videoRef: videoRef
|
|
9246
9184
|
}),
|
|
9247
9185
|
ready = _f.ready,
|
|
9248
9186
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
@@ -9575,8 +9513,14 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
9575
9513
|
prediction = _t.prediction,
|
|
9576
9514
|
dispatch = _s[1];
|
|
9577
9515
|
var lastPredictionCanvas = React.useRef(null);
|
|
9578
|
-
var _u =
|
|
9579
|
-
|
|
9516
|
+
var _u = useCameraStore(shallow.useShallow(function (state) {
|
|
9517
|
+
return {
|
|
9518
|
+
camera: state.camera,
|
|
9519
|
+
cameraReady: state.cameraReady,
|
|
9520
|
+
videoRef: state.videoRef
|
|
9521
|
+
};
|
|
9522
|
+
})),
|
|
9523
|
+
camera = _u.camera,
|
|
9580
9524
|
videoRef = _u.videoRef;
|
|
9581
9525
|
var _v = React.useContext(SelfieGuidanceModelsContext),
|
|
9582
9526
|
onPredictionMade = _v.onPredictionMade,
|
|
@@ -9666,7 +9610,7 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
9666
9610
|
face: prediction.face,
|
|
9667
9611
|
scaling: debugScalingDetails,
|
|
9668
9612
|
color: satisfied ? 'green' : 'red'
|
|
9669
|
-
}))), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null,
|
|
9613
|
+
}))), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__namespace.default.createElement("br", null), !(prediction === null || prediction === void 0 ? void 0 : prediction.faceNotCentered) ? '✅' : '❌', " Face Centered", /*#__PURE__*/React__namespace.default.createElement("br", null), !(prediction === null || prediction === void 0 ? void 0 : prediction.faceTooClose) && !(prediction === null || prediction === void 0 ? void 0 : prediction.faceTooFar) ? '✅' : '❌', ' ', "Face", ' ', (prediction === null || prediction === void 0 ? void 0 : prediction.faceTooClose) ? 'Too Close' : (prediction === null || prediction === void 0 ? void 0 : prediction.faceTooFar) ? 'Too Far' : 'Distance Correct', /*#__PURE__*/React__namespace.default.createElement("br", null), !(prediction === null || prediction === void 0 ? void 0 : prediction.faceLookingAway) ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React__namespace.default.createElement("br", null), !(prediction === null || prediction === void 0 ? void 0 : prediction.faceIsStable) ? '✅' : '❌', " Face Is Stable", /*#__PURE__*/React__namespace.default.createElement("br", null), !timedOut ? '✅' : '❌', " Time Remaining:", ' ', Math.max(0, timeoutDurationMs - (new Date().getTime() - (timeoutStartedAt !== null && timeoutStartedAt !== void 0 ? timeoutStartedAt : new Date()).getTime())), "ms")), /*#__PURE__*/React__namespace.default.createElement(ExitCaptureButton, {
|
|
9670
9614
|
onClick: onExit,
|
|
9671
9615
|
className: classNames.exitCaptureBtn
|
|
9672
9616
|
}));
|
|
@@ -10122,7 +10066,9 @@ var MicrophoneAccessDeniedOverlay = function MicrophoneAccessDeniedOverlay(_a) {
|
|
|
10122
10066
|
colors = _e === void 0 ? {} : _e,
|
|
10123
10067
|
_f = _a.verbiage,
|
|
10124
10068
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
10125
|
-
var requestMicrophoneAccess =
|
|
10069
|
+
var requestMicrophoneAccess = useCameraStore(function (state) {
|
|
10070
|
+
return state.requestMicrophoneAccess;
|
|
10071
|
+
});
|
|
10126
10072
|
assets.imageUrl || (assets.imageUrl = DEFAULT_CDN_URL + '/microphone-disable-icon.svg');
|
|
10127
10073
|
var verbiage = useTranslations(rawVerbiage, {
|
|
10128
10074
|
headingText: 'Your microphone permission is disabled',
|
|
@@ -10170,7 +10116,13 @@ var SelfieCaptureLoadingOverlayLegacy = function SelfieCaptureLoadingOverlayLega
|
|
|
10170
10116
|
colors = _e === void 0 ? {} : _e,
|
|
10171
10117
|
_f = _a.verbiage,
|
|
10172
10118
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
10173
|
-
var _g =
|
|
10119
|
+
var _g = useCameraStore(shallow.useShallow(function (state) {
|
|
10120
|
+
return {
|
|
10121
|
+
cameraReady: state.cameraReady,
|
|
10122
|
+
cameraAccessDenied: state.cameraAccessDenied,
|
|
10123
|
+
microphoneAccessDenied: state.microphoneAccessDenied
|
|
10124
|
+
};
|
|
10125
|
+
})),
|
|
10174
10126
|
cameraReady = _g.cameraReady,
|
|
10175
10127
|
cameraAccessDenied = _g.cameraAccessDenied,
|
|
10176
10128
|
microphoneAccessDenied = _g.microphoneAccessDenied;
|
|
@@ -10257,7 +10209,13 @@ var SelfieCaptureLoadingOverlayDefault = function SelfieCaptureLoadingOverlayDef
|
|
|
10257
10209
|
colors = _e === void 0 ? {} : _e,
|
|
10258
10210
|
_f = _a.verbiage,
|
|
10259
10211
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
10260
|
-
var _g =
|
|
10212
|
+
var _g = useCameraStore(shallow.useShallow(function (state) {
|
|
10213
|
+
return {
|
|
10214
|
+
cameraReady: state.cameraReady,
|
|
10215
|
+
cameraAccessDenied: state.cameraAccessDenied,
|
|
10216
|
+
microphoneAccessDenied: state.microphoneAccessDenied
|
|
10217
|
+
};
|
|
10218
|
+
})),
|
|
10261
10219
|
cameraReady = _g.cameraReady,
|
|
10262
10220
|
cameraAccessDenied = _g.cameraAccessDenied,
|
|
10263
10221
|
microphoneAccessDenied = _g.microphoneAccessDenied;
|
|
@@ -10474,7 +10432,13 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
|
|
|
10474
10432
|
livenessCheckRequest = _t.livenessCheckRequest,
|
|
10475
10433
|
setSelfieImage = _t.setSelfieImage,
|
|
10476
10434
|
logSelfieCaptureAttempt = _t.logSelfieCaptureAttempt;
|
|
10477
|
-
var _u =
|
|
10435
|
+
var _u = useCameraStore(shallow.useShallow(function (state) {
|
|
10436
|
+
return {
|
|
10437
|
+
cameraAccessDenied: state.cameraAccessDenied,
|
|
10438
|
+
requestCameraAccess: state.requestCameraAccess,
|
|
10439
|
+
releaseCameraAccess: state.releaseCameraAccess
|
|
10440
|
+
};
|
|
10441
|
+
})),
|
|
10478
10442
|
cameraAccessDenied = _u.cameraAccessDenied,
|
|
10479
10443
|
requestCameraAccess = _u.requestCameraAccess,
|
|
10480
10444
|
releaseCameraAccess = _u.releaseCameraAccess;
|
|
@@ -11195,10 +11159,10 @@ function VideoSignatureContextProvider(_a) {
|
|
|
11195
11159
|
setSignatureVideoUrl = _e[1];
|
|
11196
11160
|
var signatureRecorder = React.useRef(null);
|
|
11197
11161
|
var recordedChunks = React.useRef([]);
|
|
11198
|
-
var _f =
|
|
11199
|
-
|
|
11162
|
+
var _f = useCameraStore(),
|
|
11163
|
+
camera = _f.camera,
|
|
11200
11164
|
videoRef = _f.videoRef;
|
|
11201
|
-
var _g = useVideoRecorder(
|
|
11165
|
+
var _g = useVideoRecorder(camera),
|
|
11202
11166
|
isRecordingVideo = _g.isRecordingVideo,
|
|
11203
11167
|
startRecordingVideo = _g.startRecordingVideo,
|
|
11204
11168
|
stopRecordingVideo = _g.stopRecordingVideo,
|
|
@@ -11266,8 +11230,8 @@ function VideoSignatureContextProvider(_a) {
|
|
|
11266
11230
|
var animationFrame = React.useRef(0);
|
|
11267
11231
|
React.useEffect(function () {
|
|
11268
11232
|
var _a;
|
|
11269
|
-
if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !
|
|
11270
|
-
var _b = [
|
|
11233
|
+
if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !camera || !isRecording || !isRecordingVideo) return;
|
|
11234
|
+
var _b = [camera.width, camera.height],
|
|
11271
11235
|
w = _b[0],
|
|
11272
11236
|
h = _b[1];
|
|
11273
11237
|
var isPortrait = typeof window !== 'undefined' && window.innerWidth < window.innerHeight;
|
|
@@ -11300,7 +11264,7 @@ function VideoSignatureContextProvider(_a) {
|
|
|
11300
11264
|
return function () {
|
|
11301
11265
|
cancelAnimationFrame(animationFrame.current);
|
|
11302
11266
|
};
|
|
11303
|
-
}, [
|
|
11267
|
+
}, [camera, isRecording, isRecordingVideo, videoRef]);
|
|
11304
11268
|
var onAcceptClicked = React.useCallback(function () {
|
|
11305
11269
|
return __awaiter(_this, void 0, void 0, function () {
|
|
11306
11270
|
var imageUrl;
|
|
@@ -11429,27 +11393,29 @@ var AcceptBtn = styled__default.default(LoaderButton)(templateObject_7$1 || (tem
|
|
|
11429
11393
|
var templateObject_1$9, templateObject_2$8, templateObject_3$8, templateObject_4$3, templateObject_5$2, templateObject_6$2, templateObject_7$1;
|
|
11430
11394
|
|
|
11431
11395
|
var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
11432
|
-
var _b
|
|
11396
|
+
var _b;
|
|
11433
11397
|
var onVideoCaptured = _a.onVideoCaptured,
|
|
11434
11398
|
onFaceNotDetected = _a.onFaceNotDetected,
|
|
11435
11399
|
onExit = _a.onExit,
|
|
11436
11400
|
guidesComponent = _a.guidesComponent,
|
|
11437
|
-
|
|
11438
|
-
classNames =
|
|
11439
|
-
|
|
11440
|
-
colors =
|
|
11441
|
-
|
|
11442
|
-
rawVerbiage =
|
|
11443
|
-
|
|
11444
|
-
debugMode =
|
|
11445
|
-
var
|
|
11401
|
+
_c = _a.classNames,
|
|
11402
|
+
classNames = _c === void 0 ? {} : _c,
|
|
11403
|
+
_d = _a.colors,
|
|
11404
|
+
colors = _d === void 0 ? {} : _d,
|
|
11405
|
+
_e = _a.verbiage,
|
|
11406
|
+
rawVerbiage = _e === void 0 ? {} : _e,
|
|
11407
|
+
_f = _a.debugMode,
|
|
11408
|
+
debugMode = _f === void 0 ? false : _f;
|
|
11409
|
+
var camera = useCameraStore(function (state) {
|
|
11410
|
+
return state.camera;
|
|
11411
|
+
});
|
|
11446
11412
|
var onPredictionMade = React.useContext(SelfieGuidanceModelsContext).onPredictionMade;
|
|
11447
|
-
var
|
|
11448
|
-
signatureData =
|
|
11449
|
-
signatureDataUrl =
|
|
11450
|
-
signatureVideoData =
|
|
11451
|
-
startRecording =
|
|
11452
|
-
stopRecording =
|
|
11413
|
+
var _g = useVideoSignatureContext(),
|
|
11414
|
+
signatureData = _g.signatureData,
|
|
11415
|
+
signatureDataUrl = _g.signatureDataUrl,
|
|
11416
|
+
signatureVideoData = _g.signatureVideoData,
|
|
11417
|
+
startRecording = _g.startRecording,
|
|
11418
|
+
stopRecording = _g.stopRecording;
|
|
11453
11419
|
React.useEffect(function () {
|
|
11454
11420
|
startRecording();
|
|
11455
11421
|
return function () {
|
|
@@ -11466,9 +11432,9 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
11466
11432
|
onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(signatureVideoData, signatureData, signatureDataUrl);
|
|
11467
11433
|
}
|
|
11468
11434
|
}, [onVideoCaptured, signatureData, signatureDataUrl, signatureVideoData]);
|
|
11469
|
-
var
|
|
11470
|
-
numFramesWithoutFaces =
|
|
11471
|
-
setNumFramesWithoutFaces =
|
|
11435
|
+
var _h = React.useState(0),
|
|
11436
|
+
numFramesWithoutFaces = _h[0],
|
|
11437
|
+
setNumFramesWithoutFaces = _h[1];
|
|
11472
11438
|
React.useEffect(function () {
|
|
11473
11439
|
onPredictionMade(function (_a) {
|
|
11474
11440
|
var face = _a.face;
|
|
@@ -11495,7 +11461,7 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
11495
11461
|
}, verbiage.guidanceMessageText))), /*#__PURE__*/React__namespace.default.createElement(GuidesComponent, {
|
|
11496
11462
|
classNames: classNames.videoSignatureGuidesClassNames,
|
|
11497
11463
|
status: "success"
|
|
11498
|
-
}), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null, "Video: ",
|
|
11464
|
+
}), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null, "Video: ", camera === null || camera === void 0 ? void 0 : camera.width, "x", camera === null || camera === void 0 ? void 0 : camera.height)), /*#__PURE__*/React__namespace.default.createElement(ExitCaptureButton, {
|
|
11499
11465
|
onClick: onExit,
|
|
11500
11466
|
className: classNames.exitCaptureBtn
|
|
11501
11467
|
}));
|
|
@@ -11589,7 +11555,13 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
|
|
|
11589
11555
|
setSignatureData = _l.setSignatureData,
|
|
11590
11556
|
setSignatureVideoUrl = _l.setSignatureVideoUrl,
|
|
11591
11557
|
logSelfieCaptureAttempt = _l.logSelfieCaptureAttempt;
|
|
11592
|
-
var _m =
|
|
11558
|
+
var _m = useCameraStore(shallow.useShallow(function (state) {
|
|
11559
|
+
return {
|
|
11560
|
+
cameraAccessDenied: state.cameraAccessDenied,
|
|
11561
|
+
requestCameraAccess: state.requestCameraAccess,
|
|
11562
|
+
releaseCameraAccess: state.releaseCameraAccess
|
|
11563
|
+
};
|
|
11564
|
+
})),
|
|
11593
11565
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
11594
11566
|
requestCameraAccess = _m.requestCameraAccess,
|
|
11595
11567
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
@@ -11749,27 +11721,29 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
|
|
|
11749
11721
|
};
|
|
11750
11722
|
|
|
11751
11723
|
var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
11752
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y
|
|
11753
|
-
var
|
|
11754
|
-
requestedAction =
|
|
11755
|
-
|
|
11756
|
-
satisfied =
|
|
11757
|
-
|
|
11758
|
-
faceGuideStatus =
|
|
11724
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
11725
|
+
var _z = _a.requestedAction,
|
|
11726
|
+
requestedAction = _z === void 0 ? 'SHOW_ID_FRONT' : _z,
|
|
11727
|
+
_0 = _a.satisfied,
|
|
11728
|
+
satisfied = _0 === void 0 ? false : _0,
|
|
11729
|
+
_1 = _a.faceGuideStatus,
|
|
11730
|
+
faceGuideStatus = _1 === void 0 ? 'success' : _1,
|
|
11759
11731
|
faceGuideBorderWidth = _a.faceGuideBorderWidth,
|
|
11760
11732
|
faceGuideBorderColor = _a.faceGuideBorderColor,
|
|
11761
|
-
|
|
11762
|
-
idCardGuideStatus =
|
|
11733
|
+
_2 = _a.idCardGuideStatus,
|
|
11734
|
+
idCardGuideStatus = _2 === void 0 ? 'ready' : _2,
|
|
11763
11735
|
idCardGuideBorderWidth = _a.idCardGuideBorderWidth,
|
|
11764
11736
|
idCardGuideBorderColor = _a.idCardGuideBorderColor,
|
|
11765
11737
|
idCardCaptureProgress = _a.idCardCaptureProgress,
|
|
11766
|
-
|
|
11767
|
-
userSuppliedImages =
|
|
11768
|
-
|
|
11769
|
-
classNames =
|
|
11770
|
-
|
|
11771
|
-
rawVerbiage =
|
|
11772
|
-
var
|
|
11738
|
+
_3 = _a.idCardCaptureGuideImages,
|
|
11739
|
+
userSuppliedImages = _3 === void 0 ? defaultIdCaptureGuideImages : _3,
|
|
11740
|
+
_4 = _a.classNames,
|
|
11741
|
+
classNames = _4 === void 0 ? {} : _4,
|
|
11742
|
+
_5 = _a.verbiage,
|
|
11743
|
+
rawVerbiage = _5 === void 0 ? {} : _5;
|
|
11744
|
+
var isRearFacing = useCameraStore(function (state) {
|
|
11745
|
+
return state.isRearFacing;
|
|
11746
|
+
});
|
|
11773
11747
|
var verbiage = useTranslations(rawVerbiage, {
|
|
11774
11748
|
idFrontInstructionText: 'Display the front of your ID card...',
|
|
11775
11749
|
idBackInstructionText: 'Display the back of your ID card...',
|
|
@@ -11782,17 +11756,17 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
|
11782
11756
|
if (faceGuideBorderColor === undefined) faceGuideBorderColor = (_j = satisfied ? (_f = (_e = theme.idVideoCapture) === null || _e === void 0 ? void 0 : _e.faceGuides) === null || _f === void 0 ? void 0 : _f.satisfiedColor : (_h = (_g = theme.idVideoCapture) === null || _g === void 0 ? void 0 : _g.faceGuides) === null || _h === void 0 ? void 0 : _h.unsatisfiedColor) !== null && _j !== void 0 ? _j : '#D6DCE7';
|
|
11783
11757
|
if (idCardGuideBorderWidth === undefined) idCardGuideBorderWidth = (_m = (_l = (_k = theme.idVideoCapture) === null || _k === void 0 ? void 0 : _k.idCardGuides) === null || _l === void 0 ? void 0 : _l.borderWidth) !== null && _m !== void 0 ? _m : 20;
|
|
11784
11758
|
if (idCardGuideBorderColor === undefined) idCardGuideBorderColor = (_s = satisfied ? (_p = (_o = theme.idVideoCapture) === null || _o === void 0 ? void 0 : _o.idCardGuides) === null || _p === void 0 ? void 0 : _p.satisfiedColor : (_r = (_q = theme.idVideoCapture) === null || _q === void 0 ? void 0 : _q.idCardGuides) === null || _r === void 0 ? void 0 : _r.unsatisfiedColor) !== null && _s !== void 0 ? _s : '#D6DCE7';
|
|
11785
|
-
var
|
|
11786
|
-
idCardGuideRef =
|
|
11787
|
-
|
|
11788
|
-
idCardGuideWidth =
|
|
11789
|
-
|
|
11790
|
-
idCardGuideHeight =
|
|
11759
|
+
var _6 = useResizeObserver__default.default(),
|
|
11760
|
+
idCardGuideRef = _6.ref,
|
|
11761
|
+
_7 = _6.width,
|
|
11762
|
+
idCardGuideWidth = _7 === void 0 ? 0 : _7,
|
|
11763
|
+
_8 = _6.height,
|
|
11764
|
+
idCardGuideHeight = _8 === void 0 ? 0 : _8;
|
|
11791
11765
|
var idCaptureGuideImages = useGuideImages(userSuppliedImages);
|
|
11792
11766
|
var idCaptureGuideImagesByUrl = useGuideImagesByUrl(idCaptureGuideImages);
|
|
11793
|
-
var
|
|
11794
|
-
aspectRatio =
|
|
11795
|
-
setAspectRatio =
|
|
11767
|
+
var _9 = React.useState(undefined),
|
|
11768
|
+
aspectRatio = _9[0],
|
|
11769
|
+
setAspectRatio = _9[1];
|
|
11796
11770
|
var onImageLoaded = React.useCallback(function (e) {
|
|
11797
11771
|
var _a, _b, _c, _d;
|
|
11798
11772
|
var img = e.currentTarget;
|
|
@@ -11839,7 +11813,7 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
|
11839
11813
|
}, /*#__PURE__*/React__namespace.default.createElement(IdCardGuideImage, {
|
|
11840
11814
|
alt: "",
|
|
11841
11815
|
className: classNames.idCardGuideImage,
|
|
11842
|
-
"$isMirrored": !
|
|
11816
|
+
"$isMirrored": !isRearFacing,
|
|
11843
11817
|
style: idCardImageStyle,
|
|
11844
11818
|
src: requestedAction === 'SHOW_ID_BACK' ? idCaptureGuideImages.landscape.SHOW_ID_BACK.url : idCaptureGuideImages.landscape.SHOW_ID_FRONT.url,
|
|
11845
11819
|
onLoad: onImageLoaded
|
|
@@ -11853,8 +11827,8 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
|
11853
11827
|
className: classNames.idCardGuideInstructionsContainer
|
|
11854
11828
|
}, /*#__PURE__*/React__namespace.default.createElement(IdCardGuideInstructions, {
|
|
11855
11829
|
className: classNames.idCardGuideInstructions,
|
|
11856
|
-
"$textColor": (
|
|
11857
|
-
"$background": (
|
|
11830
|
+
"$textColor": (_w = (_v = theme.idVideoCapture) === null || _v === void 0 ? void 0 : _v.idCardGuides) === null || _w === void 0 ? void 0 : _w.instructionsTextColor,
|
|
11831
|
+
"$background": (_y = (_x = theme.idVideoCapture) === null || _x === void 0 ? void 0 : _x.idCardGuides) === null || _y === void 0 ? void 0 : _y.instructionsBackgroundColor
|
|
11858
11832
|
}, instructionText))))));
|
|
11859
11833
|
};
|
|
11860
11834
|
var Container = styled__default.default.div(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n display: flex;\n max-height: 100%;\n position: absolute;\n z-index: 1000;\n width: 100dvw;\n height: 100dvh;\n font-family: ", ";\n box-sizing: border-box;\n overflow: hidden;\n padding: 40px;\n"], ["\n display: flex;\n max-height: 100%;\n position: absolute;\n z-index: 1000;\n width: 100dvw;\n height: 100dvh;\n font-family: ", ";\n box-sizing: border-box;\n overflow: hidden;\n padding: 40px;\n"])), function (props) {
|
|
@@ -11999,99 +11973,100 @@ var defaultVideoIdCaptureThresholds = {
|
|
|
11999
11973
|
flipShortcutThreshold: 0.7
|
|
12000
11974
|
};
|
|
12001
11975
|
var IdVideoCapture = function IdVideoCapture(_a) {
|
|
12002
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v
|
|
11976
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
12003
11977
|
var onComplete = _a.onComplete,
|
|
12004
11978
|
onIdFrontImageCaptured = _a.onIdFrontImageCaptured,
|
|
12005
11979
|
onIdBackImageCaptured = _a.onIdBackImageCaptured,
|
|
12006
11980
|
onFaceNotDetected = _a.onFaceNotDetected,
|
|
12007
11981
|
onRecordingFailed = _a.onRecordingFailed,
|
|
12008
11982
|
onExitCapture = _a.onExitCapture,
|
|
12009
|
-
|
|
12010
|
-
idCaptureModelsEnabled =
|
|
12011
|
-
|
|
12012
|
-
idCardCaptureGuideImages =
|
|
12013
|
-
|
|
12014
|
-
idCardFrontDelay =
|
|
12015
|
-
|
|
12016
|
-
videoIdCaptureThresholds =
|
|
12017
|
-
|
|
12018
|
-
skipShowIdCardBack =
|
|
12019
|
-
|
|
12020
|
-
captureCountdownSeconds =
|
|
11983
|
+
_w = _a.idCaptureModelsEnabled,
|
|
11984
|
+
idCaptureModelsEnabled = _w === void 0 ? true : _w,
|
|
11985
|
+
_x = _a.idCardCaptureGuideImages,
|
|
11986
|
+
idCardCaptureGuideImages = _x === void 0 ? defaultIdCaptureGuideImages : _x,
|
|
11987
|
+
_y = _a.idCardFrontDelay,
|
|
11988
|
+
idCardFrontDelay = _y === void 0 ? 1000 : _y,
|
|
11989
|
+
_z = _a.videoIdCaptureThresholds,
|
|
11990
|
+
videoIdCaptureThresholds = _z === void 0 ? defaultVideoIdCaptureThresholds : _z,
|
|
11991
|
+
_0 = _a.skipShowIdCardBack,
|
|
11992
|
+
skipShowIdCardBack = _0 === void 0 ? false : _0,
|
|
11993
|
+
_1 = _a.captureCountdownSeconds,
|
|
11994
|
+
captureCountdownSeconds = _1 === void 0 ? 3 : _1,
|
|
12021
11995
|
readTextPrompt = _a.readTextPrompt,
|
|
12022
|
-
|
|
12023
|
-
readTextTimeoutDurationMs =
|
|
12024
|
-
|
|
12025
|
-
readTextMinReadingMs =
|
|
12026
|
-
|
|
12027
|
-
disableFaceDetectionWhileAudioCapture =
|
|
12028
|
-
|
|
12029
|
-
disableFaceDetectionWhileAudioCaptureMsDelay =
|
|
12030
|
-
|
|
12031
|
-
mergeAVStreams =
|
|
12032
|
-
|
|
12033
|
-
classNames =
|
|
12034
|
-
|
|
12035
|
-
colors =
|
|
12036
|
-
|
|
12037
|
-
rawVerbiage =
|
|
12038
|
-
|
|
12039
|
-
debugMode =
|
|
12040
|
-
var
|
|
12041
|
-
ref =
|
|
12042
|
-
|
|
12043
|
-
width =
|
|
12044
|
-
|
|
12045
|
-
height =
|
|
12046
|
-
var
|
|
12047
|
-
|
|
12048
|
-
videoRef =
|
|
12049
|
-
videoLoaded =
|
|
12050
|
-
cameraReady =
|
|
12051
|
-
microphoneReady =
|
|
12052
|
-
audioStream =
|
|
12053
|
-
|
|
12054
|
-
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
|
|
12087
|
-
|
|
12088
|
-
|
|
12089
|
-
|
|
12090
|
-
|
|
11996
|
+
_2 = _a.readTextTimeoutDurationMs,
|
|
11997
|
+
readTextTimeoutDurationMs = _2 === void 0 ? 15000 : _2,
|
|
11998
|
+
_3 = _a.readTextMinReadingMs,
|
|
11999
|
+
readTextMinReadingMs = _3 === void 0 ? 10000 : _3,
|
|
12000
|
+
_4 = _a.disableFaceDetectionWhileAudioCapture,
|
|
12001
|
+
disableFaceDetectionWhileAudioCapture = _4 === void 0 ? false : _4,
|
|
12002
|
+
_5 = _a.disableFaceDetectionWhileAudioCaptureMsDelay,
|
|
12003
|
+
disableFaceDetectionWhileAudioCaptureMsDelay = _5 === void 0 ? 2000 : _5,
|
|
12004
|
+
_6 = _a.mergeAVStreams,
|
|
12005
|
+
mergeAVStreams = _6 === void 0 ? false : _6,
|
|
12006
|
+
_7 = _a.classNames,
|
|
12007
|
+
classNames = _7 === void 0 ? {} : _7,
|
|
12008
|
+
_8 = _a.colors,
|
|
12009
|
+
colors = _8 === void 0 ? {} : _8,
|
|
12010
|
+
_9 = _a.verbiage,
|
|
12011
|
+
rawVerbiage = _9 === void 0 ? {} : _9,
|
|
12012
|
+
_10 = _a.debugMode,
|
|
12013
|
+
debugMode = _10 === void 0 ? false : _10;
|
|
12014
|
+
var _11 = useResizeObserver__default.default(),
|
|
12015
|
+
ref = _11.ref,
|
|
12016
|
+
_12 = _11.width,
|
|
12017
|
+
width = _12 === void 0 ? 1 : _12,
|
|
12018
|
+
_13 = _11.height,
|
|
12019
|
+
height = _13 === void 0 ? 1 : _13;
|
|
12020
|
+
var _14 = useCameraStore(),
|
|
12021
|
+
camera = _14.camera,
|
|
12022
|
+
videoRef = _14.videoRef,
|
|
12023
|
+
videoLoaded = _14.videoLoaded,
|
|
12024
|
+
cameraReady = _14.cameraReady,
|
|
12025
|
+
microphoneReady = _14.microphoneReady,
|
|
12026
|
+
audioStream = _14.audioStream,
|
|
12027
|
+
isRearFacing = _14.isRearFacing,
|
|
12028
|
+
releaseCameraAccess = _14.releaseCameraAccess;
|
|
12029
|
+
var _15 = React.useState([]),
|
|
12030
|
+
detectedObjects = _15[0],
|
|
12031
|
+
setDetectedObjects = _15[1];
|
|
12032
|
+
var _16 = React.useState(null),
|
|
12033
|
+
face = _16[0],
|
|
12034
|
+
setFace = _16[1];
|
|
12035
|
+
var _17 = React.useContext(IdCaptureModelsContext),
|
|
12036
|
+
idModelsReady = _17.ready,
|
|
12037
|
+
startIdModels = _17.start,
|
|
12038
|
+
stopIdModels = _17.stop,
|
|
12039
|
+
onIdPredictionMade = _17.onPredictionMade,
|
|
12040
|
+
setThresholds = _17.setThresholds,
|
|
12041
|
+
setDocumentDetectionBoundaries = _17.setDocumentDetectionBoundaries,
|
|
12042
|
+
bestFrameDetails = _17.bestFrameDetails,
|
|
12043
|
+
resetBestFrame = _17.resetBestFrame,
|
|
12044
|
+
idModelError = _17.modelError;
|
|
12045
|
+
var _18 = React.useState(null),
|
|
12046
|
+
videoStartsAt = _18[0],
|
|
12047
|
+
setVideoStartsAt = _18[1];
|
|
12048
|
+
var _19 = React.useContext(SubmissionContext),
|
|
12049
|
+
setIdCaptureVideoAudioStartsAt = _19.setIdCaptureVideoAudioStartsAt,
|
|
12050
|
+
setExpectedAudioText = _19.setExpectedAudioText;
|
|
12051
|
+
var _20 = React.useContext(SelfieGuidanceModelsContext),
|
|
12052
|
+
startSelfieGuidance = _20.start,
|
|
12053
|
+
stopSelfieGuidance = _20.stop,
|
|
12054
|
+
onSelfiePredictionMade = _20.onPredictionMade,
|
|
12055
|
+
selfieModelError = _20.error;
|
|
12056
|
+
var _21 = useVideoRecorder(camera, audioStream, mergeAVStreams),
|
|
12057
|
+
isRecordingVideo = _21.isRecordingVideo,
|
|
12058
|
+
startRecordingVideo = _21.startRecordingVideo,
|
|
12059
|
+
startRecordingAudio = _21.startRecordingAudio,
|
|
12060
|
+
stopRecordingVideo = _21.stopRecordingVideo,
|
|
12061
|
+
stopRecordingAudio = _21.stopRecordingAudio,
|
|
12062
|
+
videoRecordingUnintentionallyStopped = _21.videoRecordingUnintentionallyStopped,
|
|
12063
|
+
audioRecordingUnintentionallyStopped = _21.audioRecordingUnintentionallyStopped,
|
|
12064
|
+
videoUrl = _21.videoUrl,
|
|
12065
|
+
audioUrl = _21.audioUrl;
|
|
12091
12066
|
var countdownTimeoutRef = React.useRef(undefined);
|
|
12092
|
-
var
|
|
12093
|
-
countdownRemaining =
|
|
12094
|
-
setCountdownRemaining =
|
|
12067
|
+
var _22 = React.useState(-1),
|
|
12068
|
+
countdownRemaining = _22[0],
|
|
12069
|
+
setCountdownRemaining = _22[1];
|
|
12095
12070
|
React.useEffect(function () {
|
|
12096
12071
|
if (!isRecordingVideo && !videoUrl) {
|
|
12097
12072
|
startRecordingVideo();
|
|
@@ -12102,24 +12077,24 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12102
12077
|
var needsAudio = !!readTextPrompt && !mergeAVStreams;
|
|
12103
12078
|
var audioReady = !needsAudio || audioUrl;
|
|
12104
12079
|
if (videoUrl && audioReady) {
|
|
12105
|
-
|
|
12080
|
+
releaseCameraAccess();
|
|
12106
12081
|
onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl, audioUrl);
|
|
12107
12082
|
}
|
|
12108
|
-
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt,
|
|
12083
|
+
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess, startRecordingVideo, videoUrl]);
|
|
12109
12084
|
React.useEffect(function () {
|
|
12110
|
-
if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped) {
|
|
12085
|
+
if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped || !!readTextPrompt && !microphoneReady) {
|
|
12111
12086
|
onRecordingFailed === null || onRecordingFailed === void 0 ? void 0 : onRecordingFailed();
|
|
12112
12087
|
}
|
|
12113
|
-
}, [audioRecordingUnintentionallyStopped, onRecordingFailed, videoRecordingUnintentionallyStopped]);
|
|
12114
|
-
var
|
|
12115
|
-
requestedAction =
|
|
12116
|
-
setRequestedAction =
|
|
12088
|
+
}, [audioRecordingUnintentionallyStopped, microphoneReady, onRecordingFailed, readTextPrompt, videoRecordingUnintentionallyStopped]);
|
|
12089
|
+
var _23 = React.useState('SHOW_ID_FRONT'),
|
|
12090
|
+
requestedAction = _23[0],
|
|
12091
|
+
setRequestedAction = _23[1];
|
|
12117
12092
|
var shouldRunIdModels = idCaptureModelsEnabled && videoLoaded && cameraReady && idModelsReady && !idModelError && requestedAction !== 'READ_TEXT' && (!readTextPrompt || microphoneReady);
|
|
12118
12093
|
React.useEffect(function startModelsWhenCapturing() {
|
|
12119
12094
|
if (!shouldRunIdModels) return;
|
|
12120
12095
|
startIdModels();
|
|
12121
12096
|
return function () {
|
|
12122
|
-
stopIdModels();
|
|
12097
|
+
return stopIdModels();
|
|
12123
12098
|
};
|
|
12124
12099
|
}, [shouldRunIdModels, startIdModels, stopIdModels]);
|
|
12125
12100
|
React.useEffect(function () {
|
|
@@ -12133,18 +12108,18 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12133
12108
|
bottom: 1
|
|
12134
12109
|
});
|
|
12135
12110
|
}, [setDocumentDetectionBoundaries]);
|
|
12136
|
-
var
|
|
12137
|
-
currentDetectionScore =
|
|
12138
|
-
setCurrentDetectionScore =
|
|
12139
|
-
var
|
|
12140
|
-
currentDetectedDocumentType =
|
|
12141
|
-
setCurrentDetectedDocumentType =
|
|
12111
|
+
var _24 = React.useState(0),
|
|
12112
|
+
currentDetectionScore = _24[0],
|
|
12113
|
+
setCurrentDetectionScore = _24[1];
|
|
12114
|
+
var _25 = React.useState('none'),
|
|
12115
|
+
currentDetectedDocumentType = _25[0],
|
|
12116
|
+
setCurrentDetectedDocumentType = _25[1];
|
|
12117
|
+
var _26 = React.useState(0),
|
|
12118
|
+
currentFocusScore = _26[0],
|
|
12119
|
+
setCurrentFocusScore = _26[1];
|
|
12142
12120
|
var _27 = React.useState(0),
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
var _28 = React.useState(0),
|
|
12146
|
-
goodFramesCount = _28[0],
|
|
12147
|
-
setGoodFramesCount = _28[1];
|
|
12121
|
+
goodFramesCount = _27[0],
|
|
12122
|
+
setGoodFramesCount = _27[1];
|
|
12148
12123
|
var goodFramesThreshold = requestedAction === 'SHOW_ID_FRONT' ? videoIdCaptureThresholds.goodFrames.idCardFront : videoIdCaptureThresholds.goodFrames.idCardBack;
|
|
12149
12124
|
var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
|
|
12150
12125
|
React.useEffect(function () {
|
|
@@ -12165,9 +12140,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12165
12140
|
} : 0);
|
|
12166
12141
|
});
|
|
12167
12142
|
}, [idCaptureModelsEnabled, onIdPredictionMade, idModelError, requestedAction, videoIdCaptureThresholds.flipShortcutThreshold]);
|
|
12168
|
-
var
|
|
12169
|
-
idFrontCaptureStartedAt =
|
|
12170
|
-
setFirstGoodFrameTime =
|
|
12143
|
+
var _28 = React.useState(null),
|
|
12144
|
+
idFrontCaptureStartedAt = _28[0],
|
|
12145
|
+
setFirstGoodFrameTime = _28[1];
|
|
12171
12146
|
React.useEffect(function () {
|
|
12172
12147
|
if (goodFramesCount === 1) setFirstGoodFrameTime(new Date().getTime());
|
|
12173
12148
|
}, [goodFramesCount]);
|
|
@@ -12188,9 +12163,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12188
12163
|
var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
|
|
12189
12164
|
var faceBox = face === null || face === void 0 ? void 0 : face.box;
|
|
12190
12165
|
var faceCentered = !faceBox || !frameWidth || faceBox.xMin > frameWidth * edgeBoundary && faceBox.yMin > frameHeight * edgeBoundary && faceBox.xMax < frameWidth * (1 - edgeBoundary) && faceBox.yMax < frameHeight * (1 - edgeBoundary);
|
|
12191
|
-
var
|
|
12192
|
-
countdownStartedAt =
|
|
12193
|
-
setCountdownStartedAt =
|
|
12166
|
+
var _29 = React.useState(),
|
|
12167
|
+
countdownStartedAt = _29[0],
|
|
12168
|
+
setCountdownStartedAt = _29[1];
|
|
12194
12169
|
var photoCanvas = React.useRef(null);
|
|
12195
12170
|
var frameLock = React.useRef(false);
|
|
12196
12171
|
var captureFrame = React.useCallback(function () {
|
|
@@ -12313,9 +12288,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12313
12288
|
stopSelfieGuidance();
|
|
12314
12289
|
};
|
|
12315
12290
|
}, [startSelfieGuidance, stopSelfieGuidance]);
|
|
12316
|
-
var
|
|
12317
|
-
numFramesWithoutFaces =
|
|
12318
|
-
setNumFramesWithoutFaces =
|
|
12291
|
+
var _30 = React.useState(0),
|
|
12292
|
+
numFramesWithoutFaces = _30[0],
|
|
12293
|
+
setNumFramesWithoutFaces = _30[1];
|
|
12319
12294
|
onSelfiePredictionMade(useDebounce.useThrottledCallback(React.useCallback(function (_a) {
|
|
12320
12295
|
var face = _a.face;
|
|
12321
12296
|
if (selfieModelError) return;
|
|
@@ -12331,12 +12306,12 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12331
12306
|
}
|
|
12332
12307
|
}, [disableFaceDetectionWhileAudioCapture, disableFaceDetectionWhileAudioCaptureMsDelay, numFramesWithoutFaces, onFaceNotDetected, timeoutStartedAt]);
|
|
12333
12308
|
var theme = styled.useTheme();
|
|
12334
|
-
var
|
|
12309
|
+
var _31 = useTranslations(rawVerbiage, {
|
|
12335
12310
|
faceNotCenteredText: 'Please move your face to the center...',
|
|
12336
12311
|
captureBtnText: 'Capture'
|
|
12337
12312
|
}),
|
|
12338
|
-
captureBtnText =
|
|
12339
|
-
faceNotCenteredText =
|
|
12313
|
+
captureBtnText = _31.captureBtnText,
|
|
12314
|
+
faceNotCenteredText = _31.faceNotCenteredText;
|
|
12340
12315
|
var debugScalingDetails = useDebugScalingDetails({
|
|
12341
12316
|
enabled: debugMode,
|
|
12342
12317
|
pageWidth: width,
|
|
@@ -12345,8 +12320,6 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12345
12320
|
videoHeight: (_j = (_h = videoRef.current) === null || _h === void 0 ? void 0 : _h.videoHeight) !== null && _j !== void 0 ? _j : 0
|
|
12346
12321
|
});
|
|
12347
12322
|
var capturingId = ['SHOW_ID_FRONT', 'SHOW_ID_BACK'].includes(requestedAction);
|
|
12348
|
-
// const searchingForIdCard =
|
|
12349
|
-
// idCaptureModelsEnabled && capturingId && !goodFramesThresholdMet
|
|
12350
12323
|
var guidanceText = !faceCentered ? faceNotCenteredText : undefined;
|
|
12351
12324
|
return /*#__PURE__*/React__namespace.default.createElement(PageContainer, {
|
|
12352
12325
|
ref: ref,
|
|
@@ -12372,15 +12345,14 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12372
12345
|
faceGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor,
|
|
12373
12346
|
idCardGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor
|
|
12374
12347
|
}), debugMode && capturingId && ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, /*#__PURE__*/React__namespace.default.createElement(ObjectDetectionDebugOverlayDiv, {
|
|
12375
|
-
"$flipX": !
|
|
12348
|
+
"$flipX": !isRearFacing
|
|
12376
12349
|
}, detectedObjects.map(function (obj, i) {
|
|
12377
|
-
var _a;
|
|
12378
12350
|
return /*#__PURE__*/React__namespace.default.createElement(IdCaptureDetectedObjectDebugBox, {
|
|
12379
12351
|
key: i,
|
|
12380
12352
|
obj: obj,
|
|
12381
12353
|
scaling: debugScalingDetails,
|
|
12382
12354
|
color: "blue",
|
|
12383
|
-
flipX: !
|
|
12355
|
+
flipX: !isRearFacing
|
|
12384
12356
|
});
|
|
12385
12357
|
})), /*#__PURE__*/React__namespace.default.createElement(DebugBoundingBoxOverlay, null, face && ( /*#__PURE__*/React__namespace.default.createElement(SelfieCaptureFaceDebugBox, {
|
|
12386
12358
|
face: face,
|
|
@@ -12389,9 +12361,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12389
12361
|
className: classNames.guidanceMessageContainer
|
|
12390
12362
|
}, /*#__PURE__*/React__namespace.default.createElement(GuidanceMessage, {
|
|
12391
12363
|
className: classNames.guidanceMessage,
|
|
12392
|
-
"$background": (
|
|
12393
|
-
"$textColor": (
|
|
12394
|
-
}, guidanceText))), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null,
|
|
12364
|
+
"$background": (_o = (_m = (_l = theme.guidanceMessages) === null || _l === void 0 ? void 0 : _l.negative) === null || _m === void 0 ? void 0 : _m.backgroundColor) !== null && _o !== void 0 ? _o : 'red',
|
|
12365
|
+
"$textColor": (_r = (_q = (_p = theme.guidanceMessages) === null || _p === void 0 ? void 0 : _p.negative) === null || _q === void 0 ? void 0 : _q.textColor) !== null && _r !== void 0 ? _r : 'white'
|
|
12366
|
+
}, guidanceText))), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__namespace.default.createElement("br", null), isRecordingVideo ? '✅ Recording' : '❌ Not recording', /*#__PURE__*/React__namespace.default.createElement("br", null), goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', goodFramesCount, "/", goodFramesThreshold, /*#__PURE__*/React__namespace.default.createElement("br", null), "Document Type: ", currentDetectedDocumentType, /*#__PURE__*/React__namespace.default.createElement("br", null), "Detection Score: ", currentDetectionScore, /*#__PURE__*/React__namespace.default.createElement("br", null), "Focus Score: ", currentFocusScore, /*#__PURE__*/React__namespace.default.createElement("br", null), "Best Frame Detection Score:", ' ', (_t = (_s = bestFrameDetails.current) === null || _s === void 0 ? void 0 : _s.detectionScore) !== null && _t !== void 0 ? _t : 0, /*#__PURE__*/React__namespace.default.createElement("br", null), "Best Frame Focus Score: ", (_v = (_u = bestFrameDetails.current) === null || _u === void 0 ? void 0 : _u.focusScore) !== null && _v !== void 0 ? _v : 0)), countdownRemaining > 0 && capturingId && ( /*#__PURE__*/React__namespace.default.createElement(CountdownContainer, {
|
|
12395
12367
|
className: classNames.countdownContainer
|
|
12396
12368
|
}, /*#__PURE__*/React__namespace.default.createElement(Countdown, {
|
|
12397
12369
|
className: classNames.countdown
|
|
@@ -12400,7 +12372,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12400
12372
|
}, /*#__PURE__*/React__namespace.default.createElement(CaptureButton, {
|
|
12401
12373
|
finished: true,
|
|
12402
12374
|
onClick: function onClick() {
|
|
12403
|
-
setCountdownStartedAt(new Date());
|
|
12375
|
+
return setCountdownStartedAt(new Date());
|
|
12404
12376
|
},
|
|
12405
12377
|
disabled: !!countdownStartedAt || frameLock.current,
|
|
12406
12378
|
className: classNames.captureBtn
|
|
@@ -12688,16 +12660,14 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
12688
12660
|
className: "flex"
|
|
12689
12661
|
}, /*#__PURE__*/React__namespace.default.createElement(Spinner, null));
|
|
12690
12662
|
}
|
|
12691
|
-
return /*#__PURE__*/React__namespace.default.createElement(
|
|
12692
|
-
|
|
12693
|
-
preferContinuityCamera: isCapturingId,
|
|
12663
|
+
return /*#__PURE__*/React__namespace.default.createElement(CameraStoreProvider, {
|
|
12664
|
+
preferIphoneContinuityCamera: isCapturingId,
|
|
12694
12665
|
preferFrontFacingCamera: !isCapturingId,
|
|
12695
12666
|
requireMicrophoneAccess: !isCapturingId && !!readTextPrompt,
|
|
12696
12667
|
maxVideoWidth: isCapturingId ? 1920 : 1280,
|
|
12697
12668
|
maxFps: isCapturingId ? 60 : 30,
|
|
12698
12669
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12699
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12700
|
-
debugMode: debugMode
|
|
12670
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12701
12671
|
}, /*#__PURE__*/React__namespace.default.createElement(IdCaptureModelsProvider, {
|
|
12702
12672
|
autoStart: false,
|
|
12703
12673
|
documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
|
|
@@ -12708,7 +12678,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
12708
12678
|
autoStart: false,
|
|
12709
12679
|
onModelError: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onModelError,
|
|
12710
12680
|
modelLoadTimeoutMs: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.modelLoadTimeoutMs,
|
|
12711
|
-
requireVerticalFaceCentering:
|
|
12681
|
+
requireVerticalFaceCentering: false
|
|
12712
12682
|
}, /*#__PURE__*/React__namespace.default.createElement(PageContainer, {
|
|
12713
12683
|
className: "flex ".concat((_k = classNames.container) !== null && _k !== void 0 ? _k : '')
|
|
12714
12684
|
}, ['CHECKING_LIVENESS', 'CAPTURING_VIDEO'].includes(captureState) && /*#__PURE__*/React__namespace.default.createElement(CameraVideoTag, {
|
|
@@ -12823,17 +12793,15 @@ function CompositeWizard(_a) {
|
|
|
12823
12793
|
_o = _a.captureSignatureVideo,
|
|
12824
12794
|
captureSignatureVideo = _o === void 0 ? false : _o,
|
|
12825
12795
|
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
12826
|
-
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
checkIndex = _r[0],
|
|
12836
|
-
setCheckIndex = _r[1];
|
|
12796
|
+
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied;
|
|
12797
|
+
var _p = React.useContext(SubmissionContext),
|
|
12798
|
+
submit = _p.submit,
|
|
12799
|
+
submissionStatus = _p.submissionStatus,
|
|
12800
|
+
setSignatureData = _p.setSignatureData,
|
|
12801
|
+
setAdditionalDocuments = _p.setAdditionalDocuments;
|
|
12802
|
+
var _q = React.useState(0),
|
|
12803
|
+
checkIndex = _q[0],
|
|
12804
|
+
setCheckIndex = _q[1];
|
|
12837
12805
|
var checks = React.useMemo(function () {
|
|
12838
12806
|
var _a, _b;
|
|
12839
12807
|
var checks = __spreadArray([], userChecks, true);
|
|
@@ -12911,16 +12879,6 @@ function CompositeWizard(_a) {
|
|
|
12911
12879
|
return i + 1;
|
|
12912
12880
|
});
|
|
12913
12881
|
}, [onVideoSignatureCompleteProp]);
|
|
12914
|
-
var _s = React.useState(0),
|
|
12915
|
-
videoSignatureAttempts = _s[0],
|
|
12916
|
-
setVideoSignatureAttempts = _s[1];
|
|
12917
|
-
var onVideoSignatureRetryProp = videoSignatureCaptureProps.onRetryClicked;
|
|
12918
|
-
var onVideoSignatureRetry = React.useCallback(function () {
|
|
12919
|
-
onVideoSignatureRetryProp === null || onVideoSignatureRetryProp === void 0 ? void 0 : onVideoSignatureRetryProp();
|
|
12920
|
-
setVideoSignatureAttempts(function (n) {
|
|
12921
|
-
return n + 1;
|
|
12922
|
-
});
|
|
12923
|
-
}, [onVideoSignatureRetryProp]);
|
|
12924
12882
|
var onAdditionalDocumentCaptureCompleteProp = additionalDocumentCaptureProps === null || additionalDocumentCaptureProps === void 0 ? void 0 : additionalDocumentCaptureProps.onComplete;
|
|
12925
12883
|
var onAdditionalDocumentCaptureComplete = React.useCallback(function (uploadedDocuments) {
|
|
12926
12884
|
setAdditionalDocuments(uploadedDocuments);
|
|
@@ -12949,11 +12907,9 @@ function CompositeWizard(_a) {
|
|
|
12949
12907
|
}
|
|
12950
12908
|
switch (checks[checkIndex]) {
|
|
12951
12909
|
case 'IdCapture':
|
|
12952
|
-
return /*#__PURE__*/React__namespace.default.createElement(
|
|
12953
|
-
key: "IdCaptureCamera",
|
|
12910
|
+
return /*#__PURE__*/React__namespace.default.createElement(CameraStoreProvider, {
|
|
12954
12911
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12955
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12956
|
-
debugMode: debugMode
|
|
12912
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12957
12913
|
}, /*#__PURE__*/React__namespace.default.createElement(IdCaptureModelsProvider, {
|
|
12958
12914
|
autoStart: false,
|
|
12959
12915
|
documentDetectionModelUrl: (_d = (_c = idCaptureProps.assets) === null || _c === void 0 ? void 0 : _c.documentDetectionModelUrl) !== null && _d !== void 0 ? _d : '',
|
|
@@ -12970,13 +12926,11 @@ function CompositeWizard(_a) {
|
|
|
12970
12926
|
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12971
12927
|
}));
|
|
12972
12928
|
case 'FaceLiveness':
|
|
12973
|
-
return /*#__PURE__*/React__namespace.default.createElement(
|
|
12974
|
-
key: "FaceLivenessCamera",
|
|
12929
|
+
return /*#__PURE__*/React__namespace.default.createElement(CameraStoreProvider, {
|
|
12975
12930
|
preferFrontFacingCamera: true,
|
|
12976
|
-
|
|
12931
|
+
preferIphoneContinuityCamera: false,
|
|
12977
12932
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12978
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12979
|
-
debugMode: debugMode
|
|
12933
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12980
12934
|
}, /*#__PURE__*/React__namespace.default.createElement(SelfieGuidanceModelsProvider, {
|
|
12981
12935
|
autoStart: false,
|
|
12982
12936
|
onModelError: faceLivenessProps.onModelError,
|
|
@@ -12989,15 +12943,13 @@ function CompositeWizard(_a) {
|
|
|
12989
12943
|
onAccept: onSignatureCaptureSuccess
|
|
12990
12944
|
}));
|
|
12991
12945
|
case 'VideoSignatureCapture':
|
|
12992
|
-
return /*#__PURE__*/React__namespace.default.createElement(
|
|
12993
|
-
|
|
12994
|
-
preferContinuityCamera: false,
|
|
12946
|
+
return /*#__PURE__*/React__namespace.default.createElement(CameraStoreProvider, {
|
|
12947
|
+
preferIphoneContinuityCamera: false,
|
|
12995
12948
|
preferFrontFacingCamera: true,
|
|
12996
12949
|
maxVideoWidth: 1280,
|
|
12997
12950
|
maxFps: 30,
|
|
12998
12951
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12999
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
13000
|
-
debugMode: debugMode
|
|
12952
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
13001
12953
|
}, /*#__PURE__*/React__namespace.default.createElement(SelfieGuidanceModelsProvider, {
|
|
13002
12954
|
autoStart: false,
|
|
13003
12955
|
throttleMs: 250,
|
|
@@ -13005,8 +12957,7 @@ function CompositeWizard(_a) {
|
|
|
13005
12957
|
modelLoadTimeoutMs: videoSignatureCaptureProps.modelLoadTimeoutMs,
|
|
13006
12958
|
requireVerticalFaceCentering: false
|
|
13007
12959
|
}, /*#__PURE__*/React__namespace.default.createElement(VideoSignatureWizard, _assign({}, videoSignatureCaptureProps, {
|
|
13008
|
-
onComplete: onVideoSignatureComplete
|
|
13009
|
-
onRetryClicked: onVideoSignatureRetry
|
|
12960
|
+
onComplete: onVideoSignatureComplete
|
|
13010
12961
|
}))));
|
|
13011
12962
|
case 'AdditionalDocumentCapture':
|
|
13012
12963
|
return /*#__PURE__*/React__namespace.default.createElement(AdditionalDocumentCaptureWizard, _assign({}, additionalDocumentCaptureProps, {
|
|
@@ -13457,8 +13408,7 @@ var IdValidation = function IdValidation(_a) {
|
|
|
13457
13408
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
13458
13409
|
captureSignature: captureSignature,
|
|
13459
13410
|
captureSignatureVideo: captureSignatureVideo,
|
|
13460
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
13461
|
-
debugMode: debugMode
|
|
13411
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
13462
13412
|
}))));
|
|
13463
13413
|
};
|
|
13464
13414
|
|
|
@@ -13564,8 +13514,7 @@ var FaceValidation = function FaceValidation(_a) {
|
|
|
13564
13514
|
return ['FaceLiveness'];
|
|
13565
13515
|
}, []),
|
|
13566
13516
|
faceLivenessProps: faceLivenessProps,
|
|
13567
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
13568
|
-
debugMode: debugMode
|
|
13517
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
13569
13518
|
}))));
|
|
13570
13519
|
};
|
|
13571
13520
|
|
|
@@ -13798,8 +13747,7 @@ var IdAndFaceValidation = function IdAndFaceValidation(_a) {
|
|
|
13798
13747
|
additionalDocumentCaptureProps: additionalDocumentCaptureProps,
|
|
13799
13748
|
captureSignature: captureSignature,
|
|
13800
13749
|
captureSignatureVideo: captureSignatureVideo,
|
|
13801
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
13802
|
-
debugMode: debugMode
|
|
13750
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
13803
13751
|
}))));
|
|
13804
13752
|
};
|
|
13805
13753
|
|
|
@@ -14054,8 +14002,7 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
|
|
|
14054
14002
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
14055
14003
|
captureSignature: captureSignature,
|
|
14056
14004
|
captureSignatureVideo: captureSignatureVideo,
|
|
14057
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
14058
|
-
debugMode: debugMode
|
|
14005
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
14059
14006
|
}))));
|
|
14060
14007
|
};
|
|
14061
14008
|
|
|
@@ -14387,7 +14334,7 @@ var CustomerVerificationWizard = function CustomerVerificationWizard(_a) {
|
|
|
14387
14334
|
var _l = React.useState('LOADING'),
|
|
14388
14335
|
captureState = _l[0],
|
|
14389
14336
|
setCaptureState = _l[1];
|
|
14390
|
-
var _m =
|
|
14337
|
+
var _m = useCameraStore(),
|
|
14391
14338
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
14392
14339
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
14393
14340
|
var _o = React.useContext(SelfieGuidanceModelsContext),
|
|
@@ -14593,10 +14540,9 @@ var CustomerVerification = function CustomerVerification(_a) {
|
|
|
14593
14540
|
onSubmit: onSubmit,
|
|
14594
14541
|
geolocationEnabled: geolocationEnabled,
|
|
14595
14542
|
geolocationRequired: geolocationRequired
|
|
14596
|
-
}, /*#__PURE__*/React__namespace.default.createElement(
|
|
14543
|
+
}, /*#__PURE__*/React__namespace.default.createElement(CameraStoreProvider, {
|
|
14597
14544
|
preferFrontFacingCamera: true,
|
|
14598
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
14599
|
-
debugMode: debugMode
|
|
14545
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
14600
14546
|
}, /*#__PURE__*/React__namespace.default.createElement(SelfieGuidanceModelsProvider, {
|
|
14601
14547
|
autoStart: false,
|
|
14602
14548
|
onModelError: onModelError,
|
|
@@ -14945,7 +14891,7 @@ var CustomerIdentificationWizard = function CustomerIdentificationWizard(_a) {
|
|
|
14945
14891
|
var _l = React.useState('LOADING'),
|
|
14946
14892
|
captureState = _l[0],
|
|
14947
14893
|
setCaptureState = _l[1];
|
|
14948
|
-
var _m =
|
|
14894
|
+
var _m = useCameraStore(),
|
|
14949
14895
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
14950
14896
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
14951
14897
|
var _o = React.useContext(SelfieGuidanceModelsContext),
|
|
@@ -15149,10 +15095,9 @@ var CustomerIdentification = function CustomerIdentification(_a) {
|
|
|
15149
15095
|
onSubmit: onSubmit,
|
|
15150
15096
|
geolocationEnabled: geolocationEnabled,
|
|
15151
15097
|
geolocationRequired: geolocationRequired
|
|
15152
|
-
}, /*#__PURE__*/React__namespace.default.createElement(
|
|
15098
|
+
}, /*#__PURE__*/React__namespace.default.createElement(CameraStoreProvider, {
|
|
15153
15099
|
preferFrontFacingCamera: true,
|
|
15154
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
15155
|
-
debugMode: debugMode
|
|
15100
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
15156
15101
|
}, /*#__PURE__*/React__namespace.default.createElement(SelfieGuidanceModelsProvider, {
|
|
15157
15102
|
autoStart: false,
|
|
15158
15103
|
modelLoadTimeoutMs: modelLoadTimeoutMs,
|
|
@@ -15479,8 +15424,7 @@ var VideoIdValidation = function VideoIdValidation(_a) {
|
|
|
15479
15424
|
captureSignature: captureSignature,
|
|
15480
15425
|
captureSignatureVideo: captureSignatureVideo,
|
|
15481
15426
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
15482
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
15483
|
-
debugMode: debugMode
|
|
15427
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
15484
15428
|
}))));
|
|
15485
15429
|
};
|
|
15486
15430
|
|
|
@@ -15637,8 +15581,7 @@ var CustomerBiometricsEnrollment = function CustomerBiometricsEnrollment(_a) {
|
|
|
15637
15581
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
15638
15582
|
captureSignature: captureSignature,
|
|
15639
15583
|
captureSignatureVideo: captureSignatureVideo,
|
|
15640
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
15641
|
-
debugMode: debugMode
|
|
15584
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
15642
15585
|
}))));
|
|
15643
15586
|
};
|
|
15644
15587
|
|
|
@@ -15696,11 +15639,10 @@ var DocumentCapture = function DocumentCapture(_a) {
|
|
|
15696
15639
|
onDocumentUploadFailed: onDocumentUploadFailed,
|
|
15697
15640
|
geolocationEnabled: geolocationEnabled,
|
|
15698
15641
|
geolocationRequired: geolocationRequired
|
|
15699
|
-
}, /*#__PURE__*/React__namespace.default.createElement(
|
|
15642
|
+
}, /*#__PURE__*/React__namespace.default.createElement(CameraStoreProvider, {
|
|
15700
15643
|
requestAccessAutomatically: false,
|
|
15701
|
-
|
|
15702
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
15703
|
-
debugMode: debugMode
|
|
15644
|
+
preferIphoneContinuityCamera: true,
|
|
15645
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
15704
15646
|
}, /*#__PURE__*/React__namespace.default.createElement(DocumentCaptureWizard, {
|
|
15705
15647
|
onSuccess: onComplete,
|
|
15706
15648
|
onExitCapture: onExitCapture,
|