idmission-web-sdk 2.2.47 → 2.2.48
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 +1132 -1073
- 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 +1132 -1073
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +1150 -1091
- 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 +1 -1
- package/dist/components/camera/CameraProvider.d.ts +0 -17
- package/dist/components/camera/CameraProvider.d.ts.map +0 -1
package/dist/sdk2.esm.js
CHANGED
|
@@ -201,7 +201,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
201
201
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
202
202
|
};
|
|
203
203
|
|
|
204
|
-
var webSdkVersion = '2.2.
|
|
204
|
+
var webSdkVersion = '2.2.48';
|
|
205
205
|
|
|
206
206
|
function getPlatform() {
|
|
207
207
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -770,11 +770,11 @@ function setDefaultAuthUrl(url) {
|
|
|
770
770
|
if (!allowedAuthUrls.includes(url)) throw new Error('invalid auth url');
|
|
771
771
|
defaultAuthUrl = url;
|
|
772
772
|
}
|
|
773
|
-
var initialState$
|
|
773
|
+
var initialState$6 = {
|
|
774
774
|
authUrl: defaultAuthUrl,
|
|
775
775
|
sessionCheckState: 'READY'
|
|
776
776
|
};
|
|
777
|
-
var AuthStateContext = /*#__PURE__*/createContext(initialState$
|
|
777
|
+
var AuthStateContext = /*#__PURE__*/createContext(initialState$6);
|
|
778
778
|
var AuthDispatchContext = /*#__PURE__*/createContext(function () {});
|
|
779
779
|
var reducer$4 = function reducer(state, action) {
|
|
780
780
|
switch (action.type) {
|
|
@@ -806,7 +806,7 @@ function useAuthReducer(authUrl, sessionId) {
|
|
|
806
806
|
if (authUrl === void 0) {
|
|
807
807
|
authUrl = defaultAuthUrl;
|
|
808
808
|
}
|
|
809
|
-
var _a = useReducer(reducer$4, _assign(_assign({}, initialState$
|
|
809
|
+
var _a = useReducer(reducer$4, _assign(_assign({}, initialState$6), {
|
|
810
810
|
authUrl: authUrl
|
|
811
811
|
})),
|
|
812
812
|
state = _a[0],
|
|
@@ -1858,636 +1858,34 @@ function createUpload(blob, options) {
|
|
|
1858
1858
|
typeof window.tus !== 'undefined' ? window.tus.Upload : Upload;
|
|
1859
1859
|
return new UploadType(blob, options);
|
|
1860
1860
|
}
|
|
1861
|
-
function convertBase64ToBlob(base64Image) {
|
|
1862
|
-
// Split into two parts
|
|
1863
|
-
var parts = base64Image.split(';base64,');
|
|
1864
|
-
// Hold the content type
|
|
1865
|
-
var imageType = parts[0].split(':')[1];
|
|
1866
|
-
// Decode Base64 string
|
|
1867
|
-
var decodedData = window.atob(parts[1]);
|
|
1868
|
-
// Create UNIT8ARRAY of size same as row data length
|
|
1869
|
-
var uInt8Array = new Uint8Array(decodedData.length);
|
|
1870
|
-
// Insert all character code into uInt8Array
|
|
1871
|
-
for (var i = 0; i < decodedData.length; ++i) {
|
|
1872
|
-
uInt8Array[i] = decodedData.charCodeAt(i);
|
|
1873
|
-
}
|
|
1874
|
-
// Return BLOB image after conversion
|
|
1875
|
-
return new Blob([uInt8Array], {
|
|
1876
|
-
type: imageType
|
|
1877
|
-
});
|
|
1878
|
-
}
|
|
1879
|
-
function calculateMd5(blob) {
|
|
1880
|
-
return new Promise(function (resolve, reject) {
|
|
1881
|
-
var reader = new FileReader();
|
|
1882
|
-
reader.readAsArrayBuffer(blob);
|
|
1883
|
-
reader.onloadend = function () {
|
|
1884
|
-
if (!reader.result) return reject(new Error('Failed to read file'));
|
|
1885
|
-
resolve(SparkMD5.ArrayBuffer.hash(reader.result));
|
|
1886
|
-
};
|
|
1887
|
-
});
|
|
1888
|
-
}
|
|
1889
|
-
|
|
1890
|
-
function getFrameDimensions(frame) {
|
|
1891
|
-
var frameWidth = frame.width,
|
|
1892
|
-
frameHeight = frame.height;
|
|
1893
|
-
if (frame instanceof HTMLImageElement) {
|
|
1894
|
-
frameWidth = frame.naturalWidth;
|
|
1895
|
-
frameHeight = frame.naturalHeight;
|
|
1896
|
-
}
|
|
1897
|
-
if (frame instanceof HTMLVideoElement) {
|
|
1898
|
-
frameWidth = frame.videoWidth;
|
|
1899
|
-
frameHeight = frame.videoHeight;
|
|
1900
|
-
}
|
|
1901
|
-
return [frameWidth, frameHeight];
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
var InvisibleCanvas = styled.canvas(templateObject_1$G || (templateObject_1$G = __makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
|
|
1905
|
-
function drawToCanvas(canvas, frame, width, height) {
|
|
1906
|
-
if (!canvas) return;
|
|
1907
|
-
var ctx = canvas.getContext('2d');
|
|
1908
|
-
if (!ctx) return;
|
|
1909
|
-
if (!width || !height) {
|
|
1910
|
-
var _a = getFrameDimensions(frame),
|
|
1911
|
-
frameWidth = _a[0],
|
|
1912
|
-
frameHeight = _a[1];
|
|
1913
|
-
width || (width = frameWidth);
|
|
1914
|
-
height || (height = frameHeight);
|
|
1915
|
-
}
|
|
1916
|
-
canvas.width = width;
|
|
1917
|
-
canvas.height = height;
|
|
1918
|
-
ctx.drawImage(frame, 0, 0, width, height);
|
|
1919
|
-
}
|
|
1920
|
-
function clearCanvas(canvas) {
|
|
1921
|
-
var _a;
|
|
1922
|
-
(_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);
|
|
1923
|
-
}
|
|
1924
|
-
var templateObject_1$G;
|
|
1925
|
-
|
|
1926
|
-
function listAvailableCameras(facingMode_1) {
|
|
1927
|
-
return __awaiter(this, arguments, void 0, function (facingMode, requestMicAccess) {
|
|
1928
|
-
var cameraEnumerationStream, videoDevices;
|
|
1929
|
-
if (requestMicAccess === void 0) {
|
|
1930
|
-
requestMicAccess = false;
|
|
1931
|
-
}
|
|
1932
|
-
return __generator(this, function (_a) {
|
|
1933
|
-
switch (_a.label) {
|
|
1934
|
-
case 0:
|
|
1935
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
1936
|
-
video: {
|
|
1937
|
-
facingMode: {
|
|
1938
|
-
exact: facingMode
|
|
1939
|
-
}
|
|
1940
|
-
},
|
|
1941
|
-
audio: requestMicAccess
|
|
1942
|
-
})
|
|
1943
|
-
// This lists all available cameras attached to the user's device.
|
|
1944
|
-
];
|
|
1945
|
-
case 1:
|
|
1946
|
-
cameraEnumerationStream = _a.sent();
|
|
1947
|
-
return [4 /*yield*/, navigator.mediaDevices.enumerateDevices()];
|
|
1948
|
-
case 2:
|
|
1949
|
-
videoDevices = _a.sent().filter(function (_a) {
|
|
1950
|
-
var kind = _a.kind;
|
|
1951
|
-
return kind === 'videoinput';
|
|
1952
|
-
});
|
|
1953
|
-
// Release the access to the user's camera that we obtained for enumeration purposes.
|
|
1954
|
-
cameraEnumerationStream.getVideoTracks().forEach(function (track) {
|
|
1955
|
-
track.enabled = false;
|
|
1956
|
-
track.stop();
|
|
1957
|
-
});
|
|
1958
|
-
cameraEnumerationStream = null;
|
|
1959
|
-
return [2 /*return*/, videoDevices];
|
|
1960
|
-
}
|
|
1961
|
-
});
|
|
1962
|
-
});
|
|
1963
|
-
}
|
|
1964
|
-
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) {
|
|
1965
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
1966
|
-
});
|
|
1967
|
-
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) {
|
|
1968
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
1969
|
-
});
|
|
1970
|
-
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) {
|
|
1971
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
1972
|
-
});
|
|
1973
|
-
var labelMatches = function labelMatches(labelOrDevice, labelSetOrLabel) {
|
|
1974
|
-
var label = labelOrDevice instanceof MediaDeviceInfo ? getDeviceLabel(labelOrDevice) : labelOrDevice;
|
|
1975
|
-
var labelSet = typeof labelSetOrLabel === 'string' ? [labelSetOrLabel] : labelSetOrLabel;
|
|
1976
|
-
return labelSet.some(function (l) {
|
|
1977
|
-
return label.includes(l);
|
|
1978
|
-
});
|
|
1979
|
-
};
|
|
1980
|
-
var getDeviceLabel = function getDeviceLabel(deviceInfo) {
|
|
1981
|
-
return deviceInfo.label.toLocaleLowerCase().split(' ').join('');
|
|
1982
|
-
};
|
|
1983
|
-
var currentCamera;
|
|
1984
|
-
var currentAudioStream;
|
|
1985
|
-
function obtainCameraAccess(stream, deviceLabel, video) {
|
|
1986
|
-
releaseCameraAccess();
|
|
1987
|
-
log('obtaining camera access...');
|
|
1988
|
-
var _a = stream.getVideoTracks()[0].getSettings(),
|
|
1989
|
-
width = _a.width,
|
|
1990
|
-
height = _a.height;
|
|
1991
|
-
var label = deviceLabel.toLocaleLowerCase().split(' ').join('');
|
|
1992
|
-
var isRearFacing = labelMatches(label, __spreadArray(__spreadArray(__spreadArray([], rearLabels, true), backUltraWideLabels, true), ['iphone'], false));
|
|
1993
|
-
var release = function release() {
|
|
1994
|
-
stream.getTracks().forEach(function (track) {
|
|
1995
|
-
track.enabled = false;
|
|
1996
|
-
track.stop();
|
|
1997
|
-
});
|
|
1998
|
-
if (video) {
|
|
1999
|
-
video.pause();
|
|
2000
|
-
video.srcObject = null;
|
|
2001
|
-
video.src = '';
|
|
2002
|
-
}
|
|
2003
|
-
};
|
|
2004
|
-
width || (width = 0);
|
|
2005
|
-
height || (height = 0);
|
|
2006
|
-
currentCamera = {
|
|
2007
|
-
label: deviceLabel,
|
|
2008
|
-
stream: stream,
|
|
2009
|
-
width: width,
|
|
2010
|
-
height: height,
|
|
2011
|
-
isRearFacing: isRearFacing,
|
|
2012
|
-
release: release
|
|
2013
|
-
};
|
|
2014
|
-
if (video) video.srcObject = stream;
|
|
2015
|
-
return currentCamera;
|
|
2016
|
-
}
|
|
2017
|
-
function releaseCameraAccess() {
|
|
2018
|
-
if (!currentCamera) return;
|
|
2019
|
-
log('releasing camera access...');
|
|
2020
|
-
currentCamera.release();
|
|
2021
|
-
currentCamera = undefined;
|
|
2022
|
-
}
|
|
2023
|
-
function releaseMicrophoneAccess() {
|
|
2024
|
-
var _a;
|
|
2025
|
-
if (!currentAudioStream) return;
|
|
2026
|
-
log('releasing microphone access...');
|
|
2027
|
-
(_a = currentAudioStream.stop) === null || _a === void 0 ? void 0 : _a.call(currentAudioStream);
|
|
2028
|
-
currentAudioStream.getAudioTracks().forEach(function (t) {
|
|
2029
|
-
var _a;
|
|
2030
|
-
(_a = t.stop) === null || _a === void 0 ? void 0 : _a.call(t);
|
|
2031
|
-
});
|
|
2032
|
-
currentAudioStream = undefined;
|
|
2033
|
-
}
|
|
2034
|
-
function usePreferredCaptureDevice(_a) {
|
|
2035
|
-
var _b = _a === void 0 ? {} : _a,
|
|
2036
|
-
_c = _b.requestAccessAutomatically,
|
|
2037
|
-
requestAccessAutomatically = _c === void 0 ? true : _c,
|
|
2038
|
-
_d = _b.preferFrontFacingCamera,
|
|
2039
|
-
preferFrontFacingCamera = _d === void 0 ? false : _d,
|
|
2040
|
-
_e = _b.preferContinuityCamera,
|
|
2041
|
-
preferContinuityCamera = _e === void 0 ? true : _e,
|
|
2042
|
-
_f = _b.requireMicrophoneAccess,
|
|
2043
|
-
requireMicrophoneAccess = _f === void 0 ? false : _f,
|
|
2044
|
-
_g = _b.maxVideoWidth,
|
|
2045
|
-
maxVideoWidth = _g === void 0 ? 1920 : _g,
|
|
2046
|
-
maxFps = _b.maxFps,
|
|
2047
|
-
_h = _b.debugMode,
|
|
2048
|
-
debugMode = _h === void 0 ? false : _h;
|
|
2049
|
-
var videoRef = useRef(null);
|
|
2050
|
-
var videoRefStack = useRef([]);
|
|
2051
|
-
var cameraRef = useRef(null);
|
|
2052
|
-
var _j = useState(false),
|
|
2053
|
-
cameraReady = _j[0],
|
|
2054
|
-
setCameraReady = _j[1];
|
|
2055
|
-
var _k = useState(false),
|
|
2056
|
-
microphoneReady = _k[0],
|
|
2057
|
-
setMicrophoneReady = _k[1];
|
|
2058
|
-
var _l = useState(null),
|
|
2059
|
-
videoDevice = _l[0],
|
|
2060
|
-
setVideoDevice = _l[1];
|
|
2061
|
-
var _m = useState(null),
|
|
2062
|
-
audioStream = _m[0],
|
|
2063
|
-
setAudioStream = _m[1];
|
|
2064
|
-
var _o = useState(false),
|
|
2065
|
-
videoLoaded = _o[0],
|
|
2066
|
-
setVideoLoaded = _o[1];
|
|
2067
|
-
var _p = useState(false),
|
|
2068
|
-
iphoneContinuityCameraAvailable = _p[0],
|
|
2069
|
-
setIphoneContinuityCameraAvailable = _p[1];
|
|
2070
|
-
var _q = useState(preferContinuityCamera),
|
|
2071
|
-
iphoneContinuityCameraAllowed = _q[0],
|
|
2072
|
-
setIphoneContinuityCameraAllowed = _q[1];
|
|
2073
|
-
var _r = useState(false),
|
|
2074
|
-
iphoneContinuityCameraDenied = _r[0],
|
|
2075
|
-
setIphoneContinuityCameraDenied = _r[1];
|
|
2076
|
-
var _s = useState(false),
|
|
2077
|
-
cameraAccessDenied = _s[0],
|
|
2078
|
-
setCameraAccessDenied = _s[1];
|
|
2079
|
-
var _t = useState(false),
|
|
2080
|
-
microphoneAccessDenied = _t[0],
|
|
2081
|
-
setMicrophoneAccessDenied = _t[1];
|
|
2082
|
-
var videoRefElement = videoRef.current;
|
|
2083
|
-
useEffect(function pushVideoRefToStackWhenChanged() {
|
|
2084
|
-
// proceed if the video element being mounted is not already at the top of the videoRefStack.
|
|
2085
|
-
var topOfStack = videoRefStack.current.slice(-1)[0];
|
|
2086
|
-
if (videoRefElement && videoRefElement !== topOfStack) {
|
|
2087
|
-
log('adding video to stack', videoRefElement);
|
|
2088
|
-
videoRefStack.current.push(videoRefElement);
|
|
2089
|
-
}
|
|
2090
|
-
}, [videoRefElement]);
|
|
2091
|
-
var onVideoUnmounted = useCallback(function (videoElement) {
|
|
2092
|
-
log('removing video from stack', videoElement);
|
|
2093
|
-
videoRefStack.current = videoRefStack.current.filter(function (v) {
|
|
2094
|
-
return v !== videoElement;
|
|
2095
|
-
});
|
|
2096
|
-
videoRef.current = videoRefStack.current.slice(-1)[0]; // top of stack.
|
|
2097
|
-
log('new videoRef is', videoRef.current);
|
|
2098
|
-
}, []);
|
|
2099
|
-
useEffect(function resetCameraOnContinuityPreferenceChanged() {
|
|
2100
|
-
if (debugMode) {
|
|
2101
|
-
log('iphone continuity camera allowed changed', iphoneContinuityCameraAllowed);
|
|
2102
|
-
}
|
|
2103
|
-
releaseCameraAccess();
|
|
2104
|
-
cameraRef.current = null;
|
|
2105
|
-
setVideoLoaded(false);
|
|
2106
|
-
}, [debugMode, iphoneContinuityCameraAllowed]);
|
|
2107
|
-
// NOTE: the bound callback function here is called requestCameraAccess, because
|
|
2108
|
-
// it initiates the useEffect chain that results in camera access being requested
|
|
2109
|
-
// (requestCameraAccessAutomatically -> chooseFromAvailableCameras -> accessChosenCamera).
|
|
2110
|
-
//
|
|
2111
|
-
// We chose to title the inner function "chooseFromAvailableCameras" because
|
|
2112
|
-
// that's all it literally does -- the available cameras are enumerated, and then
|
|
2113
|
-
// the result is parsed to decide which one we like best, which is then passed to
|
|
2114
|
-
// setVideoDevice, which causes accessChosenCamera to trigger.
|
|
2115
|
-
//
|
|
2116
|
-
// I am not a huge fan of getUserMedia's design -- you need to call it twice in order
|
|
2117
|
-
// to select the "best" camera for your application's purposes.
|
|
2118
|
-
var requestCameraAccess = useCallback(function chooseFromAvailableCameras() {
|
|
2119
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2120
|
-
var availableCameras, selectedCamera, platform_1, iphoneContinuityCamera, e_1;
|
|
2121
|
-
var _a, _b;
|
|
2122
|
-
return __generator(this, function (_c) {
|
|
2123
|
-
switch (_c.label) {
|
|
2124
|
-
case 0:
|
|
2125
|
-
setCameraReady(false);
|
|
2126
|
-
setCameraAccessDenied(false);
|
|
2127
|
-
_c.label = 1;
|
|
2128
|
-
case 1:
|
|
2129
|
-
_c.trys.push([1, 3,, 4]);
|
|
2130
|
-
return [4 /*yield*/, listAvailableCameras()];
|
|
2131
|
-
case 2:
|
|
2132
|
-
availableCameras = _c.sent();
|
|
2133
|
-
selectedCamera = void 0;
|
|
2134
|
-
if (debugMode) {
|
|
2135
|
-
log('availableCameras', availableCameras);
|
|
2136
|
-
}
|
|
2137
|
-
platform_1 = getPlatform();
|
|
2138
|
-
if (debugMode) {
|
|
2139
|
-
log('platformDetails', platform_1);
|
|
2140
|
-
}
|
|
2141
|
-
if (!iphoneContinuityCameraDenied && (!(platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) || platform_1.os.family === 'OS X')) {
|
|
2142
|
-
iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
|
|
2143
|
-
return labelMatches(deviceInfo, 'iphone');
|
|
2144
|
-
});
|
|
2145
|
-
setIphoneContinuityCameraAvailable(!!iphoneContinuityCamera);
|
|
2146
|
-
if (iphoneContinuityCamera && iphoneContinuityCameraAllowed) {
|
|
2147
|
-
selectedCamera = iphoneContinuityCamera;
|
|
2148
|
-
}
|
|
2149
|
-
} 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) {
|
|
2150
|
-
return c.label.startsWith('camera2 ');
|
|
2151
|
-
})) {
|
|
2152
|
-
availableCameras = availableCameras.sort(function (a, b) {
|
|
2153
|
-
return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
|
|
2154
|
-
});
|
|
2155
|
-
if (debugMode) {
|
|
2156
|
-
log('cameras have been sorted', availableCameras);
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
if (preferFrontFacingCamera) {
|
|
2160
|
-
selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
2161
|
-
return labelMatches(deviceInfo, frontLabels);
|
|
2162
|
-
});
|
|
2163
|
-
}
|
|
2164
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
2165
|
-
return labelMatches(deviceInfo, 'backtriplecamera');
|
|
2166
|
-
}));
|
|
2167
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
2168
|
-
return labelMatches(deviceInfo, 'backdualcamera');
|
|
2169
|
-
}));
|
|
2170
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
2171
|
-
return labelMatches(deviceInfo, rearLabels) && !labelMatches(deviceInfo, backUltraWideLabels);
|
|
2172
|
-
}));
|
|
2173
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
2174
|
-
return labelMatches(deviceInfo, rearLabels);
|
|
2175
|
-
}));
|
|
2176
|
-
// on iOS, the front facing camera always is at the first position in the list, so we skip it if all else fails.
|
|
2177
|
-
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) {
|
|
2178
|
-
selectedCamera || (selectedCamera = availableCameras[1]);
|
|
2179
|
-
}
|
|
2180
|
-
selectedCamera || (selectedCamera = availableCameras[0]);
|
|
2181
|
-
if (debugMode) log('selectedCamera', selectedCamera);
|
|
2182
|
-
setVideoDevice(selectedCamera);
|
|
2183
|
-
return [3 /*break*/, 4];
|
|
2184
|
-
case 3:
|
|
2185
|
-
e_1 = _c.sent();
|
|
2186
|
-
if (e_1.name === 'NotAllowedError') {
|
|
2187
|
-
error('camera access has been blocked by the user', e_1);
|
|
2188
|
-
setCameraAccessDenied(true);
|
|
2189
|
-
} else {
|
|
2190
|
-
error('camera access encountered some other error', e_1);
|
|
2191
|
-
throw e_1;
|
|
2192
|
-
}
|
|
2193
|
-
return [3 /*break*/, 4];
|
|
2194
|
-
case 4:
|
|
2195
|
-
return [2 /*return*/];
|
|
2196
|
-
}
|
|
2197
|
-
});
|
|
2198
|
-
});
|
|
2199
|
-
}, [debugMode, iphoneContinuityCameraAllowed, iphoneContinuityCameraDenied, preferFrontFacingCamera]);
|
|
2200
|
-
useEffect(function requestCameraAccessAutomatically() {
|
|
2201
|
-
if (requestAccessAutomatically && !cameraAccessDenied) {
|
|
2202
|
-
requestCameraAccess()["catch"](error);
|
|
2203
|
-
}
|
|
2204
|
-
}, [cameraAccessDenied, requestAccessAutomatically, requestCameraAccess]);
|
|
2205
|
-
useEffect(function accessChosenCamera() {
|
|
2206
|
-
var _this = this;
|
|
2207
|
-
var _a;
|
|
2208
|
-
if (!videoDevice) return;
|
|
2209
|
-
var cleanup = function cleanup() {
|
|
2210
|
-
releaseCameraAccess();
|
|
2211
|
-
cameraRef.current = null;
|
|
2212
|
-
setVideoLoaded(false);
|
|
2213
|
-
};
|
|
2214
|
-
if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) return cleanup;
|
|
2215
|
-
(function () {
|
|
2216
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
2217
|
-
var constraints, stream, e_2, handleStreamEnded;
|
|
2218
|
-
var _a;
|
|
2219
|
-
return __generator(this, function (_b) {
|
|
2220
|
-
switch (_b.label) {
|
|
2221
|
-
case 0:
|
|
2222
|
-
constraints = {
|
|
2223
|
-
audio: false,
|
|
2224
|
-
video: {
|
|
2225
|
-
deviceId: {
|
|
2226
|
-
exact: videoDevice.deviceId
|
|
2227
|
-
},
|
|
2228
|
-
width: {
|
|
2229
|
-
ideal: maxVideoWidth
|
|
2230
|
-
},
|
|
2231
|
-
aspectRatio: 1.777777778,
|
|
2232
|
-
frameRate: {}
|
|
2233
|
-
}
|
|
2234
|
-
};
|
|
2235
|
-
if (maxFps) {
|
|
2236
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2237
|
-
// @ts-ignore
|
|
2238
|
-
constraints.video.frameRate = {
|
|
2239
|
-
max: maxFps
|
|
2240
|
-
};
|
|
2241
|
-
}
|
|
2242
|
-
stream = null;
|
|
2243
|
-
_b.label = 1;
|
|
2244
|
-
case 1:
|
|
2245
|
-
_b.trys.push([1, 3,, 4]);
|
|
2246
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
|
|
2247
|
-
case 2:
|
|
2248
|
-
stream = _b.sent();
|
|
2249
|
-
return [3 /*break*/, 4];
|
|
2250
|
-
case 3:
|
|
2251
|
-
e_2 = _b.sent();
|
|
2252
|
-
if (e_2.name === 'NotAllowedError') {
|
|
2253
|
-
if (iphoneContinuityCameraAllowed) {
|
|
2254
|
-
setIphoneContinuityCameraAvailable(false);
|
|
2255
|
-
setIphoneContinuityCameraDenied(true);
|
|
2256
|
-
} else {
|
|
2257
|
-
setCameraAccessDenied(true);
|
|
2258
|
-
}
|
|
2259
|
-
return [2 /*return*/];
|
|
2260
|
-
}
|
|
2261
|
-
return [3 /*break*/, 4];
|
|
2262
|
-
case 4:
|
|
2263
|
-
if (!!stream) return [3 /*break*/, 8];
|
|
2264
|
-
_b.label = 5;
|
|
2265
|
-
case 5:
|
|
2266
|
-
_b.trys.push([5, 7,, 8]);
|
|
2267
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
2268
|
-
audio: false,
|
|
2269
|
-
video: true
|
|
2270
|
-
})];
|
|
2271
|
-
case 6:
|
|
2272
|
-
stream = _b.sent();
|
|
2273
|
-
log('opened stream with no width and height constraints');
|
|
2274
|
-
return [3 /*break*/, 8];
|
|
2275
|
-
case 7:
|
|
2276
|
-
_b.sent();
|
|
2277
|
-
log('cannot open stream at all');
|
|
2278
|
-
return [3 /*break*/, 8];
|
|
2279
|
-
case 8:
|
|
2280
|
-
if (!stream) {
|
|
2281
|
-
throw new Error('failed to open camera');
|
|
2282
|
-
}
|
|
2283
|
-
handleStreamEnded = function handleStreamEnded() {
|
|
2284
|
-
if (iphoneContinuityCameraAvailable && iphoneContinuityCameraAllowed) {
|
|
2285
|
-
log('someone unplugged the continuity camera');
|
|
2286
|
-
releaseCameraAccess();
|
|
2287
|
-
cameraRef.current = null;
|
|
2288
|
-
setIphoneContinuityCameraAvailable(false);
|
|
2289
|
-
setIphoneContinuityCameraDenied(true);
|
|
2290
|
-
setVideoDevice(null);
|
|
2291
|
-
} else {
|
|
2292
|
-
log('someone unplugged the webcam');
|
|
2293
|
-
releaseCameraAccess();
|
|
2294
|
-
cameraRef.current = null;
|
|
2295
|
-
setVideoLoaded(false);
|
|
2296
|
-
setCameraAccessDenied(true);
|
|
2297
|
-
}
|
|
2298
|
-
};
|
|
2299
|
-
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', handleStreamEnded);
|
|
2300
|
-
stream.getVideoTracks().forEach(function (track) {
|
|
2301
|
-
track.onended = handleStreamEnded;
|
|
2302
|
-
});
|
|
2303
|
-
cameraRef.current = obtainCameraAccess(stream, videoDevice.label, videoRef.current);
|
|
2304
|
-
return [2 /*return*/];
|
|
2305
|
-
}
|
|
2306
|
-
});
|
|
2307
|
-
});
|
|
2308
|
-
})();
|
|
2309
|
-
return cleanup;
|
|
2310
|
-
}, [iphoneContinuityCameraAllowed, iphoneContinuityCameraAvailable, maxFps, maxVideoWidth, videoDevice]);
|
|
2311
|
-
useEffect(function triggerCameraReady() {
|
|
2312
|
-
// TODO: in the future let's evaluate whether we can simplify this to just
|
|
2313
|
-
// setCameraReady(!!videoDevice && videoLoaded) -- we are wondering whether
|
|
2314
|
-
// we somehow depend on this being set twice.
|
|
2315
|
-
setCameraReady(false);
|
|
2316
|
-
if (videoDevice && videoLoaded) {
|
|
2317
|
-
setCameraReady(videoDevice && videoLoaded);
|
|
2318
|
-
}
|
|
2319
|
-
}, [videoLoaded, videoDevice]);
|
|
2320
|
-
var requestMicrophoneAccess = useCallback(function _requestMicrophoneAccess() {
|
|
2321
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2322
|
-
var stream;
|
|
2323
|
-
return __generator(this, function (_a) {
|
|
2324
|
-
switch (_a.label) {
|
|
2325
|
-
case 0:
|
|
2326
|
-
setMicrophoneReady(false);
|
|
2327
|
-
setMicrophoneAccessDenied(false);
|
|
2328
|
-
_a.label = 1;
|
|
2329
|
-
case 1:
|
|
2330
|
-
_a.trys.push([1, 3,, 4]);
|
|
2331
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
2332
|
-
audio: true,
|
|
2333
|
-
video: false
|
|
2334
|
-
})];
|
|
2335
|
-
case 2:
|
|
2336
|
-
stream = _a.sent();
|
|
2337
|
-
currentAudioStream = stream;
|
|
2338
|
-
setAudioStream(stream);
|
|
2339
|
-
setMicrophoneReady(true);
|
|
2340
|
-
stream.getAudioTracks().forEach(function (track) {
|
|
2341
|
-
track.onended = function () {
|
|
2342
|
-
setMicrophoneAccessDenied(true);
|
|
2343
|
-
};
|
|
2344
|
-
});
|
|
2345
|
-
return [3 /*break*/, 4];
|
|
2346
|
-
case 3:
|
|
2347
|
-
_a.sent();
|
|
2348
|
-
setMicrophoneAccessDenied(true);
|
|
2349
|
-
return [3 /*break*/, 4];
|
|
2350
|
-
case 4:
|
|
2351
|
-
return [2 /*return*/];
|
|
2352
|
-
}
|
|
2353
|
-
});
|
|
2354
|
-
});
|
|
2355
|
-
}, []);
|
|
2356
|
-
useEffect(function requestMicrophoneAccessIfNeeded() {
|
|
2357
|
-
if (!requireMicrophoneAccess || microphoneAccessDenied) return;
|
|
2358
|
-
requestMicrophoneAccess()["catch"](error);
|
|
2359
|
-
return function () {
|
|
2360
|
-
releaseMicrophoneAccess();
|
|
2361
|
-
setAudioStream(null);
|
|
2362
|
-
setMicrophoneReady(false);
|
|
2363
|
-
};
|
|
2364
|
-
}, [microphoneAccessDenied, requestMicrophoneAccess, requireMicrophoneAccess]);
|
|
2365
|
-
var takePhoto = useCallback(function _takePhoto() {
|
|
2366
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2367
|
-
var canvas;
|
|
2368
|
-
return __generator(this, function (_a) {
|
|
2369
|
-
switch (_a.label) {
|
|
2370
|
-
case 0:
|
|
2371
|
-
if (!cameraRef.current) return [2 /*return*/, null];
|
|
2372
|
-
if (!(typeof ImageCapture !== 'undefined')) return [3 /*break*/, 2];
|
|
2373
|
-
return [4 /*yield*/, new ImageCapture(cameraRef.current.stream.getTracks()[0]).takePhoto()];
|
|
2374
|
-
case 1:
|
|
2375
|
-
return [2 /*return*/, _a.sent()];
|
|
2376
|
-
case 2:
|
|
2377
|
-
if (!videoRef.current) return [2 /*return*/, null];
|
|
2378
|
-
canvas = document.createElement('canvas');
|
|
2379
|
-
drawToCanvas(canvas, videoRef.current);
|
|
2380
|
-
return [2 /*return*/, new Promise(function (resolve) {
|
|
2381
|
-
return canvas.toBlob(resolve);
|
|
2382
|
-
})];
|
|
2383
|
-
}
|
|
2384
|
-
});
|
|
2385
|
-
});
|
|
2386
|
-
}, []);
|
|
2387
|
-
return useMemo(function () {
|
|
2388
|
-
return {
|
|
2389
|
-
videoRef: videoRef,
|
|
2390
|
-
videoDevice: videoDevice,
|
|
2391
|
-
videoLoaded: videoLoaded,
|
|
2392
|
-
setVideoLoaded: setVideoLoaded,
|
|
2393
|
-
onVideoUnmounted: onVideoUnmounted,
|
|
2394
|
-
cameraRef: cameraRef,
|
|
2395
|
-
cameraReady: cameraReady,
|
|
2396
|
-
cameraAccessDenied: cameraAccessDenied,
|
|
2397
|
-
requestCameraAccess: requestCameraAccess,
|
|
2398
|
-
releaseCameraAccess: releaseCameraAccess,
|
|
2399
|
-
iphoneContinuityCameraAvailable: iphoneContinuityCameraAvailable,
|
|
2400
|
-
iphoneContinuityCameraAllowed: iphoneContinuityCameraAllowed,
|
|
2401
|
-
setIphoneContinuityCameraAllowed: setIphoneContinuityCameraAllowed,
|
|
2402
|
-
takePhoto: takePhoto,
|
|
2403
|
-
audioStream: audioStream,
|
|
2404
|
-
microphoneReady: microphoneReady,
|
|
2405
|
-
microphoneAccessDenied: microphoneAccessDenied,
|
|
2406
|
-
requestMicrophoneAccess: requestMicrophoneAccess
|
|
2407
|
-
};
|
|
2408
|
-
}, [audioStream, cameraAccessDenied, cameraReady, iphoneContinuityCameraAllowed, iphoneContinuityCameraAvailable, microphoneAccessDenied, microphoneReady, onVideoUnmounted, requestCameraAccess, requestMicrophoneAccess, takePhoto, videoDevice, videoLoaded]);
|
|
2409
|
-
}
|
|
2410
|
-
|
|
2411
|
-
var CameraStateContext = /*#__PURE__*/createContext({
|
|
2412
|
-
videoRef: {
|
|
2413
|
-
current: null
|
|
2414
|
-
},
|
|
2415
|
-
videoDevice: null,
|
|
2416
|
-
videoLoaded: false,
|
|
2417
|
-
cameraRef: {
|
|
2418
|
-
current: null
|
|
2419
|
-
},
|
|
2420
|
-
cameraReady: false,
|
|
2421
|
-
cameraAccessDenied: false,
|
|
2422
|
-
requestCameraAccess: function requestCameraAccess() {
|
|
2423
|
-
return null;
|
|
2424
|
-
},
|
|
2425
|
-
releaseCameraAccess: function releaseCameraAccess() {
|
|
2426
|
-
return null;
|
|
2427
|
-
},
|
|
2428
|
-
iphoneContinuityCameraAvailable: false,
|
|
2429
|
-
iphoneContinuityCameraAllowed: true,
|
|
2430
|
-
setIphoneContinuityCameraAllowed: function setIphoneContinuityCameraAllowed() {
|
|
2431
|
-
return null;
|
|
2432
|
-
},
|
|
2433
|
-
takePhoto: function takePhoto() {
|
|
2434
|
-
return Promise.resolve(null);
|
|
2435
|
-
},
|
|
2436
|
-
setVideoLoaded: function setVideoLoaded() {
|
|
2437
|
-
return null;
|
|
2438
|
-
},
|
|
2439
|
-
onVideoUnmounted: function onVideoUnmounted() {
|
|
2440
|
-
return null;
|
|
2441
|
-
},
|
|
2442
|
-
audioStream: null,
|
|
2443
|
-
microphoneReady: false,
|
|
2444
|
-
microphoneAccessDenied: false,
|
|
2445
|
-
requestMicrophoneAccess: function requestMicrophoneAccess() {
|
|
2446
|
-
return null;
|
|
2447
|
-
}
|
|
2448
|
-
});
|
|
2449
|
-
var CameraProvider = function CameraProvider(_a) {
|
|
2450
|
-
var children = _a.children,
|
|
2451
|
-
_b = _a.requestAccessAutomatically,
|
|
2452
|
-
requestAccessAutomatically = _b === void 0 ? true : _b,
|
|
2453
|
-
_c = _a.preferFrontFacingCamera,
|
|
2454
|
-
preferFrontFacingCamera = _c === void 0 ? false : _c,
|
|
2455
|
-
_d = _a.preferContinuityCamera,
|
|
2456
|
-
preferContinuityCamera = _d === void 0 ? true : _d,
|
|
2457
|
-
_e = _a.requireMicrophoneAccess,
|
|
2458
|
-
requireMicrophoneAccess = _e === void 0 ? false : _e,
|
|
2459
|
-
_f = _a.maxVideoWidth,
|
|
2460
|
-
maxVideoWidth = _f === void 0 ? 1920 : _f,
|
|
2461
|
-
maxFps = _a.maxFps,
|
|
2462
|
-
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
2463
|
-
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
|
|
2464
|
-
_g = _a.debugMode,
|
|
2465
|
-
debugMode = _g === void 0 ? false : _g;
|
|
2466
|
-
var captureDevice = usePreferredCaptureDevice({
|
|
2467
|
-
requestAccessAutomatically: requestAccessAutomatically,
|
|
2468
|
-
preferFrontFacingCamera: preferFrontFacingCamera,
|
|
2469
|
-
preferContinuityCamera: preferContinuityCamera,
|
|
2470
|
-
requireMicrophoneAccess: requireMicrophoneAccess,
|
|
2471
|
-
maxVideoWidth: maxVideoWidth,
|
|
2472
|
-
maxFps: maxFps,
|
|
2473
|
-
debugMode: debugMode
|
|
1861
|
+
function convertBase64ToBlob(base64Image) {
|
|
1862
|
+
// Split into two parts
|
|
1863
|
+
var parts = base64Image.split(';base64,');
|
|
1864
|
+
// Hold the content type
|
|
1865
|
+
var imageType = parts[0].split(':')[1];
|
|
1866
|
+
// Decode Base64 string
|
|
1867
|
+
var decodedData = window.atob(parts[1]);
|
|
1868
|
+
// Create UNIT8ARRAY of size same as row data length
|
|
1869
|
+
var uInt8Array = new Uint8Array(decodedData.length);
|
|
1870
|
+
// Insert all character code into uInt8Array
|
|
1871
|
+
for (var i = 0; i < decodedData.length; ++i) {
|
|
1872
|
+
uInt8Array[i] = decodedData.charCodeAt(i);
|
|
1873
|
+
}
|
|
1874
|
+
// Return BLOB image after conversion
|
|
1875
|
+
return new Blob([uInt8Array], {
|
|
1876
|
+
type: imageType
|
|
2474
1877
|
});
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
return function () {
|
|
2484
|
-
releaseCameraAccess();
|
|
1878
|
+
}
|
|
1879
|
+
function calculateMd5(blob) {
|
|
1880
|
+
return new Promise(function (resolve, reject) {
|
|
1881
|
+
var reader = new FileReader();
|
|
1882
|
+
reader.readAsArrayBuffer(blob);
|
|
1883
|
+
reader.onloadend = function () {
|
|
1884
|
+
if (!reader.result) return reject(new Error('Failed to read file'));
|
|
1885
|
+
resolve(SparkMD5.ArrayBuffer.hash(reader.result));
|
|
2485
1886
|
};
|
|
2486
|
-
}
|
|
2487
|
-
|
|
2488
|
-
value: captureDevice
|
|
2489
|
-
}, children);
|
|
2490
|
-
};
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
2491
1889
|
|
|
2492
1890
|
var visionTasksBasePath = "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.7/wasm";
|
|
2493
1891
|
var visionRuntimePreloading = false;
|
|
@@ -2531,6 +1929,42 @@ function preloadVisionRuntime() {
|
|
|
2531
1929
|
});
|
|
2532
1930
|
}
|
|
2533
1931
|
|
|
1932
|
+
function getFrameDimensions(frame) {
|
|
1933
|
+
var frameWidth = frame.width,
|
|
1934
|
+
frameHeight = frame.height;
|
|
1935
|
+
if (frame instanceof HTMLImageElement) {
|
|
1936
|
+
frameWidth = frame.naturalWidth;
|
|
1937
|
+
frameHeight = frame.naturalHeight;
|
|
1938
|
+
}
|
|
1939
|
+
if (frame instanceof HTMLVideoElement) {
|
|
1940
|
+
frameWidth = frame.videoWidth;
|
|
1941
|
+
frameHeight = frame.videoHeight;
|
|
1942
|
+
}
|
|
1943
|
+
return [frameWidth, frameHeight];
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
var InvisibleCanvas = styled.canvas(templateObject_1$G || (templateObject_1$G = __makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
|
|
1947
|
+
function drawToCanvas(canvas, frame, width, height) {
|
|
1948
|
+
if (!canvas) return;
|
|
1949
|
+
var ctx = canvas.getContext('2d');
|
|
1950
|
+
if (!ctx) return;
|
|
1951
|
+
if (!width || !height) {
|
|
1952
|
+
var _a = getFrameDimensions(frame),
|
|
1953
|
+
frameWidth = _a[0],
|
|
1954
|
+
frameHeight = _a[1];
|
|
1955
|
+
width || (width = frameWidth);
|
|
1956
|
+
height || (height = frameHeight);
|
|
1957
|
+
}
|
|
1958
|
+
canvas.width = width;
|
|
1959
|
+
canvas.height = height;
|
|
1960
|
+
ctx.drawImage(frame, 0, 0, width, height);
|
|
1961
|
+
}
|
|
1962
|
+
function clearCanvas(canvas) {
|
|
1963
|
+
var _a;
|
|
1964
|
+
(_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);
|
|
1965
|
+
}
|
|
1966
|
+
var templateObject_1$G;
|
|
1967
|
+
|
|
2534
1968
|
function cropToShoulders(rawCanvas, cropCanvas, resizeCanvas, frame, face, quality, maxHeight) {
|
|
2535
1969
|
if (quality === void 0) {
|
|
2536
1970
|
quality = 0.92;
|
|
@@ -2834,7 +2268,8 @@ function useLoadFocusModel(_a) {
|
|
|
2834
2268
|
modelPath = _b === void 0 ? defaultFocusModelPath : _b,
|
|
2835
2269
|
_c = _a.modelLoadTimeoutMs,
|
|
2836
2270
|
modelLoadTimeoutMs = _c === void 0 ? defaultFocusModelLoadTimeoutMs : _c,
|
|
2837
|
-
onModelError = _a.onModelError
|
|
2271
|
+
onModelError = _a.onModelError,
|
|
2272
|
+
videoRef = _a.videoRef;
|
|
2838
2273
|
var _d = useState(false),
|
|
2839
2274
|
ready = _d[0],
|
|
2840
2275
|
setReady = _d[1];
|
|
@@ -2844,7 +2279,6 @@ function useLoadFocusModel(_a) {
|
|
|
2844
2279
|
var _f = useState(null),
|
|
2845
2280
|
modelError = _f[0],
|
|
2846
2281
|
setModelError = _f[1];
|
|
2847
|
-
var videoRef = useContext(CameraStateContext).videoRef;
|
|
2848
2282
|
useEffect(function loadModel() {
|
|
2849
2283
|
var _this = this;
|
|
2850
2284
|
setReady(false);
|
|
@@ -2982,7 +2416,8 @@ function closeFaceDetector() {
|
|
|
2982
2416
|
function useLoadFaceDetector(_a) {
|
|
2983
2417
|
var onModelError = _a.onModelError,
|
|
2984
2418
|
_b = _a.modelLoadTimeoutMs,
|
|
2985
|
-
modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b
|
|
2419
|
+
modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b,
|
|
2420
|
+
videoRef = _a.videoRef;
|
|
2986
2421
|
var _c = useState(false),
|
|
2987
2422
|
ready = _c[0],
|
|
2988
2423
|
setReady = _c[1];
|
|
@@ -2992,7 +2427,6 @@ function useLoadFaceDetector(_a) {
|
|
|
2992
2427
|
var _e = useState(null),
|
|
2993
2428
|
modelError = _e[0],
|
|
2994
2429
|
setModelError = _e[1];
|
|
2995
|
-
var videoRef = useContext(CameraStateContext).videoRef;
|
|
2996
2430
|
useEffect(function loadModel() {
|
|
2997
2431
|
var _this = this;
|
|
2998
2432
|
setReady(false);
|
|
@@ -3473,7 +2907,8 @@ function useLoadDocumentDetector(_a) {
|
|
|
3473
2907
|
modelLoadTimeoutMs = _c === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _c,
|
|
3474
2908
|
_d = _a.scoreThreshold,
|
|
3475
2909
|
scoreThreshold = _d === void 0 ? defaultDocumentDetectionScoreThreshold : _d,
|
|
3476
|
-
onModelError = _a.onModelError
|
|
2910
|
+
onModelError = _a.onModelError,
|
|
2911
|
+
videoRef = _a.videoRef;
|
|
3477
2912
|
var _e = useState(false),
|
|
3478
2913
|
ready = _e[0],
|
|
3479
2914
|
setReady = _e[1];
|
|
@@ -3483,7 +2918,6 @@ function useLoadDocumentDetector(_a) {
|
|
|
3483
2918
|
var _g = useState(null),
|
|
3484
2919
|
modelError = _g[0],
|
|
3485
2920
|
setModelError = _g[1];
|
|
3486
|
-
var videoRef = useContext(CameraStateContext).videoRef;
|
|
3487
2921
|
useEffect(function loadModel() {
|
|
3488
2922
|
var _this = this;
|
|
3489
2923
|
setReady(false);
|
|
@@ -3764,32 +3198,576 @@ function useFrameLoop(fn, _a) {
|
|
|
3764
3198
|
});
|
|
3765
3199
|
});
|
|
3766
3200
|
}
|
|
3767
|
-
renderPrediction().then();
|
|
3201
|
+
renderPrediction().then();
|
|
3202
|
+
return function () {
|
|
3203
|
+
loopId.current += 1;
|
|
3204
|
+
frameId.current && cancelAnimationFrame(frameId.current);
|
|
3205
|
+
timer && clearTimeout(timer);
|
|
3206
|
+
};
|
|
3207
|
+
}, [fn, running, throttleMs]);
|
|
3208
|
+
var start = useCallback(function () {
|
|
3209
|
+
startedAtRef.current = new Date();
|
|
3210
|
+
setRunning(true);
|
|
3211
|
+
}, []);
|
|
3212
|
+
var stop = useCallback(function () {
|
|
3213
|
+
loopId.current += 1; // force the loop to stop immediately.
|
|
3214
|
+
setRunning(false);
|
|
3215
|
+
startedAtRef.current = null;
|
|
3216
|
+
}, []);
|
|
3217
|
+
useEffect(function startAutomatically() {
|
|
3218
|
+
if (autoStart) start();
|
|
3219
|
+
return function () {
|
|
3220
|
+
stop();
|
|
3221
|
+
};
|
|
3222
|
+
}, [autoStart, start, stop]);
|
|
3223
|
+
return {
|
|
3224
|
+
start: start,
|
|
3225
|
+
stop: stop
|
|
3226
|
+
};
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
var createStoreImpl = function createStoreImpl(createState) {
|
|
3230
|
+
var state;
|
|
3231
|
+
var listeners = /* @__PURE__ */new Set();
|
|
3232
|
+
var setState = function setState(partial, replace) {
|
|
3233
|
+
var nextState = typeof partial === "function" ? partial(state) : partial;
|
|
3234
|
+
if (!Object.is(nextState, state)) {
|
|
3235
|
+
var previousState = state;
|
|
3236
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
3237
|
+
listeners.forEach(function (listener) {
|
|
3238
|
+
return listener(state, previousState);
|
|
3239
|
+
});
|
|
3240
|
+
}
|
|
3241
|
+
};
|
|
3242
|
+
var getState = function getState() {
|
|
3243
|
+
return state;
|
|
3244
|
+
};
|
|
3245
|
+
var getInitialState = function getInitialState() {
|
|
3246
|
+
return initialState;
|
|
3247
|
+
};
|
|
3248
|
+
var subscribe = function subscribe(listener) {
|
|
3249
|
+
listeners.add(listener);
|
|
3250
|
+
return function () {
|
|
3251
|
+
return listeners["delete"](listener);
|
|
3252
|
+
};
|
|
3253
|
+
};
|
|
3254
|
+
var api = {
|
|
3255
|
+
setState: setState,
|
|
3256
|
+
getState: getState,
|
|
3257
|
+
getInitialState: getInitialState,
|
|
3258
|
+
subscribe: subscribe
|
|
3259
|
+
};
|
|
3260
|
+
var initialState = state = createState(setState, getState, api);
|
|
3261
|
+
return api;
|
|
3262
|
+
};
|
|
3263
|
+
var createStore = function createStore(createState) {
|
|
3264
|
+
return createState ? createStoreImpl(createState) : createStoreImpl;
|
|
3265
|
+
};
|
|
3266
|
+
|
|
3267
|
+
var identity = function identity(arg) {
|
|
3268
|
+
return arg;
|
|
3269
|
+
};
|
|
3270
|
+
function useStore(api, selector) {
|
|
3271
|
+
if (selector === void 0) {
|
|
3272
|
+
selector = identity;
|
|
3273
|
+
}
|
|
3274
|
+
var slice = React__default.useSyncExternalStore(api.subscribe, function () {
|
|
3275
|
+
return selector(api.getState());
|
|
3276
|
+
}, function () {
|
|
3277
|
+
return selector(api.getInitialState());
|
|
3278
|
+
});
|
|
3279
|
+
React__default.useDebugValue(slice);
|
|
3280
|
+
return slice;
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
function listAvailableCameras(facingMode_1) {
|
|
3284
|
+
return __awaiter(this, arguments, void 0, function (facingMode, requestMicAccess) {
|
|
3285
|
+
var cameraEnumerationStream, videoDevices;
|
|
3286
|
+
if (requestMicAccess === void 0) {
|
|
3287
|
+
requestMicAccess = false;
|
|
3288
|
+
}
|
|
3289
|
+
return __generator(this, function (_a) {
|
|
3290
|
+
switch (_a.label) {
|
|
3291
|
+
case 0:
|
|
3292
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3293
|
+
video: {
|
|
3294
|
+
facingMode: {
|
|
3295
|
+
exact: facingMode
|
|
3296
|
+
}
|
|
3297
|
+
},
|
|
3298
|
+
audio: requestMicAccess
|
|
3299
|
+
})
|
|
3300
|
+
// This lists all available cameras attached to the user's device.
|
|
3301
|
+
];
|
|
3302
|
+
case 1:
|
|
3303
|
+
cameraEnumerationStream = _a.sent();
|
|
3304
|
+
return [4 /*yield*/, navigator.mediaDevices.enumerateDevices()];
|
|
3305
|
+
case 2:
|
|
3306
|
+
videoDevices = _a.sent().filter(function (_a) {
|
|
3307
|
+
var kind = _a.kind;
|
|
3308
|
+
return kind === 'videoinput';
|
|
3309
|
+
});
|
|
3310
|
+
// Release the access to the user's camera that we obtained for enumeration purposes.
|
|
3311
|
+
cameraEnumerationStream.getVideoTracks().forEach(function (track) {
|
|
3312
|
+
track.enabled = false;
|
|
3313
|
+
track.stop();
|
|
3314
|
+
});
|
|
3315
|
+
cameraEnumerationStream = null;
|
|
3316
|
+
return [2 /*return*/, videoDevices];
|
|
3317
|
+
}
|
|
3318
|
+
});
|
|
3319
|
+
});
|
|
3320
|
+
}
|
|
3321
|
+
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) {
|
|
3322
|
+
return s.toLocaleLowerCase().split(' ').join('');
|
|
3323
|
+
});
|
|
3324
|
+
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) {
|
|
3325
|
+
return s.toLocaleLowerCase().split(' ').join('');
|
|
3326
|
+
});
|
|
3327
|
+
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) {
|
|
3328
|
+
return s.toLocaleLowerCase().split(' ').join('');
|
|
3329
|
+
});
|
|
3330
|
+
var cameraLabelMatches = function cameraLabelMatches(labelOrDevice, labelSetOrLabel) {
|
|
3331
|
+
var label = labelOrDevice instanceof MediaDeviceInfo ? getDeviceLabel(labelOrDevice) : labelOrDevice;
|
|
3332
|
+
var labelSet = typeof labelSetOrLabel === 'string' ? [labelSetOrLabel] : labelSetOrLabel;
|
|
3333
|
+
return labelSet.some(function (l) {
|
|
3334
|
+
return label.includes(l);
|
|
3335
|
+
});
|
|
3336
|
+
};
|
|
3337
|
+
var getDeviceLabel = function getDeviceLabel(deviceInfo) {
|
|
3338
|
+
return deviceInfo.label.toLocaleLowerCase().split(' ').join('');
|
|
3339
|
+
};
|
|
3340
|
+
var currentCamera;
|
|
3341
|
+
function obtainCameraAccess(stream, deviceLabel, video) {
|
|
3342
|
+
releaseCameraAccess();
|
|
3343
|
+
log('obtaining camera access...');
|
|
3344
|
+
var _a = stream.getVideoTracks()[0].getSettings(),
|
|
3345
|
+
width = _a.width,
|
|
3346
|
+
height = _a.height;
|
|
3347
|
+
log('camera dimensions', width, height);
|
|
3348
|
+
var label = deviceLabel.toLocaleLowerCase().split(' ').join('');
|
|
3349
|
+
log('camera label', label);
|
|
3350
|
+
var isRearFacing = cameraLabelMatches(label, __spreadArray(__spreadArray(__spreadArray([], rearCameraLabels, true), backUltraWideCameraLabels, true), ['iphone'], false));
|
|
3351
|
+
log('is rear facing?', isRearFacing);
|
|
3352
|
+
var release = function release() {
|
|
3353
|
+
stream.getTracks().forEach(function (track) {
|
|
3354
|
+
track.enabled = false;
|
|
3355
|
+
track.stop();
|
|
3356
|
+
});
|
|
3357
|
+
if (video) {
|
|
3358
|
+
video.pause();
|
|
3359
|
+
video.srcObject = null;
|
|
3360
|
+
video.src = '';
|
|
3361
|
+
}
|
|
3362
|
+
};
|
|
3363
|
+
width || (width = 0);
|
|
3364
|
+
height || (height = 0);
|
|
3365
|
+
currentCamera = {
|
|
3366
|
+
label: deviceLabel,
|
|
3367
|
+
stream: stream,
|
|
3368
|
+
width: width,
|
|
3369
|
+
height: height,
|
|
3370
|
+
isRearFacing: isRearFacing,
|
|
3371
|
+
release: release
|
|
3372
|
+
};
|
|
3373
|
+
log('camera access granted');
|
|
3374
|
+
if (video) video.srcObject = stream;
|
|
3375
|
+
log('video source initialized');
|
|
3376
|
+
return currentCamera;
|
|
3377
|
+
}
|
|
3378
|
+
function releaseCameraAccess() {
|
|
3379
|
+
if (!currentCamera) return;
|
|
3380
|
+
log('releasing camera access...');
|
|
3381
|
+
currentCamera.release();
|
|
3382
|
+
currentCamera = undefined;
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
var initialState$5 = {
|
|
3386
|
+
videoRef: {
|
|
3387
|
+
current: null
|
|
3388
|
+
},
|
|
3389
|
+
videoLoaded: false,
|
|
3390
|
+
videoStream: null,
|
|
3391
|
+
videoDevice: null,
|
|
3392
|
+
isRearFacing: false,
|
|
3393
|
+
camera: null,
|
|
3394
|
+
cameraReady: false,
|
|
3395
|
+
cameraAccessDenied: false,
|
|
3396
|
+
iphoneContinuityCameraAvailable: false,
|
|
3397
|
+
iphoneContinuityCameraDenied: false,
|
|
3398
|
+
preferIphoneContinuityCamera: true,
|
|
3399
|
+
audioStream: null,
|
|
3400
|
+
microphoneReady: false,
|
|
3401
|
+
microphoneAccessDenied: false
|
|
3402
|
+
};
|
|
3403
|
+
var createCameraStore = function createCameraStore(config) {
|
|
3404
|
+
var store = createStore(function (set, get) {
|
|
3405
|
+
return _assign(_assign(_assign({}, initialState$5), config), {
|
|
3406
|
+
reset: function reset() {
|
|
3407
|
+
return set(_assign(_assign({}, initialState$5), config));
|
|
3408
|
+
},
|
|
3409
|
+
setConfig: function setConfig(config) {
|
|
3410
|
+
return set(config);
|
|
3411
|
+
},
|
|
3412
|
+
onVideoMounted: function onVideoMounted() {
|
|
3413
|
+
return set({
|
|
3414
|
+
videoLoaded: true
|
|
3415
|
+
});
|
|
3416
|
+
},
|
|
3417
|
+
setIphoneContinuityCameraAllowed: function setIphoneContinuityCameraAllowed(value) {
|
|
3418
|
+
return set({
|
|
3419
|
+
preferIphoneContinuityCamera: value
|
|
3420
|
+
});
|
|
3421
|
+
},
|
|
3422
|
+
requestCameraAccess: function requestCameraAccess() {
|
|
3423
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3424
|
+
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;
|
|
3425
|
+
var _b, _c, _d;
|
|
3426
|
+
return __generator(this, function (_e) {
|
|
3427
|
+
switch (_e.label) {
|
|
3428
|
+
case 0:
|
|
3429
|
+
_a = get(), videoRef = _a.videoRef, releaseCameraAccess = _a.releaseCameraAccess, preferFrontFacingCamera = _a.preferFrontFacingCamera, preferIphoneContinuityCamera = _a.preferIphoneContinuityCamera, iphoneContinuityCameraDenied = _a.iphoneContinuityCameraDenied;
|
|
3430
|
+
releaseCameraAccess();
|
|
3431
|
+
_e.label = 1;
|
|
3432
|
+
case 1:
|
|
3433
|
+
_e.trys.push([1, 11,, 12]);
|
|
3434
|
+
return [4 /*yield*/, listAvailableCameras()];
|
|
3435
|
+
case 2:
|
|
3436
|
+
availableCameras = _e.sent();
|
|
3437
|
+
selectedCamera = void 0;
|
|
3438
|
+
debug('availableCameras', availableCameras);
|
|
3439
|
+
platform_1 = getPlatform();
|
|
3440
|
+
debug('platformDetails', platform_1);
|
|
3441
|
+
if (!iphoneContinuityCameraDenied && (!(platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) || platform_1.os.family === 'OS X')) {
|
|
3442
|
+
iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
|
|
3443
|
+
return cameraLabelMatches(deviceInfo, 'iphone');
|
|
3444
|
+
});
|
|
3445
|
+
set({
|
|
3446
|
+
iphoneContinuityCameraAvailable: !!iphoneContinuityCamera
|
|
3447
|
+
});
|
|
3448
|
+
if (iphoneContinuityCamera && preferIphoneContinuityCamera) {
|
|
3449
|
+
selectedCamera = iphoneContinuityCamera;
|
|
3450
|
+
}
|
|
3451
|
+
} 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) {
|
|
3452
|
+
return c.label.startsWith('camera2 ');
|
|
3453
|
+
})) {
|
|
3454
|
+
availableCameras = availableCameras.sort(function (a, b) {
|
|
3455
|
+
return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
|
|
3456
|
+
});
|
|
3457
|
+
debug('cameras have been sorted', availableCameras);
|
|
3458
|
+
}
|
|
3459
|
+
if (preferFrontFacingCamera) {
|
|
3460
|
+
selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3461
|
+
return cameraLabelMatches(deviceInfo, frontCameraLabels);
|
|
3462
|
+
});
|
|
3463
|
+
}
|
|
3464
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3465
|
+
return cameraLabelMatches(deviceInfo, 'backtriplecamera');
|
|
3466
|
+
}));
|
|
3467
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3468
|
+
return cameraLabelMatches(deviceInfo, 'backdualcamera');
|
|
3469
|
+
}));
|
|
3470
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3471
|
+
return cameraLabelMatches(deviceInfo, rearCameraLabels) && !cameraLabelMatches(deviceInfo, backUltraWideCameraLabels);
|
|
3472
|
+
}));
|
|
3473
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3474
|
+
return cameraLabelMatches(deviceInfo, rearCameraLabels);
|
|
3475
|
+
}));
|
|
3476
|
+
// on iOS, the front facing camera always is at the first position in the list, so we skip it if all else fails.
|
|
3477
|
+
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) {
|
|
3478
|
+
selectedCamera || (selectedCamera = availableCameras[1]);
|
|
3479
|
+
}
|
|
3480
|
+
selectedCamera || (selectedCamera = availableCameras[0]);
|
|
3481
|
+
debug('selectedCamera', selectedCamera);
|
|
3482
|
+
set({
|
|
3483
|
+
videoDevice: selectedCamera
|
|
3484
|
+
});
|
|
3485
|
+
constraints = {
|
|
3486
|
+
audio: false,
|
|
3487
|
+
video: {
|
|
3488
|
+
deviceId: {
|
|
3489
|
+
exact: selectedCamera.deviceId
|
|
3490
|
+
},
|
|
3491
|
+
width: {
|
|
3492
|
+
ideal: config.maxVideoWidth
|
|
3493
|
+
},
|
|
3494
|
+
aspectRatio: 1.777777778,
|
|
3495
|
+
frameRate: {}
|
|
3496
|
+
}
|
|
3497
|
+
};
|
|
3498
|
+
if (config.maxFps) {
|
|
3499
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3500
|
+
// @ts-ignore
|
|
3501
|
+
constraints.video.frameRate = {
|
|
3502
|
+
max: config.maxFps
|
|
3503
|
+
};
|
|
3504
|
+
}
|
|
3505
|
+
stream_1 = null;
|
|
3506
|
+
_e.label = 3;
|
|
3507
|
+
case 3:
|
|
3508
|
+
_e.trys.push([3, 5,, 6]);
|
|
3509
|
+
debug('obtaining camera access with constraints', constraints);
|
|
3510
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
|
|
3511
|
+
case 4:
|
|
3512
|
+
stream_1 = _e.sent();
|
|
3513
|
+
return [3 /*break*/, 6];
|
|
3514
|
+
case 5:
|
|
3515
|
+
e_1 = _e.sent();
|
|
3516
|
+
if (e_1.name === 'NotAllowedError') {
|
|
3517
|
+
if (preferIphoneContinuityCamera) {
|
|
3518
|
+
set({
|
|
3519
|
+
iphoneContinuityCameraAvailable: false,
|
|
3520
|
+
iphoneContinuityCameraDenied: true
|
|
3521
|
+
});
|
|
3522
|
+
} else {
|
|
3523
|
+
set({
|
|
3524
|
+
cameraAccessDenied: true
|
|
3525
|
+
});
|
|
3526
|
+
}
|
|
3527
|
+
return [2 /*return*/];
|
|
3528
|
+
}
|
|
3529
|
+
return [3 /*break*/, 6];
|
|
3530
|
+
case 6:
|
|
3531
|
+
if (!!stream_1) return [3 /*break*/, 10];
|
|
3532
|
+
_e.label = 7;
|
|
3533
|
+
case 7:
|
|
3534
|
+
_e.trys.push([7, 9,, 10]);
|
|
3535
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3536
|
+
audio: false,
|
|
3537
|
+
video: true
|
|
3538
|
+
})];
|
|
3539
|
+
case 8:
|
|
3540
|
+
stream_1 = _e.sent();
|
|
3541
|
+
debug('opened stream with no width and height constraints');
|
|
3542
|
+
return [3 /*break*/, 10];
|
|
3543
|
+
case 9:
|
|
3544
|
+
_e.sent();
|
|
3545
|
+
debug('cannot open stream at all');
|
|
3546
|
+
return [3 /*break*/, 10];
|
|
3547
|
+
case 10:
|
|
3548
|
+
if (!stream_1) {
|
|
3549
|
+
error('failed to open camera');
|
|
3550
|
+
throw new Error('failed to open camera');
|
|
3551
|
+
}
|
|
3552
|
+
debug('camera access granted with constraints', constraints);
|
|
3553
|
+
handleStreamEnded_1 = function handleStreamEnded_1() {
|
|
3554
|
+
if (preferIphoneContinuityCamera && get().iphoneContinuityCameraAvailable) {
|
|
3555
|
+
debug('someone unplugged the continuity camera');
|
|
3556
|
+
set({
|
|
3557
|
+
videoStream: null,
|
|
3558
|
+
videoDevice: null,
|
|
3559
|
+
cameraReady: false,
|
|
3560
|
+
iphoneContinuityCameraAvailable: false,
|
|
3561
|
+
iphoneContinuityCameraDenied: true
|
|
3562
|
+
});
|
|
3563
|
+
get().requestCameraAccess();
|
|
3564
|
+
} else {
|
|
3565
|
+
debug('someone unplugged the webcam');
|
|
3566
|
+
releaseCameraAccess();
|
|
3567
|
+
set({
|
|
3568
|
+
videoStream: null,
|
|
3569
|
+
videoDevice: null,
|
|
3570
|
+
videoLoaded: false,
|
|
3571
|
+
cameraReady: false,
|
|
3572
|
+
cameraAccessDenied: true
|
|
3573
|
+
});
|
|
3574
|
+
}
|
|
3575
|
+
};
|
|
3576
|
+
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', handleStreamEnded_1);
|
|
3577
|
+
videoTrack_1 = stream_1.getVideoTracks()[0];
|
|
3578
|
+
videoTrack_1.onended = handleStreamEnded_1;
|
|
3579
|
+
camera_1 = obtainCameraAccess(stream_1, selectedCamera.label, videoRef.current);
|
|
3580
|
+
setTimeout(function () {
|
|
3581
|
+
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
3582
|
+
// when the camera access is being requested. This delay is a workaround for that.
|
|
3583
|
+
videoTrack_1.onmute = handleStreamEnded_1;
|
|
3584
|
+
set({
|
|
3585
|
+
camera: camera_1,
|
|
3586
|
+
cameraReady: true,
|
|
3587
|
+
cameraAccessDenied: false,
|
|
3588
|
+
isRearFacing: camera_1.isRearFacing,
|
|
3589
|
+
videoStream: stream_1
|
|
3590
|
+
});
|
|
3591
|
+
}, 500);
|
|
3592
|
+
return [3 /*break*/, 12];
|
|
3593
|
+
case 11:
|
|
3594
|
+
e_3 = _e.sent();
|
|
3595
|
+
if (e_3.name === 'NotAllowedError') {
|
|
3596
|
+
error('camera access has been blocked by the user', e_3);
|
|
3597
|
+
set({
|
|
3598
|
+
cameraAccessDenied: true
|
|
3599
|
+
});
|
|
3600
|
+
} else {
|
|
3601
|
+
error('camera access encountered some other error', e_3);
|
|
3602
|
+
throw e_3;
|
|
3603
|
+
}
|
|
3604
|
+
return [3 /*break*/, 12];
|
|
3605
|
+
case 12:
|
|
3606
|
+
return [2 /*return*/];
|
|
3607
|
+
}
|
|
3608
|
+
});
|
|
3609
|
+
});
|
|
3610
|
+
},
|
|
3611
|
+
releaseCameraAccess: function releaseCameraAccess() {
|
|
3612
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3613
|
+
var camera;
|
|
3614
|
+
return __generator(this, function (_a) {
|
|
3615
|
+
camera = get().camera;
|
|
3616
|
+
if (!camera) return [2 /*return*/];
|
|
3617
|
+
camera.release();
|
|
3618
|
+
set({
|
|
3619
|
+
camera: null,
|
|
3620
|
+
cameraReady: false,
|
|
3621
|
+
cameraAccessDenied: false
|
|
3622
|
+
});
|
|
3623
|
+
return [2 /*return*/];
|
|
3624
|
+
});
|
|
3625
|
+
});
|
|
3626
|
+
},
|
|
3627
|
+
requestMicrophoneAccess: function requestMicrophoneAccess() {
|
|
3628
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3629
|
+
var stream_2;
|
|
3630
|
+
return __generator(this, function (_a) {
|
|
3631
|
+
switch (_a.label) {
|
|
3632
|
+
case 0:
|
|
3633
|
+
get().releaseMicrophoneAccess();
|
|
3634
|
+
_a.label = 1;
|
|
3635
|
+
case 1:
|
|
3636
|
+
_a.trys.push([1, 3,, 4]);
|
|
3637
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3638
|
+
audio: true,
|
|
3639
|
+
video: false
|
|
3640
|
+
})
|
|
3641
|
+
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
3642
|
+
// when the camera access is being requested. This delay is a workaround for that.
|
|
3643
|
+
];
|
|
3644
|
+
case 2:
|
|
3645
|
+
stream_2 = _a.sent();
|
|
3646
|
+
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
3647
|
+
// when the camera access is being requested. This delay is a workaround for that.
|
|
3648
|
+
setTimeout(function () {
|
|
3649
|
+
set({
|
|
3650
|
+
audioStream: stream_2,
|
|
3651
|
+
microphoneReady: true,
|
|
3652
|
+
microphoneAccessDenied: false
|
|
3653
|
+
});
|
|
3654
|
+
var track = stream_2.getAudioTracks()[0];
|
|
3655
|
+
track.onended = function () {
|
|
3656
|
+
return set({
|
|
3657
|
+
microphoneReady: false,
|
|
3658
|
+
microphoneAccessDenied: true
|
|
3659
|
+
});
|
|
3660
|
+
};
|
|
3661
|
+
track.onmute = function () {
|
|
3662
|
+
return set({
|
|
3663
|
+
microphoneReady: false,
|
|
3664
|
+
microphoneAccessDenied: true
|
|
3665
|
+
});
|
|
3666
|
+
};
|
|
3667
|
+
}, 500);
|
|
3668
|
+
return [3 /*break*/, 4];
|
|
3669
|
+
case 3:
|
|
3670
|
+
_a.sent();
|
|
3671
|
+
set({
|
|
3672
|
+
microphoneAccessDenied: true
|
|
3673
|
+
});
|
|
3674
|
+
return [3 /*break*/, 4];
|
|
3675
|
+
case 4:
|
|
3676
|
+
return [2 /*return*/];
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3679
|
+
});
|
|
3680
|
+
},
|
|
3681
|
+
releaseMicrophoneAccess: function releaseMicrophoneAccess() {
|
|
3682
|
+
var _a;
|
|
3683
|
+
var audioStream = get().audioStream;
|
|
3684
|
+
(_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
|
|
3685
|
+
audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks().forEach(function (track) {
|
|
3686
|
+
var _a;
|
|
3687
|
+
(_a = track.stop) === null || _a === void 0 ? void 0 : _a.call(track);
|
|
3688
|
+
});
|
|
3689
|
+
set({
|
|
3690
|
+
audioStream: null,
|
|
3691
|
+
microphoneReady: false,
|
|
3692
|
+
microphoneAccessDenied: false
|
|
3693
|
+
});
|
|
3694
|
+
}
|
|
3695
|
+
});
|
|
3696
|
+
});
|
|
3697
|
+
if (config.requestAccessAutomatically) {
|
|
3698
|
+
void store.getState().requestCameraAccess();
|
|
3699
|
+
}
|
|
3700
|
+
return _assign(_assign({}, store), {
|
|
3701
|
+
destroy: function destroy() {
|
|
3702
|
+
store.getState().releaseCameraAccess();
|
|
3703
|
+
store.getState().releaseMicrophoneAccess();
|
|
3704
|
+
}
|
|
3705
|
+
});
|
|
3706
|
+
};
|
|
3707
|
+
var CameraStoreContext = /*#__PURE__*/createContext(undefined);
|
|
3708
|
+
function CameraStoreProvider(_a) {
|
|
3709
|
+
var children = _a.children,
|
|
3710
|
+
_b = _a.requestAccessAutomatically,
|
|
3711
|
+
requestAccessAutomatically = _b === void 0 ? true : _b,
|
|
3712
|
+
_c = _a.preferIphoneContinuityCamera,
|
|
3713
|
+
preferIphoneContinuityCamera = _c === void 0 ? true : _c,
|
|
3714
|
+
_d = _a.preferFrontFacingCamera,
|
|
3715
|
+
preferFrontFacingCamera = _d === void 0 ? false : _d,
|
|
3716
|
+
_e = _a.maxVideoWidth,
|
|
3717
|
+
maxVideoWidth = _e === void 0 ? 1920 : _e,
|
|
3718
|
+
maxFps = _a.maxFps,
|
|
3719
|
+
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
3720
|
+
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
|
|
3721
|
+
_f = _a.requireMicrophoneAccess,
|
|
3722
|
+
requireMicrophoneAccess = _f === void 0 ? false : _f;
|
|
3723
|
+
var videoRef = useRef(null);
|
|
3724
|
+
var store = useRef();
|
|
3725
|
+
store.current || (store.current = createCameraStore({
|
|
3726
|
+
videoRef: videoRef,
|
|
3727
|
+
requestAccessAutomatically: requestAccessAutomatically,
|
|
3728
|
+
preferIphoneContinuityCamera: preferIphoneContinuityCamera,
|
|
3729
|
+
preferFrontFacingCamera: preferFrontFacingCamera,
|
|
3730
|
+
maxVideoWidth: maxVideoWidth,
|
|
3731
|
+
maxFps: maxFps,
|
|
3732
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
3733
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
3734
|
+
requireMicrophoneAccess: requireMicrophoneAccess
|
|
3735
|
+
}));
|
|
3736
|
+
useEffect(function () {
|
|
3737
|
+
var _a, _b, _c;
|
|
3738
|
+
var state = (_a = store.current) === null || _a === void 0 ? void 0 : _a.getState();
|
|
3739
|
+
if (!state) return;
|
|
3740
|
+
if (preferIphoneContinuityCamera !== (state === null || state === void 0 ? void 0 : state.preferIphoneContinuityCamera) || preferFrontFacingCamera !== (state === null || state === void 0 ? void 0 : state.preferFrontFacingCamera)) {
|
|
3741
|
+
(_b = store.current) === null || _b === void 0 ? void 0 : _b.setState({
|
|
3742
|
+
preferIphoneContinuityCamera: preferIphoneContinuityCamera,
|
|
3743
|
+
preferFrontFacingCamera: preferFrontFacingCamera
|
|
3744
|
+
});
|
|
3745
|
+
(_c = store.current) === null || _c === void 0 ? void 0 : _c.getState().requestCameraAccess();
|
|
3746
|
+
}
|
|
3747
|
+
}, [preferFrontFacingCamera, preferIphoneContinuityCamera]);
|
|
3748
|
+
useEffect(function () {
|
|
3749
|
+
var _a;
|
|
3750
|
+
if (!requireMicrophoneAccess) return;
|
|
3751
|
+
(_a = store.current) === null || _a === void 0 ? void 0 : _a.getState().requestMicrophoneAccess();
|
|
3768
3752
|
return function () {
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
timer && clearTimeout(timer);
|
|
3753
|
+
var _a;
|
|
3754
|
+
return (_a = store.current) === null || _a === void 0 ? void 0 : _a.getState().releaseMicrophoneAccess();
|
|
3772
3755
|
};
|
|
3773
|
-
}, [
|
|
3774
|
-
|
|
3775
|
-
startedAtRef.current = new Date();
|
|
3776
|
-
setRunning(true);
|
|
3777
|
-
}, []);
|
|
3778
|
-
var stop = useCallback(function () {
|
|
3779
|
-
loopId.current += 1; // force the loop to stop immediately.
|
|
3780
|
-
setRunning(false);
|
|
3781
|
-
startedAtRef.current = null;
|
|
3782
|
-
}, []);
|
|
3783
|
-
useEffect(function startAutomatically() {
|
|
3784
|
-
if (autoStart) start();
|
|
3756
|
+
}, [requireMicrophoneAccess]);
|
|
3757
|
+
useEffect(function () {
|
|
3785
3758
|
return function () {
|
|
3786
|
-
|
|
3759
|
+
var _a;
|
|
3760
|
+
return (_a = store.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
3787
3761
|
};
|
|
3788
|
-
}, [
|
|
3789
|
-
return {
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3762
|
+
}, []);
|
|
3763
|
+
return /*#__PURE__*/React__default.createElement(CameraStoreContext.Provider, {
|
|
3764
|
+
value: store.current
|
|
3765
|
+
}, children);
|
|
3766
|
+
}
|
|
3767
|
+
function useCameraStore(selector) {
|
|
3768
|
+
var store = useContext(CameraStoreContext);
|
|
3769
|
+
if (!store) throw new Error('useCameraStore cannot be used without Provider');
|
|
3770
|
+
return useStore(store, selector);
|
|
3793
3771
|
}
|
|
3794
3772
|
|
|
3795
3773
|
var DocumentDetectionModelContext = /*#__PURE__*/createContext({
|
|
@@ -3837,7 +3815,7 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
3837
3815
|
_g = _a.documentDetectionModelLoadTimeoutMs,
|
|
3838
3816
|
documentDetectionModelLoadTimeoutMs = _g === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _g,
|
|
3839
3817
|
onDocumentDetectionModelError = _a.onDocumentDetectionModelError;
|
|
3840
|
-
var _h =
|
|
3818
|
+
var _h = useCameraStore(),
|
|
3841
3819
|
videoRef = _h.videoRef,
|
|
3842
3820
|
videoLoaded = _h.videoLoaded,
|
|
3843
3821
|
cameraReady = _h.cameraReady;
|
|
@@ -3860,7 +3838,8 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
3860
3838
|
modelPath: documentDetectionModelPath,
|
|
3861
3839
|
modelLoadTimeoutMs: documentDetectionModelLoadTimeoutMs,
|
|
3862
3840
|
scoreThreshold: documentDetectionModelScoreThreshold,
|
|
3863
|
-
onModelError: onDocumentDetectionModelError
|
|
3841
|
+
onModelError: onDocumentDetectionModelError,
|
|
3842
|
+
videoRef: videoRef
|
|
3864
3843
|
}),
|
|
3865
3844
|
ready = _o.ready,
|
|
3866
3845
|
modelDownloadProgress = _o.modelDownloadProgress,
|
|
@@ -3977,10 +3956,12 @@ function FocusModelProvider(_a) {
|
|
|
3977
3956
|
var _e = useState({}),
|
|
3978
3957
|
focusThresholds = _e[0],
|
|
3979
3958
|
setFocusThresholds = _e[1];
|
|
3959
|
+
var videoRef = useCameraStore().videoRef;
|
|
3980
3960
|
var _f = useLoadFocusModel({
|
|
3981
3961
|
modelPath: focusModelPath,
|
|
3982
3962
|
modelLoadTimeoutMs: focusModelLoadTimeoutMs,
|
|
3983
|
-
onModelError: onFocusModelError
|
|
3963
|
+
onModelError: onFocusModelError,
|
|
3964
|
+
videoRef: videoRef
|
|
3984
3965
|
}),
|
|
3985
3966
|
ready = _f.ready,
|
|
3986
3967
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
@@ -5102,31 +5083,33 @@ var Button = styled(LoaderButton)(templateObject_5$b || (templateObject_5$b = __
|
|
|
5102
5083
|
var templateObject_1$D, templateObject_2$w, templateObject_3$o, templateObject_4$i, templateObject_5$b;
|
|
5103
5084
|
|
|
5104
5085
|
var IdCapture = function IdCapture(_a) {
|
|
5105
|
-
var _b, _c, _d, _e, _f, _g, _h
|
|
5086
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
5106
5087
|
var requiredDocumentType = _a.requiredDocumentType,
|
|
5107
|
-
|
|
5108
|
-
thresholds =
|
|
5088
|
+
_j = _a.thresholds,
|
|
5089
|
+
thresholds = _j === void 0 ? defaultIdCaptureThresholds : _j,
|
|
5109
5090
|
guidanceMessage = _a.guidanceMessage,
|
|
5110
5091
|
guidanceSatisfied = _a.guidanceSatisfied,
|
|
5111
5092
|
onCapture = _a.onCapture,
|
|
5112
|
-
|
|
5113
|
-
classNames =
|
|
5114
|
-
|
|
5115
|
-
colors =
|
|
5116
|
-
|
|
5117
|
-
rawVerbiage =
|
|
5118
|
-
|
|
5119
|
-
debugMode =
|
|
5120
|
-
var
|
|
5121
|
-
ref =
|
|
5122
|
-
|
|
5123
|
-
width =
|
|
5124
|
-
|
|
5125
|
-
height =
|
|
5126
|
-
var
|
|
5127
|
-
state =
|
|
5128
|
-
dispatch =
|
|
5129
|
-
var
|
|
5093
|
+
_k = _a.classNames,
|
|
5094
|
+
classNames = _k === void 0 ? {} : _k,
|
|
5095
|
+
_l = _a.colors,
|
|
5096
|
+
colors = _l === void 0 ? {} : _l,
|
|
5097
|
+
_m = _a.verbiage,
|
|
5098
|
+
rawVerbiage = _m === void 0 ? {} : _m,
|
|
5099
|
+
_o = _a.debugMode,
|
|
5100
|
+
debugMode = _o === void 0 ? false : _o;
|
|
5101
|
+
var _p = useResizeObserver(),
|
|
5102
|
+
ref = _p.ref,
|
|
5103
|
+
_q = _p.width,
|
|
5104
|
+
width = _q === void 0 ? 1 : _q,
|
|
5105
|
+
_r = _p.height,
|
|
5106
|
+
height = _r === void 0 ? 1 : _r;
|
|
5107
|
+
var _s = useIdCaptureState(),
|
|
5108
|
+
state = _s[0],
|
|
5109
|
+
dispatch = _s[1];
|
|
5110
|
+
var _t = useCameraStore(),
|
|
5111
|
+
camera = _t.camera,
|
|
5112
|
+
isRearFacing = _t.isRearFacing;
|
|
5130
5113
|
var _u = useContext(IdCaptureModelsContext),
|
|
5131
5114
|
modelsReady = _u.ready,
|
|
5132
5115
|
setThresholds = _u.setThresholds,
|
|
@@ -5238,17 +5221,16 @@ var IdCapture = function IdCapture(_a) {
|
|
|
5238
5221
|
classNames: classNames.overrideWrongDocumentTypeGuidanceDialog,
|
|
5239
5222
|
verbiage: rawVerbiage.overrideWrongDocumentTypeGuidanceDialog
|
|
5240
5223
|
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugBoundingBoxOverlay, {
|
|
5241
|
-
"$flipX": !
|
|
5224
|
+
"$flipX": !isRearFacing,
|
|
5242
5225
|
scaling: debugScalingDetails
|
|
5243
5226
|
}, state.detectedObjects.map(function (obj, i) {
|
|
5244
|
-
var _a;
|
|
5245
5227
|
return /*#__PURE__*/React__default.createElement(IdCaptureDetectedObjectDebugBox, {
|
|
5246
5228
|
key: i,
|
|
5247
5229
|
obj: obj,
|
|
5248
5230
|
scaling: debugScalingDetails,
|
|
5249
|
-
flipX: !
|
|
5231
|
+
flipX: !isRearFacing
|
|
5250
5232
|
});
|
|
5251
|
-
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null,
|
|
5233
|
+
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__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__default.createElement("br", null), modelsReady ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React__default.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React__default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__default.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React__default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u274C Models not ready")))));
|
|
5252
5234
|
};
|
|
5253
5235
|
var timeSince = function timeSince(t) {
|
|
5254
5236
|
if (!t) return 0;
|
|
@@ -5265,7 +5247,9 @@ var CameraAccessDeniedOverlay = function CameraAccessDeniedOverlay(_a) {
|
|
|
5265
5247
|
colors = _e === void 0 ? {} : _e,
|
|
5266
5248
|
_f = _a.verbiage,
|
|
5267
5249
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
5268
|
-
var requestCameraAccess =
|
|
5250
|
+
var requestCameraAccess = useCameraStore(function (state) {
|
|
5251
|
+
return state.requestCameraAccess;
|
|
5252
|
+
});
|
|
5269
5253
|
assets.imageUrl || (assets.imageUrl = DEFAULT_CDN_URL + '/camera-disable-icon.png');
|
|
5270
5254
|
var verbiage = useTranslations(rawVerbiage, {
|
|
5271
5255
|
headingText: 'Your camera permission is disabled',
|
|
@@ -5913,7 +5897,7 @@ var IdCaptureLoadingOverlayDefault = function IdCaptureLoadingOverlayDefault(_a)
|
|
|
5913
5897
|
var _o = useContext(IdCaptureModelsContext),
|
|
5914
5898
|
modelsReady = _o.ready,
|
|
5915
5899
|
modelDownloadProgress = _o.modelDownloadProgress;
|
|
5916
|
-
var _p =
|
|
5900
|
+
var _p = useCameraStore(),
|
|
5917
5901
|
cameraReady = _p.cameraReady,
|
|
5918
5902
|
cameraAccessDenied = _p.cameraAccessDenied,
|
|
5919
5903
|
iphoneContinuityCameraAvailable = _p.iphoneContinuityCameraAvailable,
|
|
@@ -6091,6 +6075,71 @@ var ContinueButton$1 = styled(LoaderButton)(templateObject_18 || (templateObject
|
|
|
6091
6075
|
});
|
|
6092
6076
|
var templateObject_1$y, templateObject_2$t, templateObject_3$l, templateObject_4$f, templateObject_5$a, templateObject_6$8, templateObject_7$5, templateObject_8$2, templateObject_9$2, templateObject_10$1, templateObject_11$1, templateObject_12$1, templateObject_13$1, templateObject_14$1, templateObject_15$1, templateObject_16, templateObject_17, templateObject_18;
|
|
6093
6077
|
|
|
6078
|
+
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6079
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
6080
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
6081
|
+
var isIterable = function isIterable(obj) {
|
|
6082
|
+
return Symbol.iterator in obj;
|
|
6083
|
+
};
|
|
6084
|
+
var compareMapLike = function compareMapLike(iterableA, iterableB) {
|
|
6085
|
+
var mapA = iterableA instanceof Map ? iterableA : new Map(iterableA);
|
|
6086
|
+
var mapB = iterableB instanceof Map ? iterableB : new Map(iterableB);
|
|
6087
|
+
if (mapA.size !== mapB.size) return false;
|
|
6088
|
+
for (var _iterator = _createForOfIteratorHelperLoose(mapA), _step; !(_step = _iterator()).done;) {
|
|
6089
|
+
var _step$value = _step.value,
|
|
6090
|
+
key = _step$value[0],
|
|
6091
|
+
value = _step$value[1];
|
|
6092
|
+
if (!Object.is(value, mapB.get(key))) {
|
|
6093
|
+
return false;
|
|
6094
|
+
}
|
|
6095
|
+
}
|
|
6096
|
+
return true;
|
|
6097
|
+
};
|
|
6098
|
+
function shallow(objA, objB) {
|
|
6099
|
+
if (Object.is(objA, objB)) {
|
|
6100
|
+
return true;
|
|
6101
|
+
}
|
|
6102
|
+
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
6103
|
+
return false;
|
|
6104
|
+
}
|
|
6105
|
+
if (isIterable(objA) && isIterable(objB)) {
|
|
6106
|
+
var iteratorA = objA[Symbol.iterator]();
|
|
6107
|
+
var iteratorB = objB[Symbol.iterator]();
|
|
6108
|
+
var nextA = iteratorA.next();
|
|
6109
|
+
var nextB = iteratorB.next();
|
|
6110
|
+
if (Array.isArray(nextA.value) && Array.isArray(nextB.value) && nextA.value.length === 2 && nextB.value.length === 2) {
|
|
6111
|
+
return compareMapLike(objA, objB);
|
|
6112
|
+
}
|
|
6113
|
+
while (!nextA.done && !nextB.done) {
|
|
6114
|
+
if (!Object.is(nextA.value, nextB.value)) {
|
|
6115
|
+
return false;
|
|
6116
|
+
}
|
|
6117
|
+
nextA = iteratorA.next();
|
|
6118
|
+
nextB = iteratorB.next();
|
|
6119
|
+
}
|
|
6120
|
+
return !!nextA.done && !!nextB.done;
|
|
6121
|
+
}
|
|
6122
|
+
var keysA = Object.keys(objA);
|
|
6123
|
+
if (keysA.length !== Object.keys(objB).length) {
|
|
6124
|
+
return false;
|
|
6125
|
+
}
|
|
6126
|
+
for (var _i = 0, _keysA = keysA; _i < _keysA.length; _i++) {
|
|
6127
|
+
var keyA = _keysA[_i];
|
|
6128
|
+
if (!Object.hasOwn(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {
|
|
6129
|
+
return false;
|
|
6130
|
+
}
|
|
6131
|
+
}
|
|
6132
|
+
return true;
|
|
6133
|
+
}
|
|
6134
|
+
|
|
6135
|
+
function useShallow(selector) {
|
|
6136
|
+
var prev = React__default.useRef();
|
|
6137
|
+
return function (state) {
|
|
6138
|
+
var next = selector(state);
|
|
6139
|
+
return shallow(prev.current, next) ? prev.current : prev.current = next;
|
|
6140
|
+
};
|
|
6141
|
+
}
|
|
6142
|
+
|
|
6094
6143
|
var ContinuityCameraCheckboxContainer = styled.div(templateObject_1$x || (templateObject_1$x = __makeTemplateObject(["\n margin-top: 15px;\n margin-bottom: 15px;\n"], ["\n margin-top: 15px;\n margin-bottom: 15px;\n"])));
|
|
6095
6144
|
var ContinuityCameraCheckbox = styled.input(templateObject_2$s || (templateObject_2$s = __makeTemplateObject(["\n margin-right: 8px;\n"], ["\n margin-right: 8px;\n"])));
|
|
6096
6145
|
var IdCaptureLoadingOverlayLegacy = function IdCaptureLoadingOverlayLegacy(_a) {
|
|
@@ -6111,7 +6160,14 @@ var IdCaptureLoadingOverlayLegacy = function IdCaptureLoadingOverlayLegacy(_a) {
|
|
|
6111
6160
|
var _l = useContext(IdCaptureModelsContext),
|
|
6112
6161
|
modelsReady = _l.ready,
|
|
6113
6162
|
modelDownloadProgress = _l.modelDownloadProgress;
|
|
6114
|
-
var _m =
|
|
6163
|
+
var _m = useCameraStore(useShallow(function (state) {
|
|
6164
|
+
return {
|
|
6165
|
+
cameraReady: state.cameraReady,
|
|
6166
|
+
cameraAccessDenied: state.cameraAccessDenied,
|
|
6167
|
+
iphoneContinuityCameraAvailable: state.iphoneContinuityCameraAvailable,
|
|
6168
|
+
setIphoneContinuityCameraAllowed: state.setIphoneContinuityCameraAllowed
|
|
6169
|
+
};
|
|
6170
|
+
})),
|
|
6115
6171
|
cameraReady = _m.cameraReady,
|
|
6116
6172
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
6117
6173
|
iphoneContinuityCameraAvailable = _m.iphoneContinuityCameraAvailable,
|
|
@@ -6657,23 +6713,24 @@ function getOrientation(allowPortraitOnMobile) {
|
|
|
6657
6713
|
}
|
|
6658
6714
|
|
|
6659
6715
|
var IdVideoCaptureFlipIdPrompt = function IdVideoCaptureFlipIdPrompt(_a) {
|
|
6660
|
-
var _b
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
classNames = _d === void 0 ? {} : _d,
|
|
6716
|
+
var _b = _a.idCaptureGuideImages,
|
|
6717
|
+
idCaptureGuideImages = _b === void 0 ? defaultIdCaptureGuideImages : _b,
|
|
6718
|
+
_c = _a.classNames,
|
|
6719
|
+
classNames = _c === void 0 ? {} : _c,
|
|
6665
6720
|
borderWidth = _a.borderWidth,
|
|
6666
6721
|
borderColor = _a.borderColor,
|
|
6667
6722
|
borderRadius = _a.borderRadius,
|
|
6668
6723
|
imageStyle = _a.imageStyle;
|
|
6669
|
-
var
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6724
|
+
var isRearFacing = useCameraStore(function (state) {
|
|
6725
|
+
return state.isRearFacing;
|
|
6726
|
+
});
|
|
6727
|
+
var isMirrored = !isRearFacing;
|
|
6728
|
+
var _d = useState(1),
|
|
6729
|
+
transitionTime = _d[0],
|
|
6730
|
+
setTransitionTime = _d[1];
|
|
6731
|
+
var _e = useState(0),
|
|
6732
|
+
rotationAngle = _e[0],
|
|
6733
|
+
setRotationAngle = _e[1];
|
|
6677
6734
|
var frontTransforms = ["rotateY(".concat(rotationAngle, "deg)")];
|
|
6678
6735
|
if (isMirrored) frontTransforms.push('scaleX(-1)');
|
|
6679
6736
|
var backTransforms = ["rotateY(".concat(180 - rotationAngle, "deg)")];
|
|
@@ -7197,29 +7254,30 @@ var Canvas$1 = styled.canvas(templateObject_2$n || (templateObject_2$n = __makeT
|
|
|
7197
7254
|
var templateObject_1$r, templateObject_2$n;
|
|
7198
7255
|
|
|
7199
7256
|
function IdCaptureGuides(_a) {
|
|
7200
|
-
var _b,
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
rawVerbiage = _o === void 0 ? {} : _o;
|
|
7257
|
+
var _b = _a.guideType,
|
|
7258
|
+
guideType = _b === void 0 ? 'fit' : _b,
|
|
7259
|
+
_c = _a.status,
|
|
7260
|
+
status = _c === void 0 ? 'ready' : _c,
|
|
7261
|
+
_d = _a.progress,
|
|
7262
|
+
progress = _d === void 0 ? 0 : _d,
|
|
7263
|
+
_e = _a.portraitGuidesOnMobile,
|
|
7264
|
+
portraitGuidesOnMobile = _e === void 0 ? true : _e,
|
|
7265
|
+
_f = _a.requestedAction,
|
|
7266
|
+
requestedAction = _f === void 0 ? 'SHOW_ID_FRONT' : _f,
|
|
7267
|
+
_g = _a.isBackToFront,
|
|
7268
|
+
isBackToFront = _g === void 0 ? false : _g,
|
|
7269
|
+
_h = _a.images,
|
|
7270
|
+
images = _h === void 0 ? defaultIdCaptureGuideImages : _h,
|
|
7271
|
+
_j = _a.classNames,
|
|
7272
|
+
classNames = _j === void 0 ? {} : _j,
|
|
7273
|
+
_k = _a.colors,
|
|
7274
|
+
colors = _k === void 0 ? {} : _k,
|
|
7275
|
+
_l = _a.verbiage,
|
|
7276
|
+
rawVerbiage = _l === void 0 ? {} : _l;
|
|
7221
7277
|
var state = useIdCaptureState()[0];
|
|
7222
|
-
var
|
|
7278
|
+
var isRearFacing = useCameraStore(function (state) {
|
|
7279
|
+
return state.isRearFacing;
|
|
7280
|
+
});
|
|
7223
7281
|
var verbiage = useTranslations(rawVerbiage, {
|
|
7224
7282
|
instructionText: 'Scan the front of ID',
|
|
7225
7283
|
capturingText: 'Capturing...',
|
|
@@ -7231,7 +7289,7 @@ function IdCaptureGuides(_a) {
|
|
|
7231
7289
|
status: status,
|
|
7232
7290
|
progress: progress,
|
|
7233
7291
|
instruction: state.captureFailed ? verbiage.captureFailedText : state.capturing ? verbiage === null || verbiage === void 0 ? void 0 : verbiage.capturingText : verbiage.instructionText,
|
|
7234
|
-
isMirrored: !
|
|
7292
|
+
isMirrored: !isRearFacing,
|
|
7235
7293
|
borderColor: state.isGoodFrame ? colors.guideBoxSatisfiedColor : colors.guideBoxUnsatisfiedColor,
|
|
7236
7294
|
imageVisible: requestedAction === 'FLIP_ID' || !state.idCardFrontDetectionThresholdMet || !state.documentInBounds || state.documentTooClose
|
|
7237
7295
|
})), guideType === 'fit' && ( /*#__PURE__*/React__default.createElement(IdCaptureFitGuide, {
|
|
@@ -7241,7 +7299,7 @@ function IdCaptureGuides(_a) {
|
|
|
7241
7299
|
status: status,
|
|
7242
7300
|
progress: progress,
|
|
7243
7301
|
instruction: state.captureFailed ? verbiage.captureFailedText : state.capturing ? verbiage === null || verbiage === void 0 ? void 0 : verbiage.capturingText : verbiage.instructionText,
|
|
7244
|
-
isMirrored: !
|
|
7302
|
+
isMirrored: !isRearFacing,
|
|
7245
7303
|
isBackToFront: isBackToFront,
|
|
7246
7304
|
portraitGuidesOnMobile: portraitGuidesOnMobile,
|
|
7247
7305
|
borderColor: state.isGoodFrame ? colors.guideBoxSatisfiedColor : colors.guideBoxUnsatisfiedColor,
|
|
@@ -7340,48 +7398,6 @@ var ImagePreviewText = styled.div(templateObject_3$h || (templateObject_3$h = __
|
|
|
7340
7398
|
var ImagePreviewImageWrapper = styled.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"])));
|
|
7341
7399
|
var templateObject_1$q, templateObject_2$m, templateObject_3$h, templateObject_4$b;
|
|
7342
7400
|
|
|
7343
|
-
var CameraVideoTag = function CameraVideoTag(_a) {
|
|
7344
|
-
var _b;
|
|
7345
|
-
var className = _a.className;
|
|
7346
|
-
var _c = useContext(CameraStateContext),
|
|
7347
|
-
videoRef = _c.videoRef,
|
|
7348
|
-
setVideoLoaded = _c.setVideoLoaded,
|
|
7349
|
-
onVideoUnmounted = _c.onVideoUnmounted,
|
|
7350
|
-
cameraRef = _c.cameraRef;
|
|
7351
|
-
useEffect(function notifyCameraProviderOfUnmount() {
|
|
7352
|
-
var videoElement = videoRef.current;
|
|
7353
|
-
if (!videoElement) return;
|
|
7354
|
-
return function () {
|
|
7355
|
-
onVideoUnmounted(videoElement);
|
|
7356
|
-
};
|
|
7357
|
-
}, [onVideoUnmounted, videoRef]);
|
|
7358
|
-
useEffect(function setVideoLoadedToFalseOnMount() {
|
|
7359
|
-
setVideoLoaded(false);
|
|
7360
|
-
}, [setVideoLoaded]);
|
|
7361
|
-
useEffect(function attachCameraStreamToVideoTagWhenReady() {
|
|
7362
|
-
var _a;
|
|
7363
|
-
if (videoRef.current && ((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.stream)) {
|
|
7364
|
-
videoRef.current.srcObject = cameraRef.current.stream;
|
|
7365
|
-
}
|
|
7366
|
-
}, [cameraRef, videoRef]);
|
|
7367
|
-
var onLoadedData = useCallback(function () {
|
|
7368
|
-
setVideoLoaded(true);
|
|
7369
|
-
}, [setVideoLoaded]);
|
|
7370
|
-
return /*#__PURE__*/React__default.createElement(FullscreenVideoTag, {
|
|
7371
|
-
className: className,
|
|
7372
|
-
autoPlay: true,
|
|
7373
|
-
playsInline: true,
|
|
7374
|
-
muted: true,
|
|
7375
|
-
ref: videoRef,
|
|
7376
|
-
onLoadedData: onLoadedData,
|
|
7377
|
-
"$isRearFacing": (_b = cameraRef.current) === null || _b === void 0 ? void 0 : _b.isRearFacing
|
|
7378
|
-
});
|
|
7379
|
-
};
|
|
7380
|
-
var FullscreenVideoTag = styled.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) {
|
|
7381
|
-
return props.$isRearFacing ? '' : 'scaleX(-1)';
|
|
7382
|
-
});
|
|
7383
|
-
var templateObject_1$p;
|
|
7384
|
-
|
|
7385
7401
|
var documentCaptureInitialState = {
|
|
7386
7402
|
documents: [],
|
|
7387
7403
|
currentDocumentIndex: 0,
|
|
@@ -7500,8 +7516,8 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7500
7516
|
var _c = useReducer(documentCaptureStateReducer, documentCaptureInitialState),
|
|
7501
7517
|
state = _c[0],
|
|
7502
7518
|
dispatch = _c[1];
|
|
7503
|
-
var _d =
|
|
7504
|
-
|
|
7519
|
+
var _d = useCameraStore(),
|
|
7520
|
+
videoStream = _d.videoStream,
|
|
7505
7521
|
videoRef = _d.videoRef;
|
|
7506
7522
|
var uploadDocument = useContext(SubmissionContext).uploadDocument;
|
|
7507
7523
|
var uploadCapturedDocument = useCallback(function (content, filetype) {
|
|
@@ -7592,8 +7608,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7592
7608
|
}, [onResize]);
|
|
7593
7609
|
var videoTag = videoRef.current;
|
|
7594
7610
|
useEffect(function () {
|
|
7595
|
-
if (!state.capturing) return;
|
|
7596
|
-
if (!cameraRef.current) return;
|
|
7611
|
+
if (!state.capturing || !(videoStream === null || videoStream === void 0 ? void 0 : videoStream.active)) return;
|
|
7597
7612
|
function onComplete(content) {
|
|
7598
7613
|
if (!content) return;
|
|
7599
7614
|
var contentUrl = URL.createObjectURL(content);
|
|
@@ -7606,7 +7621,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7606
7621
|
});
|
|
7607
7622
|
}
|
|
7608
7623
|
if (typeof ImageCapture !== 'undefined') {
|
|
7609
|
-
var tracks =
|
|
7624
|
+
var tracks = videoStream.getTracks();
|
|
7610
7625
|
var videoCameraTrack = tracks.find(function (track) {
|
|
7611
7626
|
return track.kind === 'video';
|
|
7612
7627
|
});
|
|
@@ -7621,7 +7636,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7621
7636
|
drawToCanvas(canvas, videoTag);
|
|
7622
7637
|
canvas.toBlob(onComplete);
|
|
7623
7638
|
}
|
|
7624
|
-
}, [
|
|
7639
|
+
}, [state.capturing, videoStream, videoTag]);
|
|
7625
7640
|
var stateWithActions = useMemo(function () {
|
|
7626
7641
|
return _assign(_assign({}, state), {
|
|
7627
7642
|
uploadCapturedDocument: uploadCapturedDocument
|
|
@@ -7736,52 +7751,85 @@ var DocumentCaptureGuideOverlay = function DocumentCaptureGuideOverlay(_a) {
|
|
|
7736
7751
|
ref: canvasRef
|
|
7737
7752
|
}));
|
|
7738
7753
|
};
|
|
7739
|
-
var CanvasWrapper = styled.div(templateObject_1$
|
|
7754
|
+
var CanvasWrapper = styled.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) {
|
|
7740
7755
|
return props.$maskColor;
|
|
7741
7756
|
});
|
|
7742
7757
|
var Canvas = styled.canvas(templateObject_2$l || (templateObject_2$l = __makeTemplateObject(["\n display: block;\n"], ["\n display: block;\n"])));
|
|
7743
|
-
var templateObject_1$
|
|
7758
|
+
var templateObject_1$p, templateObject_2$l;
|
|
7744
7759
|
|
|
7745
|
-
var CameraFeedWrapper = styled.div(templateObject_1$
|
|
7760
|
+
var CameraFeedWrapper = styled.div(templateObject_1$o || (templateObject_1$o = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (props) {
|
|
7746
7761
|
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;") : "";
|
|
7747
7762
|
});
|
|
7763
|
+
var templateObject_1$o;
|
|
7764
|
+
|
|
7765
|
+
var CameraVideoTag = function CameraVideoTag(props) {
|
|
7766
|
+
var _a = useCameraStore(useShallow(function (store) {
|
|
7767
|
+
return {
|
|
7768
|
+
videoRef: store.videoRef,
|
|
7769
|
+
videoStream: store.videoStream,
|
|
7770
|
+
onVideoMounted: store.onVideoMounted,
|
|
7771
|
+
isRearFacing: store.isRearFacing
|
|
7772
|
+
};
|
|
7773
|
+
})),
|
|
7774
|
+
videoRef = _a.videoRef,
|
|
7775
|
+
videoStream = _a.videoStream,
|
|
7776
|
+
onVideoMounted = _a.onVideoMounted,
|
|
7777
|
+
isRearFacing = _a.isRearFacing;
|
|
7778
|
+
useEffect(function attachCameraStreamToVideoTagWhenReady() {
|
|
7779
|
+
if (videoRef.current && videoStream) {
|
|
7780
|
+
debug('attaching camera stream to video tag');
|
|
7781
|
+
videoRef.current.srcObject = videoStream;
|
|
7782
|
+
}
|
|
7783
|
+
}, [videoStream, videoRef]);
|
|
7784
|
+
return /*#__PURE__*/React__default.createElement(FullscreenVideoTag, _assign({
|
|
7785
|
+
autoPlay: true,
|
|
7786
|
+
playsInline: true,
|
|
7787
|
+
muted: true,
|
|
7788
|
+
ref: videoRef,
|
|
7789
|
+
onLoadedData: onVideoMounted,
|
|
7790
|
+
"$isRearFacing": isRearFacing
|
|
7791
|
+
}, props));
|
|
7792
|
+
};
|
|
7793
|
+
var FullscreenVideoTag = styled.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) {
|
|
7794
|
+
return props.$isRearFacing ? '' : 'scaleX(-1)';
|
|
7795
|
+
});
|
|
7748
7796
|
var templateObject_1$n;
|
|
7749
7797
|
|
|
7750
7798
|
var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
|
|
7751
|
-
var _b, _c, _d, _e, _f
|
|
7799
|
+
var _b, _c, _d, _e, _f;
|
|
7752
7800
|
var onCaptureClicked = _a.onCaptureClicked,
|
|
7753
|
-
|
|
7754
|
-
classNames =
|
|
7755
|
-
|
|
7756
|
-
rawVerbiage =
|
|
7757
|
-
var
|
|
7758
|
-
|
|
7759
|
-
documents =
|
|
7760
|
-
currentDocumentIndex =
|
|
7761
|
-
rectX =
|
|
7762
|
-
rectY =
|
|
7763
|
-
rectWidth =
|
|
7764
|
-
rectHeight =
|
|
7765
|
-
rectOffsetTop =
|
|
7766
|
-
capturing =
|
|
7767
|
-
uploadCapturedDocument =
|
|
7768
|
-
dispatch =
|
|
7769
|
-
var
|
|
7770
|
-
title =
|
|
7771
|
-
aspectRatio =
|
|
7772
|
-
cameraFeedMode =
|
|
7773
|
-
instructions =
|
|
7774
|
-
contentUrl =
|
|
7775
|
-
content =
|
|
7776
|
-
uploadState =
|
|
7777
|
-
var
|
|
7778
|
-
|
|
7779
|
-
cameraReady =
|
|
7780
|
-
cameraAccessDenied =
|
|
7781
|
-
requestCameraAccess =
|
|
7782
|
-
var
|
|
7783
|
-
cameraAccessRequested =
|
|
7784
|
-
setCameraAccessRequested =
|
|
7801
|
+
_g = _a.classNames,
|
|
7802
|
+
classNames = _g === void 0 ? {} : _g,
|
|
7803
|
+
_h = _a.verbiage,
|
|
7804
|
+
rawVerbiage = _h === void 0 ? {} : _h;
|
|
7805
|
+
var _j = useDocumentCaptureState(),
|
|
7806
|
+
_k = _j[0],
|
|
7807
|
+
documents = _k.documents,
|
|
7808
|
+
currentDocumentIndex = _k.currentDocumentIndex,
|
|
7809
|
+
rectX = _k.rectX,
|
|
7810
|
+
rectY = _k.rectY,
|
|
7811
|
+
rectWidth = _k.rectWidth,
|
|
7812
|
+
rectHeight = _k.rectHeight,
|
|
7813
|
+
rectOffsetTop = _k.rectOffsetTop,
|
|
7814
|
+
capturing = _k.capturing,
|
|
7815
|
+
uploadCapturedDocument = _k.uploadCapturedDocument,
|
|
7816
|
+
dispatch = _j[1];
|
|
7817
|
+
var _l = (_b = documents[currentDocumentIndex]) !== null && _b !== void 0 ? _b : {},
|
|
7818
|
+
title = _l.title,
|
|
7819
|
+
aspectRatio = _l.aspectRatio,
|
|
7820
|
+
cameraFeedMode = _l.cameraFeedMode,
|
|
7821
|
+
instructions = _l.instructions,
|
|
7822
|
+
contentUrl = _l.contentUrl,
|
|
7823
|
+
content = _l.content,
|
|
7824
|
+
uploadState = _l.uploadState;
|
|
7825
|
+
var _m = useCameraStore(),
|
|
7826
|
+
videoStream = _m.videoStream,
|
|
7827
|
+
cameraReady = _m.cameraReady,
|
|
7828
|
+
cameraAccessDenied = _m.cameraAccessDenied,
|
|
7829
|
+
requestCameraAccess = _m.requestCameraAccess;
|
|
7830
|
+
var _o = useState(false),
|
|
7831
|
+
cameraAccessRequested = _o[0],
|
|
7832
|
+
setCameraAccessRequested = _o[1];
|
|
7785
7833
|
var cameraAccessNeeded =
|
|
7786
7834
|
// we should force the browser to ask for camera access if...
|
|
7787
7835
|
uploadState === 'not_started' &&
|
|
@@ -7790,14 +7838,14 @@ var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
|
|
|
7790
7838
|
// and the user hasn't passed a media blob for the current document...
|
|
7791
7839
|
!cameraAccessRequested &&
|
|
7792
7840
|
// and we haven't already tried to force a camera request...
|
|
7793
|
-
!(
|
|
7841
|
+
!(videoStream === null || videoStream === void 0 ? void 0 : videoStream.active); // and we don't already have camera access.
|
|
7794
7842
|
useEffect(function requestCameraAccessIfNeeded() {
|
|
7795
7843
|
if (!cameraAccessNeeded) return;
|
|
7796
7844
|
setCameraAccessRequested(true);
|
|
7797
7845
|
requestCameraAccess();
|
|
7798
7846
|
}, [cameraAccessNeeded, requestCameraAccess]);
|
|
7799
7847
|
var theme = useTheme();
|
|
7800
|
-
var maskColor = (
|
|
7848
|
+
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)";
|
|
7801
7849
|
var verbiage = useTranslations(rawVerbiage, {
|
|
7802
7850
|
headingText: title,
|
|
7803
7851
|
loadingBtnText: 'Camera initializing...',
|
|
@@ -7830,7 +7878,7 @@ var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
|
|
|
7830
7878
|
});
|
|
7831
7879
|
}
|
|
7832
7880
|
return /*#__PURE__*/React__default.createElement(PageContainer, {
|
|
7833
|
-
className: "flex ".concat((
|
|
7881
|
+
className: "flex ".concat((_f = classNames.container) !== null && _f !== void 0 ? _f : '')
|
|
7834
7882
|
}, /*#__PURE__*/React__default.createElement(CameraFeedWrapper, {
|
|
7835
7883
|
className: classNames.cameraFeedWrapper,
|
|
7836
7884
|
"$mode": cameraFeedMode !== null && cameraFeedMode !== void 0 ? cameraFeedMode : 'snapToGuides',
|
|
@@ -8255,7 +8303,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
8255
8303
|
var _3 = useIdCaptureState(),
|
|
8256
8304
|
state = _3[0],
|
|
8257
8305
|
dispatch = _3[1];
|
|
8258
|
-
var _4 =
|
|
8306
|
+
var _4 = useCameraStore(),
|
|
8259
8307
|
cameraAccessDenied = _4.cameraAccessDenied,
|
|
8260
8308
|
requestCameraAccess = _4.requestCameraAccess,
|
|
8261
8309
|
releaseCameraAccess = _4.releaseCameraAccess;
|
|
@@ -8380,7 +8428,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
8380
8428
|
type: 'resetWizard'
|
|
8381
8429
|
});
|
|
8382
8430
|
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
8383
|
-
requestCameraAccess();
|
|
8431
|
+
void requestCameraAccess();
|
|
8384
8432
|
}, [dispatch, onExitCapture, releaseCameraAccess, requestCameraAccess]);
|
|
8385
8433
|
useEffect(function () {
|
|
8386
8434
|
if (submissionStatus !== SubmissionStatus.READY) {
|
|
@@ -9203,7 +9251,13 @@ function SelfieGuidanceModelsProvider(_a) {
|
|
|
9203
9251
|
modelLoadTimeoutMs = _c === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _c,
|
|
9204
9252
|
_d = _a.requireVerticalFaceCentering,
|
|
9205
9253
|
requireVerticalFaceCentering = _d === void 0 ? true : _d;
|
|
9206
|
-
var _e =
|
|
9254
|
+
var _e = useCameraStore(useShallow(function (state) {
|
|
9255
|
+
return {
|
|
9256
|
+
videoRef: state.videoRef,
|
|
9257
|
+
videoLoaded: state.videoLoaded,
|
|
9258
|
+
cameraReady: state.cameraReady
|
|
9259
|
+
};
|
|
9260
|
+
})),
|
|
9207
9261
|
videoRef = _e.videoRef,
|
|
9208
9262
|
videoLoaded = _e.videoLoaded,
|
|
9209
9263
|
cameraReady = _e.cameraReady;
|
|
@@ -9211,7 +9265,8 @@ function SelfieGuidanceModelsProvider(_a) {
|
|
|
9211
9265
|
var onPredictionHandler = useRef();
|
|
9212
9266
|
var _f = useLoadFaceDetector({
|
|
9213
9267
|
onModelError: onModelError,
|
|
9214
|
-
modelLoadTimeoutMs: modelLoadTimeoutMs
|
|
9268
|
+
modelLoadTimeoutMs: modelLoadTimeoutMs,
|
|
9269
|
+
videoRef: videoRef
|
|
9215
9270
|
}),
|
|
9216
9271
|
ready = _f.ready,
|
|
9217
9272
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
@@ -9544,8 +9599,14 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
9544
9599
|
prediction = _t.prediction,
|
|
9545
9600
|
dispatch = _s[1];
|
|
9546
9601
|
var lastPredictionCanvas = useRef(null);
|
|
9547
|
-
var _u =
|
|
9548
|
-
|
|
9602
|
+
var _u = useCameraStore(useShallow(function (state) {
|
|
9603
|
+
return {
|
|
9604
|
+
camera: state.camera,
|
|
9605
|
+
cameraReady: state.cameraReady,
|
|
9606
|
+
videoRef: state.videoRef
|
|
9607
|
+
};
|
|
9608
|
+
})),
|
|
9609
|
+
camera = _u.camera,
|
|
9549
9610
|
videoRef = _u.videoRef;
|
|
9550
9611
|
var _v = useContext(SelfieGuidanceModelsContext),
|
|
9551
9612
|
onPredictionMade = _v.onPredictionMade,
|
|
@@ -9635,7 +9696,7 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
9635
9696
|
face: prediction.face,
|
|
9636
9697
|
scaling: debugScalingDetails,
|
|
9637
9698
|
color: satisfied ? 'green' : 'red'
|
|
9638
|
-
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null,
|
|
9699
|
+
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), !(prediction === null || prediction === void 0 ? void 0 : prediction.faceNotCentered) ? '✅' : '❌', " Face Centered", /*#__PURE__*/React__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__default.createElement("br", null), !(prediction === null || prediction === void 0 ? void 0 : prediction.faceLookingAway) ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React__default.createElement("br", null), !(prediction === null || prediction === void 0 ? void 0 : prediction.faceIsStable) ? '✅' : '❌', " Face Is Stable", /*#__PURE__*/React__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__default.createElement(ExitCaptureButton, {
|
|
9639
9700
|
onClick: onExit,
|
|
9640
9701
|
className: classNames.exitCaptureBtn
|
|
9641
9702
|
}));
|
|
@@ -10091,7 +10152,9 @@ var MicrophoneAccessDeniedOverlay = function MicrophoneAccessDeniedOverlay(_a) {
|
|
|
10091
10152
|
colors = _e === void 0 ? {} : _e,
|
|
10092
10153
|
_f = _a.verbiage,
|
|
10093
10154
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
10094
|
-
var requestMicrophoneAccess =
|
|
10155
|
+
var requestMicrophoneAccess = useCameraStore(function (state) {
|
|
10156
|
+
return state.requestMicrophoneAccess;
|
|
10157
|
+
});
|
|
10095
10158
|
assets.imageUrl || (assets.imageUrl = DEFAULT_CDN_URL + '/microphone-disable-icon.svg');
|
|
10096
10159
|
var verbiage = useTranslations(rawVerbiage, {
|
|
10097
10160
|
headingText: 'Your microphone permission is disabled',
|
|
@@ -10139,7 +10202,13 @@ var SelfieCaptureLoadingOverlayLegacy = function SelfieCaptureLoadingOverlayLega
|
|
|
10139
10202
|
colors = _e === void 0 ? {} : _e,
|
|
10140
10203
|
_f = _a.verbiage,
|
|
10141
10204
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
10142
|
-
var _g =
|
|
10205
|
+
var _g = useCameraStore(useShallow(function (state) {
|
|
10206
|
+
return {
|
|
10207
|
+
cameraReady: state.cameraReady,
|
|
10208
|
+
cameraAccessDenied: state.cameraAccessDenied,
|
|
10209
|
+
microphoneAccessDenied: state.microphoneAccessDenied
|
|
10210
|
+
};
|
|
10211
|
+
})),
|
|
10143
10212
|
cameraReady = _g.cameraReady,
|
|
10144
10213
|
cameraAccessDenied = _g.cameraAccessDenied,
|
|
10145
10214
|
microphoneAccessDenied = _g.microphoneAccessDenied;
|
|
@@ -10226,7 +10295,13 @@ var SelfieCaptureLoadingOverlayDefault = function SelfieCaptureLoadingOverlayDef
|
|
|
10226
10295
|
colors = _e === void 0 ? {} : _e,
|
|
10227
10296
|
_f = _a.verbiage,
|
|
10228
10297
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
10229
|
-
var _g =
|
|
10298
|
+
var _g = useCameraStore(useShallow(function (state) {
|
|
10299
|
+
return {
|
|
10300
|
+
cameraReady: state.cameraReady,
|
|
10301
|
+
cameraAccessDenied: state.cameraAccessDenied,
|
|
10302
|
+
microphoneAccessDenied: state.microphoneAccessDenied
|
|
10303
|
+
};
|
|
10304
|
+
})),
|
|
10230
10305
|
cameraReady = _g.cameraReady,
|
|
10231
10306
|
cameraAccessDenied = _g.cameraAccessDenied,
|
|
10232
10307
|
microphoneAccessDenied = _g.microphoneAccessDenied;
|
|
@@ -10443,7 +10518,13 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
|
|
|
10443
10518
|
livenessCheckRequest = _t.livenessCheckRequest,
|
|
10444
10519
|
setSelfieImage = _t.setSelfieImage,
|
|
10445
10520
|
logSelfieCaptureAttempt = _t.logSelfieCaptureAttempt;
|
|
10446
|
-
var _u =
|
|
10521
|
+
var _u = useCameraStore(useShallow(function (state) {
|
|
10522
|
+
return {
|
|
10523
|
+
cameraAccessDenied: state.cameraAccessDenied,
|
|
10524
|
+
requestCameraAccess: state.requestCameraAccess,
|
|
10525
|
+
releaseCameraAccess: state.releaseCameraAccess
|
|
10526
|
+
};
|
|
10527
|
+
})),
|
|
10447
10528
|
cameraAccessDenied = _u.cameraAccessDenied,
|
|
10448
10529
|
requestCameraAccess = _u.requestCameraAccess,
|
|
10449
10530
|
releaseCameraAccess = _u.releaseCameraAccess;
|
|
@@ -11164,10 +11245,10 @@ function VideoSignatureContextProvider(_a) {
|
|
|
11164
11245
|
setSignatureVideoUrl = _e[1];
|
|
11165
11246
|
var signatureRecorder = useRef(null);
|
|
11166
11247
|
var recordedChunks = useRef([]);
|
|
11167
|
-
var _f =
|
|
11168
|
-
|
|
11248
|
+
var _f = useCameraStore(),
|
|
11249
|
+
camera = _f.camera,
|
|
11169
11250
|
videoRef = _f.videoRef;
|
|
11170
|
-
var _g = useVideoRecorder(
|
|
11251
|
+
var _g = useVideoRecorder(camera),
|
|
11171
11252
|
isRecordingVideo = _g.isRecordingVideo,
|
|
11172
11253
|
startRecordingVideo = _g.startRecordingVideo,
|
|
11173
11254
|
stopRecordingVideo = _g.stopRecordingVideo,
|
|
@@ -11235,8 +11316,8 @@ function VideoSignatureContextProvider(_a) {
|
|
|
11235
11316
|
var animationFrame = useRef(0);
|
|
11236
11317
|
useEffect(function () {
|
|
11237
11318
|
var _a;
|
|
11238
|
-
if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !
|
|
11239
|
-
var _b = [
|
|
11319
|
+
if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !camera || !isRecording || !isRecordingVideo) return;
|
|
11320
|
+
var _b = [camera.width, camera.height],
|
|
11240
11321
|
w = _b[0],
|
|
11241
11322
|
h = _b[1];
|
|
11242
11323
|
var isPortrait = typeof window !== 'undefined' && window.innerWidth < window.innerHeight;
|
|
@@ -11269,7 +11350,7 @@ function VideoSignatureContextProvider(_a) {
|
|
|
11269
11350
|
return function () {
|
|
11270
11351
|
cancelAnimationFrame(animationFrame.current);
|
|
11271
11352
|
};
|
|
11272
|
-
}, [
|
|
11353
|
+
}, [camera, isRecording, isRecordingVideo, videoRef]);
|
|
11273
11354
|
var onAcceptClicked = useCallback(function () {
|
|
11274
11355
|
return __awaiter(_this, void 0, void 0, function () {
|
|
11275
11356
|
var imageUrl;
|
|
@@ -11398,27 +11479,29 @@ var AcceptBtn = styled(LoaderButton)(templateObject_7$1 || (templateObject_7$1 =
|
|
|
11398
11479
|
var templateObject_1$9, templateObject_2$8, templateObject_3$8, templateObject_4$3, templateObject_5$2, templateObject_6$2, templateObject_7$1;
|
|
11399
11480
|
|
|
11400
11481
|
var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
11401
|
-
var _b
|
|
11482
|
+
var _b;
|
|
11402
11483
|
var onVideoCaptured = _a.onVideoCaptured,
|
|
11403
11484
|
onFaceNotDetected = _a.onFaceNotDetected,
|
|
11404
11485
|
onExit = _a.onExit,
|
|
11405
11486
|
guidesComponent = _a.guidesComponent,
|
|
11406
|
-
|
|
11407
|
-
classNames =
|
|
11408
|
-
|
|
11409
|
-
colors =
|
|
11410
|
-
|
|
11411
|
-
rawVerbiage =
|
|
11412
|
-
|
|
11413
|
-
debugMode =
|
|
11414
|
-
var
|
|
11487
|
+
_c = _a.classNames,
|
|
11488
|
+
classNames = _c === void 0 ? {} : _c,
|
|
11489
|
+
_d = _a.colors,
|
|
11490
|
+
colors = _d === void 0 ? {} : _d,
|
|
11491
|
+
_e = _a.verbiage,
|
|
11492
|
+
rawVerbiage = _e === void 0 ? {} : _e,
|
|
11493
|
+
_f = _a.debugMode,
|
|
11494
|
+
debugMode = _f === void 0 ? false : _f;
|
|
11495
|
+
var camera = useCameraStore(function (state) {
|
|
11496
|
+
return state.camera;
|
|
11497
|
+
});
|
|
11415
11498
|
var onPredictionMade = useContext(SelfieGuidanceModelsContext).onPredictionMade;
|
|
11416
|
-
var
|
|
11417
|
-
signatureData =
|
|
11418
|
-
signatureDataUrl =
|
|
11419
|
-
signatureVideoData =
|
|
11420
|
-
startRecording =
|
|
11421
|
-
stopRecording =
|
|
11499
|
+
var _g = useVideoSignatureContext(),
|
|
11500
|
+
signatureData = _g.signatureData,
|
|
11501
|
+
signatureDataUrl = _g.signatureDataUrl,
|
|
11502
|
+
signatureVideoData = _g.signatureVideoData,
|
|
11503
|
+
startRecording = _g.startRecording,
|
|
11504
|
+
stopRecording = _g.stopRecording;
|
|
11422
11505
|
useEffect(function () {
|
|
11423
11506
|
startRecording();
|
|
11424
11507
|
return function () {
|
|
@@ -11435,9 +11518,9 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
11435
11518
|
onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(signatureVideoData, signatureData, signatureDataUrl);
|
|
11436
11519
|
}
|
|
11437
11520
|
}, [onVideoCaptured, signatureData, signatureDataUrl, signatureVideoData]);
|
|
11438
|
-
var
|
|
11439
|
-
numFramesWithoutFaces =
|
|
11440
|
-
setNumFramesWithoutFaces =
|
|
11521
|
+
var _h = useState(0),
|
|
11522
|
+
numFramesWithoutFaces = _h[0],
|
|
11523
|
+
setNumFramesWithoutFaces = _h[1];
|
|
11441
11524
|
useEffect(function () {
|
|
11442
11525
|
onPredictionMade(function (_a) {
|
|
11443
11526
|
var face = _a.face;
|
|
@@ -11464,7 +11547,7 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
11464
11547
|
}, verbiage.guidanceMessageText))), /*#__PURE__*/React__default.createElement(GuidesComponent, {
|
|
11465
11548
|
classNames: classNames.videoSignatureGuidesClassNames,
|
|
11466
11549
|
status: "success"
|
|
11467
|
-
}), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, "Video: ",
|
|
11550
|
+
}), debugMode && ( /*#__PURE__*/React__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__default.createElement(ExitCaptureButton, {
|
|
11468
11551
|
onClick: onExit,
|
|
11469
11552
|
className: classNames.exitCaptureBtn
|
|
11470
11553
|
}));
|
|
@@ -11558,7 +11641,13 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
|
|
|
11558
11641
|
setSignatureData = _l.setSignatureData,
|
|
11559
11642
|
setSignatureVideoUrl = _l.setSignatureVideoUrl,
|
|
11560
11643
|
logSelfieCaptureAttempt = _l.logSelfieCaptureAttempt;
|
|
11561
|
-
var _m =
|
|
11644
|
+
var _m = useCameraStore(useShallow(function (state) {
|
|
11645
|
+
return {
|
|
11646
|
+
cameraAccessDenied: state.cameraAccessDenied,
|
|
11647
|
+
requestCameraAccess: state.requestCameraAccess,
|
|
11648
|
+
releaseCameraAccess: state.releaseCameraAccess
|
|
11649
|
+
};
|
|
11650
|
+
})),
|
|
11562
11651
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
11563
11652
|
requestCameraAccess = _m.requestCameraAccess,
|
|
11564
11653
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
@@ -11718,27 +11807,29 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
|
|
|
11718
11807
|
};
|
|
11719
11808
|
|
|
11720
11809
|
var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
11721
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y
|
|
11722
|
-
var
|
|
11723
|
-
requestedAction =
|
|
11724
|
-
|
|
11725
|
-
satisfied =
|
|
11726
|
-
|
|
11727
|
-
faceGuideStatus =
|
|
11810
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
11811
|
+
var _z = _a.requestedAction,
|
|
11812
|
+
requestedAction = _z === void 0 ? 'SHOW_ID_FRONT' : _z,
|
|
11813
|
+
_0 = _a.satisfied,
|
|
11814
|
+
satisfied = _0 === void 0 ? false : _0,
|
|
11815
|
+
_1 = _a.faceGuideStatus,
|
|
11816
|
+
faceGuideStatus = _1 === void 0 ? 'success' : _1,
|
|
11728
11817
|
faceGuideBorderWidth = _a.faceGuideBorderWidth,
|
|
11729
11818
|
faceGuideBorderColor = _a.faceGuideBorderColor,
|
|
11730
|
-
|
|
11731
|
-
idCardGuideStatus =
|
|
11819
|
+
_2 = _a.idCardGuideStatus,
|
|
11820
|
+
idCardGuideStatus = _2 === void 0 ? 'ready' : _2,
|
|
11732
11821
|
idCardGuideBorderWidth = _a.idCardGuideBorderWidth,
|
|
11733
11822
|
idCardGuideBorderColor = _a.idCardGuideBorderColor,
|
|
11734
11823
|
idCardCaptureProgress = _a.idCardCaptureProgress,
|
|
11735
|
-
|
|
11736
|
-
userSuppliedImages =
|
|
11737
|
-
|
|
11738
|
-
classNames =
|
|
11739
|
-
|
|
11740
|
-
rawVerbiage =
|
|
11741
|
-
var
|
|
11824
|
+
_3 = _a.idCardCaptureGuideImages,
|
|
11825
|
+
userSuppliedImages = _3 === void 0 ? defaultIdCaptureGuideImages : _3,
|
|
11826
|
+
_4 = _a.classNames,
|
|
11827
|
+
classNames = _4 === void 0 ? {} : _4,
|
|
11828
|
+
_5 = _a.verbiage,
|
|
11829
|
+
rawVerbiage = _5 === void 0 ? {} : _5;
|
|
11830
|
+
var isRearFacing = useCameraStore(function (state) {
|
|
11831
|
+
return state.isRearFacing;
|
|
11832
|
+
});
|
|
11742
11833
|
var verbiage = useTranslations(rawVerbiage, {
|
|
11743
11834
|
idFrontInstructionText: 'Display the front of your ID card...',
|
|
11744
11835
|
idBackInstructionText: 'Display the back of your ID card...',
|
|
@@ -11751,17 +11842,17 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
|
11751
11842
|
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';
|
|
11752
11843
|
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;
|
|
11753
11844
|
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';
|
|
11754
|
-
var
|
|
11755
|
-
idCardGuideRef =
|
|
11756
|
-
|
|
11757
|
-
idCardGuideWidth =
|
|
11758
|
-
|
|
11759
|
-
idCardGuideHeight =
|
|
11845
|
+
var _6 = useResizeObserver(),
|
|
11846
|
+
idCardGuideRef = _6.ref,
|
|
11847
|
+
_7 = _6.width,
|
|
11848
|
+
idCardGuideWidth = _7 === void 0 ? 0 : _7,
|
|
11849
|
+
_8 = _6.height,
|
|
11850
|
+
idCardGuideHeight = _8 === void 0 ? 0 : _8;
|
|
11760
11851
|
var idCaptureGuideImages = useGuideImages(userSuppliedImages);
|
|
11761
11852
|
var idCaptureGuideImagesByUrl = useGuideImagesByUrl(idCaptureGuideImages);
|
|
11762
|
-
var
|
|
11763
|
-
aspectRatio =
|
|
11764
|
-
setAspectRatio =
|
|
11853
|
+
var _9 = useState(undefined),
|
|
11854
|
+
aspectRatio = _9[0],
|
|
11855
|
+
setAspectRatio = _9[1];
|
|
11765
11856
|
var onImageLoaded = useCallback(function (e) {
|
|
11766
11857
|
var _a, _b, _c, _d;
|
|
11767
11858
|
var img = e.currentTarget;
|
|
@@ -11808,7 +11899,7 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
|
11808
11899
|
}, /*#__PURE__*/React__default.createElement(IdCardGuideImage, {
|
|
11809
11900
|
alt: "",
|
|
11810
11901
|
className: classNames.idCardGuideImage,
|
|
11811
|
-
"$isMirrored": !
|
|
11902
|
+
"$isMirrored": !isRearFacing,
|
|
11812
11903
|
style: idCardImageStyle,
|
|
11813
11904
|
src: requestedAction === 'SHOW_ID_BACK' ? idCaptureGuideImages.landscape.SHOW_ID_BACK.url : idCaptureGuideImages.landscape.SHOW_ID_FRONT.url,
|
|
11814
11905
|
onLoad: onImageLoaded
|
|
@@ -11822,8 +11913,8 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
|
11822
11913
|
className: classNames.idCardGuideInstructionsContainer
|
|
11823
11914
|
}, /*#__PURE__*/React__default.createElement(IdCardGuideInstructions, {
|
|
11824
11915
|
className: classNames.idCardGuideInstructions,
|
|
11825
|
-
"$textColor": (
|
|
11826
|
-
"$background": (
|
|
11916
|
+
"$textColor": (_w = (_v = theme.idVideoCapture) === null || _v === void 0 ? void 0 : _v.idCardGuides) === null || _w === void 0 ? void 0 : _w.instructionsTextColor,
|
|
11917
|
+
"$background": (_y = (_x = theme.idVideoCapture) === null || _x === void 0 ? void 0 : _x.idCardGuides) === null || _y === void 0 ? void 0 : _y.instructionsBackgroundColor
|
|
11827
11918
|
}, instructionText))))));
|
|
11828
11919
|
};
|
|
11829
11920
|
var Container = styled.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) {
|
|
@@ -11968,99 +12059,100 @@ var defaultVideoIdCaptureThresholds = {
|
|
|
11968
12059
|
flipShortcutThreshold: 0.7
|
|
11969
12060
|
};
|
|
11970
12061
|
var IdVideoCapture = function IdVideoCapture(_a) {
|
|
11971
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v
|
|
12062
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
11972
12063
|
var onComplete = _a.onComplete,
|
|
11973
12064
|
onIdFrontImageCaptured = _a.onIdFrontImageCaptured,
|
|
11974
12065
|
onIdBackImageCaptured = _a.onIdBackImageCaptured,
|
|
11975
12066
|
onFaceNotDetected = _a.onFaceNotDetected,
|
|
11976
12067
|
onRecordingFailed = _a.onRecordingFailed,
|
|
11977
12068
|
onExitCapture = _a.onExitCapture,
|
|
11978
|
-
|
|
11979
|
-
idCaptureModelsEnabled =
|
|
11980
|
-
|
|
11981
|
-
idCardCaptureGuideImages =
|
|
11982
|
-
|
|
11983
|
-
idCardFrontDelay =
|
|
11984
|
-
|
|
11985
|
-
videoIdCaptureThresholds =
|
|
11986
|
-
|
|
11987
|
-
skipShowIdCardBack =
|
|
11988
|
-
|
|
11989
|
-
captureCountdownSeconds =
|
|
12069
|
+
_w = _a.idCaptureModelsEnabled,
|
|
12070
|
+
idCaptureModelsEnabled = _w === void 0 ? true : _w,
|
|
12071
|
+
_x = _a.idCardCaptureGuideImages,
|
|
12072
|
+
idCardCaptureGuideImages = _x === void 0 ? defaultIdCaptureGuideImages : _x,
|
|
12073
|
+
_y = _a.idCardFrontDelay,
|
|
12074
|
+
idCardFrontDelay = _y === void 0 ? 1000 : _y,
|
|
12075
|
+
_z = _a.videoIdCaptureThresholds,
|
|
12076
|
+
videoIdCaptureThresholds = _z === void 0 ? defaultVideoIdCaptureThresholds : _z,
|
|
12077
|
+
_0 = _a.skipShowIdCardBack,
|
|
12078
|
+
skipShowIdCardBack = _0 === void 0 ? false : _0,
|
|
12079
|
+
_1 = _a.captureCountdownSeconds,
|
|
12080
|
+
captureCountdownSeconds = _1 === void 0 ? 3 : _1,
|
|
11990
12081
|
readTextPrompt = _a.readTextPrompt,
|
|
11991
|
-
|
|
11992
|
-
readTextTimeoutDurationMs =
|
|
11993
|
-
|
|
11994
|
-
readTextMinReadingMs =
|
|
11995
|
-
|
|
11996
|
-
disableFaceDetectionWhileAudioCapture =
|
|
11997
|
-
|
|
11998
|
-
disableFaceDetectionWhileAudioCaptureMsDelay =
|
|
11999
|
-
|
|
12000
|
-
mergeAVStreams =
|
|
12001
|
-
|
|
12002
|
-
classNames =
|
|
12003
|
-
|
|
12004
|
-
colors =
|
|
12005
|
-
|
|
12006
|
-
rawVerbiage =
|
|
12007
|
-
|
|
12008
|
-
debugMode =
|
|
12009
|
-
var
|
|
12010
|
-
ref =
|
|
12011
|
-
|
|
12012
|
-
width =
|
|
12013
|
-
|
|
12014
|
-
height =
|
|
12015
|
-
var
|
|
12016
|
-
|
|
12017
|
-
videoRef =
|
|
12018
|
-
videoLoaded =
|
|
12019
|
-
cameraReady =
|
|
12020
|
-
microphoneReady =
|
|
12021
|
-
audioStream =
|
|
12022
|
-
|
|
12023
|
-
|
|
12024
|
-
|
|
12025
|
-
|
|
12026
|
-
|
|
12027
|
-
|
|
12028
|
-
|
|
12029
|
-
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
|
|
12036
|
-
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12041
|
-
|
|
12042
|
-
|
|
12043
|
-
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12082
|
+
_2 = _a.readTextTimeoutDurationMs,
|
|
12083
|
+
readTextTimeoutDurationMs = _2 === void 0 ? 15000 : _2,
|
|
12084
|
+
_3 = _a.readTextMinReadingMs,
|
|
12085
|
+
readTextMinReadingMs = _3 === void 0 ? 10000 : _3,
|
|
12086
|
+
_4 = _a.disableFaceDetectionWhileAudioCapture,
|
|
12087
|
+
disableFaceDetectionWhileAudioCapture = _4 === void 0 ? false : _4,
|
|
12088
|
+
_5 = _a.disableFaceDetectionWhileAudioCaptureMsDelay,
|
|
12089
|
+
disableFaceDetectionWhileAudioCaptureMsDelay = _5 === void 0 ? 2000 : _5,
|
|
12090
|
+
_6 = _a.mergeAVStreams,
|
|
12091
|
+
mergeAVStreams = _6 === void 0 ? false : _6,
|
|
12092
|
+
_7 = _a.classNames,
|
|
12093
|
+
classNames = _7 === void 0 ? {} : _7,
|
|
12094
|
+
_8 = _a.colors,
|
|
12095
|
+
colors = _8 === void 0 ? {} : _8,
|
|
12096
|
+
_9 = _a.verbiage,
|
|
12097
|
+
rawVerbiage = _9 === void 0 ? {} : _9,
|
|
12098
|
+
_10 = _a.debugMode,
|
|
12099
|
+
debugMode = _10 === void 0 ? false : _10;
|
|
12100
|
+
var _11 = useResizeObserver(),
|
|
12101
|
+
ref = _11.ref,
|
|
12102
|
+
_12 = _11.width,
|
|
12103
|
+
width = _12 === void 0 ? 1 : _12,
|
|
12104
|
+
_13 = _11.height,
|
|
12105
|
+
height = _13 === void 0 ? 1 : _13;
|
|
12106
|
+
var _14 = useCameraStore(),
|
|
12107
|
+
camera = _14.camera,
|
|
12108
|
+
videoRef = _14.videoRef,
|
|
12109
|
+
videoLoaded = _14.videoLoaded,
|
|
12110
|
+
cameraReady = _14.cameraReady,
|
|
12111
|
+
microphoneReady = _14.microphoneReady,
|
|
12112
|
+
audioStream = _14.audioStream,
|
|
12113
|
+
isRearFacing = _14.isRearFacing,
|
|
12114
|
+
releaseCameraAccess = _14.releaseCameraAccess;
|
|
12115
|
+
var _15 = useState([]),
|
|
12116
|
+
detectedObjects = _15[0],
|
|
12117
|
+
setDetectedObjects = _15[1];
|
|
12118
|
+
var _16 = useState(null),
|
|
12119
|
+
face = _16[0],
|
|
12120
|
+
setFace = _16[1];
|
|
12121
|
+
var _17 = useContext(IdCaptureModelsContext),
|
|
12122
|
+
idModelsReady = _17.ready,
|
|
12123
|
+
startIdModels = _17.start,
|
|
12124
|
+
stopIdModels = _17.stop,
|
|
12125
|
+
onIdPredictionMade = _17.onPredictionMade,
|
|
12126
|
+
setThresholds = _17.setThresholds,
|
|
12127
|
+
setDocumentDetectionBoundaries = _17.setDocumentDetectionBoundaries,
|
|
12128
|
+
bestFrameDetails = _17.bestFrameDetails,
|
|
12129
|
+
resetBestFrame = _17.resetBestFrame,
|
|
12130
|
+
idModelError = _17.modelError;
|
|
12131
|
+
var _18 = useState(null),
|
|
12132
|
+
videoStartsAt = _18[0],
|
|
12133
|
+
setVideoStartsAt = _18[1];
|
|
12134
|
+
var _19 = useContext(SubmissionContext),
|
|
12135
|
+
setIdCaptureVideoAudioStartsAt = _19.setIdCaptureVideoAudioStartsAt,
|
|
12136
|
+
setExpectedAudioText = _19.setExpectedAudioText;
|
|
12137
|
+
var _20 = useContext(SelfieGuidanceModelsContext),
|
|
12138
|
+
startSelfieGuidance = _20.start,
|
|
12139
|
+
stopSelfieGuidance = _20.stop,
|
|
12140
|
+
onSelfiePredictionMade = _20.onPredictionMade,
|
|
12141
|
+
selfieModelError = _20.error;
|
|
12142
|
+
var _21 = useVideoRecorder(camera, audioStream, mergeAVStreams),
|
|
12143
|
+
isRecordingVideo = _21.isRecordingVideo,
|
|
12144
|
+
startRecordingVideo = _21.startRecordingVideo,
|
|
12145
|
+
startRecordingAudio = _21.startRecordingAudio,
|
|
12146
|
+
stopRecordingVideo = _21.stopRecordingVideo,
|
|
12147
|
+
stopRecordingAudio = _21.stopRecordingAudio,
|
|
12148
|
+
videoRecordingUnintentionallyStopped = _21.videoRecordingUnintentionallyStopped,
|
|
12149
|
+
audioRecordingUnintentionallyStopped = _21.audioRecordingUnintentionallyStopped,
|
|
12150
|
+
videoUrl = _21.videoUrl,
|
|
12151
|
+
audioUrl = _21.audioUrl;
|
|
12060
12152
|
var countdownTimeoutRef = useRef(undefined);
|
|
12061
|
-
var
|
|
12062
|
-
countdownRemaining =
|
|
12063
|
-
setCountdownRemaining =
|
|
12153
|
+
var _22 = useState(-1),
|
|
12154
|
+
countdownRemaining = _22[0],
|
|
12155
|
+
setCountdownRemaining = _22[1];
|
|
12064
12156
|
useEffect(function () {
|
|
12065
12157
|
if (!isRecordingVideo && !videoUrl) {
|
|
12066
12158
|
startRecordingVideo();
|
|
@@ -12071,24 +12163,24 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12071
12163
|
var needsAudio = !!readTextPrompt && !mergeAVStreams;
|
|
12072
12164
|
var audioReady = !needsAudio || audioUrl;
|
|
12073
12165
|
if (videoUrl && audioReady) {
|
|
12074
|
-
|
|
12166
|
+
releaseCameraAccess();
|
|
12075
12167
|
onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl, audioUrl);
|
|
12076
12168
|
}
|
|
12077
|
-
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt,
|
|
12169
|
+
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, releaseCameraAccess, startRecordingVideo, videoUrl]);
|
|
12078
12170
|
useEffect(function () {
|
|
12079
|
-
if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped) {
|
|
12171
|
+
if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped || !!readTextPrompt && !microphoneReady) {
|
|
12080
12172
|
onRecordingFailed === null || onRecordingFailed === void 0 ? void 0 : onRecordingFailed();
|
|
12081
12173
|
}
|
|
12082
|
-
}, [audioRecordingUnintentionallyStopped, onRecordingFailed, videoRecordingUnintentionallyStopped]);
|
|
12083
|
-
var
|
|
12084
|
-
requestedAction =
|
|
12085
|
-
setRequestedAction =
|
|
12174
|
+
}, [audioRecordingUnintentionallyStopped, microphoneReady, onRecordingFailed, readTextPrompt, videoRecordingUnintentionallyStopped]);
|
|
12175
|
+
var _23 = useState('SHOW_ID_FRONT'),
|
|
12176
|
+
requestedAction = _23[0],
|
|
12177
|
+
setRequestedAction = _23[1];
|
|
12086
12178
|
var shouldRunIdModels = idCaptureModelsEnabled && videoLoaded && cameraReady && idModelsReady && !idModelError && requestedAction !== 'READ_TEXT' && (!readTextPrompt || microphoneReady);
|
|
12087
12179
|
useEffect(function startModelsWhenCapturing() {
|
|
12088
12180
|
if (!shouldRunIdModels) return;
|
|
12089
12181
|
startIdModels();
|
|
12090
12182
|
return function () {
|
|
12091
|
-
stopIdModels();
|
|
12183
|
+
return stopIdModels();
|
|
12092
12184
|
};
|
|
12093
12185
|
}, [shouldRunIdModels, startIdModels, stopIdModels]);
|
|
12094
12186
|
useEffect(function () {
|
|
@@ -12102,18 +12194,18 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12102
12194
|
bottom: 1
|
|
12103
12195
|
});
|
|
12104
12196
|
}, [setDocumentDetectionBoundaries]);
|
|
12105
|
-
var
|
|
12106
|
-
currentDetectionScore =
|
|
12107
|
-
setCurrentDetectionScore =
|
|
12108
|
-
var
|
|
12109
|
-
currentDetectedDocumentType =
|
|
12110
|
-
setCurrentDetectedDocumentType =
|
|
12197
|
+
var _24 = useState(0),
|
|
12198
|
+
currentDetectionScore = _24[0],
|
|
12199
|
+
setCurrentDetectionScore = _24[1];
|
|
12200
|
+
var _25 = useState('none'),
|
|
12201
|
+
currentDetectedDocumentType = _25[0],
|
|
12202
|
+
setCurrentDetectedDocumentType = _25[1];
|
|
12203
|
+
var _26 = useState(0),
|
|
12204
|
+
currentFocusScore = _26[0],
|
|
12205
|
+
setCurrentFocusScore = _26[1];
|
|
12111
12206
|
var _27 = useState(0),
|
|
12112
|
-
|
|
12113
|
-
|
|
12114
|
-
var _28 = useState(0),
|
|
12115
|
-
goodFramesCount = _28[0],
|
|
12116
|
-
setGoodFramesCount = _28[1];
|
|
12207
|
+
goodFramesCount = _27[0],
|
|
12208
|
+
setGoodFramesCount = _27[1];
|
|
12117
12209
|
var goodFramesThreshold = requestedAction === 'SHOW_ID_FRONT' ? videoIdCaptureThresholds.goodFrames.idCardFront : videoIdCaptureThresholds.goodFrames.idCardBack;
|
|
12118
12210
|
var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
|
|
12119
12211
|
useEffect(function () {
|
|
@@ -12134,9 +12226,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12134
12226
|
} : 0);
|
|
12135
12227
|
});
|
|
12136
12228
|
}, [idCaptureModelsEnabled, onIdPredictionMade, idModelError, requestedAction, videoIdCaptureThresholds.flipShortcutThreshold]);
|
|
12137
|
-
var
|
|
12138
|
-
idFrontCaptureStartedAt =
|
|
12139
|
-
setFirstGoodFrameTime =
|
|
12229
|
+
var _28 = useState(null),
|
|
12230
|
+
idFrontCaptureStartedAt = _28[0],
|
|
12231
|
+
setFirstGoodFrameTime = _28[1];
|
|
12140
12232
|
useEffect(function () {
|
|
12141
12233
|
if (goodFramesCount === 1) setFirstGoodFrameTime(new Date().getTime());
|
|
12142
12234
|
}, [goodFramesCount]);
|
|
@@ -12157,9 +12249,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12157
12249
|
var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
|
|
12158
12250
|
var faceBox = face === null || face === void 0 ? void 0 : face.box;
|
|
12159
12251
|
var faceCentered = !faceBox || !frameWidth || faceBox.xMin > frameWidth * edgeBoundary && faceBox.yMin > frameHeight * edgeBoundary && faceBox.xMax < frameWidth * (1 - edgeBoundary) && faceBox.yMax < frameHeight * (1 - edgeBoundary);
|
|
12160
|
-
var
|
|
12161
|
-
countdownStartedAt =
|
|
12162
|
-
setCountdownStartedAt =
|
|
12252
|
+
var _29 = useState(),
|
|
12253
|
+
countdownStartedAt = _29[0],
|
|
12254
|
+
setCountdownStartedAt = _29[1];
|
|
12163
12255
|
var photoCanvas = useRef(null);
|
|
12164
12256
|
var frameLock = useRef(false);
|
|
12165
12257
|
var captureFrame = useCallback(function () {
|
|
@@ -12282,9 +12374,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12282
12374
|
stopSelfieGuidance();
|
|
12283
12375
|
};
|
|
12284
12376
|
}, [startSelfieGuidance, stopSelfieGuidance]);
|
|
12285
|
-
var
|
|
12286
|
-
numFramesWithoutFaces =
|
|
12287
|
-
setNumFramesWithoutFaces =
|
|
12377
|
+
var _30 = useState(0),
|
|
12378
|
+
numFramesWithoutFaces = _30[0],
|
|
12379
|
+
setNumFramesWithoutFaces = _30[1];
|
|
12288
12380
|
onSelfiePredictionMade(useThrottledCallback(useCallback(function (_a) {
|
|
12289
12381
|
var face = _a.face;
|
|
12290
12382
|
if (selfieModelError) return;
|
|
@@ -12300,12 +12392,12 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12300
12392
|
}
|
|
12301
12393
|
}, [disableFaceDetectionWhileAudioCapture, disableFaceDetectionWhileAudioCaptureMsDelay, numFramesWithoutFaces, onFaceNotDetected, timeoutStartedAt]);
|
|
12302
12394
|
var theme = useTheme();
|
|
12303
|
-
var
|
|
12395
|
+
var _31 = useTranslations(rawVerbiage, {
|
|
12304
12396
|
faceNotCenteredText: 'Please move your face to the center...',
|
|
12305
12397
|
captureBtnText: 'Capture'
|
|
12306
12398
|
}),
|
|
12307
|
-
captureBtnText =
|
|
12308
|
-
faceNotCenteredText =
|
|
12399
|
+
captureBtnText = _31.captureBtnText,
|
|
12400
|
+
faceNotCenteredText = _31.faceNotCenteredText;
|
|
12309
12401
|
var debugScalingDetails = useDebugScalingDetails({
|
|
12310
12402
|
enabled: debugMode,
|
|
12311
12403
|
pageWidth: width,
|
|
@@ -12314,8 +12406,6 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12314
12406
|
videoHeight: (_j = (_h = videoRef.current) === null || _h === void 0 ? void 0 : _h.videoHeight) !== null && _j !== void 0 ? _j : 0
|
|
12315
12407
|
});
|
|
12316
12408
|
var capturingId = ['SHOW_ID_FRONT', 'SHOW_ID_BACK'].includes(requestedAction);
|
|
12317
|
-
// const searchingForIdCard =
|
|
12318
|
-
// idCaptureModelsEnabled && capturingId && !goodFramesThresholdMet
|
|
12319
12409
|
var guidanceText = !faceCentered ? faceNotCenteredText : undefined;
|
|
12320
12410
|
return /*#__PURE__*/React__default.createElement(PageContainer, {
|
|
12321
12411
|
ref: ref,
|
|
@@ -12341,15 +12431,14 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12341
12431
|
faceGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor,
|
|
12342
12432
|
idCardGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor
|
|
12343
12433
|
}), debugMode && capturingId && ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ObjectDetectionDebugOverlayDiv, {
|
|
12344
|
-
"$flipX": !
|
|
12434
|
+
"$flipX": !isRearFacing
|
|
12345
12435
|
}, detectedObjects.map(function (obj, i) {
|
|
12346
|
-
var _a;
|
|
12347
12436
|
return /*#__PURE__*/React__default.createElement(IdCaptureDetectedObjectDebugBox, {
|
|
12348
12437
|
key: i,
|
|
12349
12438
|
obj: obj,
|
|
12350
12439
|
scaling: debugScalingDetails,
|
|
12351
12440
|
color: "blue",
|
|
12352
|
-
flipX: !
|
|
12441
|
+
flipX: !isRearFacing
|
|
12353
12442
|
});
|
|
12354
12443
|
})), /*#__PURE__*/React__default.createElement(DebugBoundingBoxOverlay, null, face && ( /*#__PURE__*/React__default.createElement(SelfieCaptureFaceDebugBox, {
|
|
12355
12444
|
face: face,
|
|
@@ -12358,9 +12447,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12358
12447
|
className: classNames.guidanceMessageContainer
|
|
12359
12448
|
}, /*#__PURE__*/React__default.createElement(GuidanceMessage, {
|
|
12360
12449
|
className: classNames.guidanceMessage,
|
|
12361
|
-
"$background": (
|
|
12362
|
-
"$textColor": (
|
|
12363
|
-
}, guidanceText))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null,
|
|
12450
|
+
"$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',
|
|
12451
|
+
"$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'
|
|
12452
|
+
}, guidanceText))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default.createElement("br", null), isRecordingVideo ? '✅ Recording' : '❌ Not recording', /*#__PURE__*/React__default.createElement("br", null), goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', goodFramesCount, "/", goodFramesThreshold, /*#__PURE__*/React__default.createElement("br", null), "Document Type: ", currentDetectedDocumentType, /*#__PURE__*/React__default.createElement("br", null), "Detection Score: ", currentDetectionScore, /*#__PURE__*/React__default.createElement("br", null), "Focus Score: ", currentFocusScore, /*#__PURE__*/React__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__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__default.createElement(CountdownContainer, {
|
|
12364
12453
|
className: classNames.countdownContainer
|
|
12365
12454
|
}, /*#__PURE__*/React__default.createElement(Countdown, {
|
|
12366
12455
|
className: classNames.countdown
|
|
@@ -12369,7 +12458,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12369
12458
|
}, /*#__PURE__*/React__default.createElement(CaptureButton, {
|
|
12370
12459
|
finished: true,
|
|
12371
12460
|
onClick: function onClick() {
|
|
12372
|
-
setCountdownStartedAt(new Date());
|
|
12461
|
+
return setCountdownStartedAt(new Date());
|
|
12373
12462
|
},
|
|
12374
12463
|
disabled: !!countdownStartedAt || frameLock.current,
|
|
12375
12464
|
className: classNames.captureBtn
|
|
@@ -12657,16 +12746,14 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
12657
12746
|
className: "flex"
|
|
12658
12747
|
}, /*#__PURE__*/React__default.createElement(Spinner, null));
|
|
12659
12748
|
}
|
|
12660
|
-
return /*#__PURE__*/React__default.createElement(
|
|
12661
|
-
|
|
12662
|
-
preferContinuityCamera: isCapturingId,
|
|
12749
|
+
return /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
|
|
12750
|
+
preferIphoneContinuityCamera: isCapturingId,
|
|
12663
12751
|
preferFrontFacingCamera: !isCapturingId,
|
|
12664
12752
|
requireMicrophoneAccess: !isCapturingId && !!readTextPrompt,
|
|
12665
12753
|
maxVideoWidth: isCapturingId ? 1920 : 1280,
|
|
12666
12754
|
maxFps: isCapturingId ? 60 : 30,
|
|
12667
12755
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12668
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12669
|
-
debugMode: debugMode
|
|
12756
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12670
12757
|
}, /*#__PURE__*/React__default.createElement(IdCaptureModelsProvider, {
|
|
12671
12758
|
autoStart: false,
|
|
12672
12759
|
documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
|
|
@@ -12677,7 +12764,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
12677
12764
|
autoStart: false,
|
|
12678
12765
|
onModelError: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onModelError,
|
|
12679
12766
|
modelLoadTimeoutMs: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.modelLoadTimeoutMs,
|
|
12680
|
-
requireVerticalFaceCentering:
|
|
12767
|
+
requireVerticalFaceCentering: false
|
|
12681
12768
|
}, /*#__PURE__*/React__default.createElement(PageContainer, {
|
|
12682
12769
|
className: "flex ".concat((_k = classNames.container) !== null && _k !== void 0 ? _k : '')
|
|
12683
12770
|
}, ['CHECKING_LIVENESS', 'CAPTURING_VIDEO'].includes(captureState) && /*#__PURE__*/React__default.createElement(CameraVideoTag, {
|
|
@@ -12792,17 +12879,15 @@ function CompositeWizard(_a) {
|
|
|
12792
12879
|
_o = _a.captureSignatureVideo,
|
|
12793
12880
|
captureSignatureVideo = _o === void 0 ? false : _o,
|
|
12794
12881
|
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
12795
|
-
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied
|
|
12796
|
-
|
|
12797
|
-
|
|
12798
|
-
|
|
12799
|
-
|
|
12800
|
-
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
|
|
12804
|
-
checkIndex = _r[0],
|
|
12805
|
-
setCheckIndex = _r[1];
|
|
12882
|
+
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied;
|
|
12883
|
+
var _p = useContext(SubmissionContext),
|
|
12884
|
+
submit = _p.submit,
|
|
12885
|
+
submissionStatus = _p.submissionStatus,
|
|
12886
|
+
setSignatureData = _p.setSignatureData,
|
|
12887
|
+
setAdditionalDocuments = _p.setAdditionalDocuments;
|
|
12888
|
+
var _q = useState(0),
|
|
12889
|
+
checkIndex = _q[0],
|
|
12890
|
+
setCheckIndex = _q[1];
|
|
12806
12891
|
var checks = useMemo(function () {
|
|
12807
12892
|
var _a, _b;
|
|
12808
12893
|
var checks = __spreadArray([], userChecks, true);
|
|
@@ -12880,16 +12965,6 @@ function CompositeWizard(_a) {
|
|
|
12880
12965
|
return i + 1;
|
|
12881
12966
|
});
|
|
12882
12967
|
}, [onVideoSignatureCompleteProp]);
|
|
12883
|
-
var _s = useState(0),
|
|
12884
|
-
videoSignatureAttempts = _s[0],
|
|
12885
|
-
setVideoSignatureAttempts = _s[1];
|
|
12886
|
-
var onVideoSignatureRetryProp = videoSignatureCaptureProps.onRetryClicked;
|
|
12887
|
-
var onVideoSignatureRetry = useCallback(function () {
|
|
12888
|
-
onVideoSignatureRetryProp === null || onVideoSignatureRetryProp === void 0 ? void 0 : onVideoSignatureRetryProp();
|
|
12889
|
-
setVideoSignatureAttempts(function (n) {
|
|
12890
|
-
return n + 1;
|
|
12891
|
-
});
|
|
12892
|
-
}, [onVideoSignatureRetryProp]);
|
|
12893
12968
|
var onAdditionalDocumentCaptureCompleteProp = additionalDocumentCaptureProps === null || additionalDocumentCaptureProps === void 0 ? void 0 : additionalDocumentCaptureProps.onComplete;
|
|
12894
12969
|
var onAdditionalDocumentCaptureComplete = useCallback(function (uploadedDocuments) {
|
|
12895
12970
|
setAdditionalDocuments(uploadedDocuments);
|
|
@@ -12918,11 +12993,9 @@ function CompositeWizard(_a) {
|
|
|
12918
12993
|
}
|
|
12919
12994
|
switch (checks[checkIndex]) {
|
|
12920
12995
|
case 'IdCapture':
|
|
12921
|
-
return /*#__PURE__*/React__default.createElement(
|
|
12922
|
-
key: "IdCaptureCamera",
|
|
12996
|
+
return /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
|
|
12923
12997
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12924
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12925
|
-
debugMode: debugMode
|
|
12998
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12926
12999
|
}, /*#__PURE__*/React__default.createElement(IdCaptureModelsProvider, {
|
|
12927
13000
|
autoStart: false,
|
|
12928
13001
|
documentDetectionModelUrl: (_d = (_c = idCaptureProps.assets) === null || _c === void 0 ? void 0 : _c.documentDetectionModelUrl) !== null && _d !== void 0 ? _d : '',
|
|
@@ -12939,13 +13012,11 @@ function CompositeWizard(_a) {
|
|
|
12939
13012
|
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12940
13013
|
}));
|
|
12941
13014
|
case 'FaceLiveness':
|
|
12942
|
-
return /*#__PURE__*/React__default.createElement(
|
|
12943
|
-
key: "FaceLivenessCamera",
|
|
13015
|
+
return /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
|
|
12944
13016
|
preferFrontFacingCamera: true,
|
|
12945
|
-
|
|
13017
|
+
preferIphoneContinuityCamera: false,
|
|
12946
13018
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12947
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12948
|
-
debugMode: debugMode
|
|
13019
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12949
13020
|
}, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
|
|
12950
13021
|
autoStart: false,
|
|
12951
13022
|
onModelError: faceLivenessProps.onModelError,
|
|
@@ -12958,15 +13029,13 @@ function CompositeWizard(_a) {
|
|
|
12958
13029
|
onAccept: onSignatureCaptureSuccess
|
|
12959
13030
|
}));
|
|
12960
13031
|
case 'VideoSignatureCapture':
|
|
12961
|
-
return /*#__PURE__*/React__default.createElement(
|
|
12962
|
-
|
|
12963
|
-
preferContinuityCamera: false,
|
|
13032
|
+
return /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
|
|
13033
|
+
preferIphoneContinuityCamera: false,
|
|
12964
13034
|
preferFrontFacingCamera: true,
|
|
12965
13035
|
maxVideoWidth: 1280,
|
|
12966
13036
|
maxFps: 30,
|
|
12967
13037
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12968
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12969
|
-
debugMode: debugMode
|
|
13038
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12970
13039
|
}, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
|
|
12971
13040
|
autoStart: false,
|
|
12972
13041
|
throttleMs: 250,
|
|
@@ -12974,8 +13043,7 @@ function CompositeWizard(_a) {
|
|
|
12974
13043
|
modelLoadTimeoutMs: videoSignatureCaptureProps.modelLoadTimeoutMs,
|
|
12975
13044
|
requireVerticalFaceCentering: false
|
|
12976
13045
|
}, /*#__PURE__*/React__default.createElement(VideoSignatureWizard, _assign({}, videoSignatureCaptureProps, {
|
|
12977
|
-
onComplete: onVideoSignatureComplete
|
|
12978
|
-
onRetryClicked: onVideoSignatureRetry
|
|
13046
|
+
onComplete: onVideoSignatureComplete
|
|
12979
13047
|
}))));
|
|
12980
13048
|
case 'AdditionalDocumentCapture':
|
|
12981
13049
|
return /*#__PURE__*/React__default.createElement(AdditionalDocumentCaptureWizard, _assign({}, additionalDocumentCaptureProps, {
|
|
@@ -13426,8 +13494,7 @@ var IdValidation = function IdValidation(_a) {
|
|
|
13426
13494
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
13427
13495
|
captureSignature: captureSignature,
|
|
13428
13496
|
captureSignatureVideo: captureSignatureVideo,
|
|
13429
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
13430
|
-
debugMode: debugMode
|
|
13497
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
13431
13498
|
}))));
|
|
13432
13499
|
};
|
|
13433
13500
|
|
|
@@ -13533,8 +13600,7 @@ var FaceValidation = function FaceValidation(_a) {
|
|
|
13533
13600
|
return ['FaceLiveness'];
|
|
13534
13601
|
}, []),
|
|
13535
13602
|
faceLivenessProps: faceLivenessProps,
|
|
13536
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
13537
|
-
debugMode: debugMode
|
|
13603
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
13538
13604
|
}))));
|
|
13539
13605
|
};
|
|
13540
13606
|
|
|
@@ -13767,8 +13833,7 @@ var IdAndFaceValidation = function IdAndFaceValidation(_a) {
|
|
|
13767
13833
|
additionalDocumentCaptureProps: additionalDocumentCaptureProps,
|
|
13768
13834
|
captureSignature: captureSignature,
|
|
13769
13835
|
captureSignatureVideo: captureSignatureVideo,
|
|
13770
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
13771
|
-
debugMode: debugMode
|
|
13836
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
13772
13837
|
}))));
|
|
13773
13838
|
};
|
|
13774
13839
|
|
|
@@ -14023,8 +14088,7 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
|
|
|
14023
14088
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
14024
14089
|
captureSignature: captureSignature,
|
|
14025
14090
|
captureSignatureVideo: captureSignatureVideo,
|
|
14026
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
14027
|
-
debugMode: debugMode
|
|
14091
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
14028
14092
|
}))));
|
|
14029
14093
|
};
|
|
14030
14094
|
|
|
@@ -14356,7 +14420,7 @@ var CustomerVerificationWizard = function CustomerVerificationWizard(_a) {
|
|
|
14356
14420
|
var _l = useState('LOADING'),
|
|
14357
14421
|
captureState = _l[0],
|
|
14358
14422
|
setCaptureState = _l[1];
|
|
14359
|
-
var _m =
|
|
14423
|
+
var _m = useCameraStore(),
|
|
14360
14424
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
14361
14425
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
14362
14426
|
var _o = useContext(SelfieGuidanceModelsContext),
|
|
@@ -14562,10 +14626,9 @@ var CustomerVerification = function CustomerVerification(_a) {
|
|
|
14562
14626
|
onSubmit: onSubmit,
|
|
14563
14627
|
geolocationEnabled: geolocationEnabled,
|
|
14564
14628
|
geolocationRequired: geolocationRequired
|
|
14565
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
14629
|
+
}, /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
|
|
14566
14630
|
preferFrontFacingCamera: true,
|
|
14567
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
14568
|
-
debugMode: debugMode
|
|
14631
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
14569
14632
|
}, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
|
|
14570
14633
|
autoStart: false,
|
|
14571
14634
|
onModelError: onModelError,
|
|
@@ -14914,7 +14977,7 @@ var CustomerIdentificationWizard = function CustomerIdentificationWizard(_a) {
|
|
|
14914
14977
|
var _l = useState('LOADING'),
|
|
14915
14978
|
captureState = _l[0],
|
|
14916
14979
|
setCaptureState = _l[1];
|
|
14917
|
-
var _m =
|
|
14980
|
+
var _m = useCameraStore(),
|
|
14918
14981
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
14919
14982
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
14920
14983
|
var _o = useContext(SelfieGuidanceModelsContext),
|
|
@@ -15118,10 +15181,9 @@ var CustomerIdentification = function CustomerIdentification(_a) {
|
|
|
15118
15181
|
onSubmit: onSubmit,
|
|
15119
15182
|
geolocationEnabled: geolocationEnabled,
|
|
15120
15183
|
geolocationRequired: geolocationRequired
|
|
15121
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
15184
|
+
}, /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
|
|
15122
15185
|
preferFrontFacingCamera: true,
|
|
15123
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
15124
|
-
debugMode: debugMode
|
|
15186
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
15125
15187
|
}, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
|
|
15126
15188
|
autoStart: false,
|
|
15127
15189
|
modelLoadTimeoutMs: modelLoadTimeoutMs,
|
|
@@ -15448,8 +15510,7 @@ var VideoIdValidation = function VideoIdValidation(_a) {
|
|
|
15448
15510
|
captureSignature: captureSignature,
|
|
15449
15511
|
captureSignatureVideo: captureSignatureVideo,
|
|
15450
15512
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
15451
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
15452
|
-
debugMode: debugMode
|
|
15513
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
15453
15514
|
}))));
|
|
15454
15515
|
};
|
|
15455
15516
|
|
|
@@ -15606,8 +15667,7 @@ var CustomerBiometricsEnrollment = function CustomerBiometricsEnrollment(_a) {
|
|
|
15606
15667
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
15607
15668
|
captureSignature: captureSignature,
|
|
15608
15669
|
captureSignatureVideo: captureSignatureVideo,
|
|
15609
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
15610
|
-
debugMode: debugMode
|
|
15670
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
15611
15671
|
}))));
|
|
15612
15672
|
};
|
|
15613
15673
|
|
|
@@ -15665,11 +15725,10 @@ var DocumentCapture = function DocumentCapture(_a) {
|
|
|
15665
15725
|
onDocumentUploadFailed: onDocumentUploadFailed,
|
|
15666
15726
|
geolocationEnabled: geolocationEnabled,
|
|
15667
15727
|
geolocationRequired: geolocationRequired
|
|
15668
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
15728
|
+
}, /*#__PURE__*/React__default.createElement(CameraStoreProvider, {
|
|
15669
15729
|
requestAccessAutomatically: false,
|
|
15670
|
-
|
|
15671
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
15672
|
-
debugMode: debugMode
|
|
15730
|
+
preferIphoneContinuityCamera: true,
|
|
15731
|
+
onCameraAccessDenied: onCameraAccessDenied
|
|
15673
15732
|
}, /*#__PURE__*/React__default.createElement(DocumentCaptureWizard, {
|
|
15674
15733
|
onSuccess: onComplete,
|
|
15675
15734
|
onExitCapture: onExitCapture,
|