idmission-web-sdk 2.2.45 → 2.2.47
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 +2 -1
- package/dist/components/CompositeWizard.d.ts.map +1 -1
- package/dist/components/camera/CameraAccessDeniedOverlay.d.ts.map +1 -1
- package/dist/components/camera/CameraProvider.d.ts +17 -0
- package/dist/components/camera/CameraProvider.d.ts.map +1 -0
- package/dist/components/camera/CameraVideoTag.d.ts +4 -2
- 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/submission/SubmissionProvider.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 +0 -4
- package/dist/lib/camera/Camera.d.ts.map +1 -1
- package/dist/lib/models/DocumentDetection.d.ts +1 -3
- package/dist/lib/models/DocumentDetection.d.ts.map +1 -1
- package/dist/lib/models/FaceDetection.d.ts +1 -3
- package/dist/lib/models/FaceDetection.d.ts.map +1 -1
- package/dist/lib/models/Focus.d.ts +1 -3
- package/dist/lib/models/Focus.d.ts.map +1 -1
- package/dist/sdk2.cjs.development.js +1300 -1239
- 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 +1300 -1239
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +1238 -1294
- 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 +4 -5
- package/dist/lib/camera/cameraStore.d.ts +0 -52
- package/dist/lib/camera/cameraStore.d.ts.map +0 -1
- package/dist/lib/camera/videoRefStack.d.ts +0 -6
- package/dist/lib/camera/videoRefStack.d.ts.map +0 -1
package/dist/sdk2.esm.js
CHANGED
|
@@ -8,12 +8,10 @@ import { Upload } from 'tus-js-client';
|
|
|
8
8
|
import SparkMD5 from 'spark-md5';
|
|
9
9
|
import useResizeObserver from 'use-resize-observer';
|
|
10
10
|
import { ImageSegmenter, FilesetResolver, ImageClassifier, FaceDetector, ObjectDetector } from '@mediapipe/tasks-vision';
|
|
11
|
-
import { createStore, useStore } from 'zustand';
|
|
12
11
|
import { useDebouncedCallback, useThrottledCallback } from 'use-debounce';
|
|
13
12
|
import { createPortal } from 'react-dom';
|
|
14
13
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
15
14
|
import i18n from 'i18next';
|
|
16
|
-
import { useShallow } from 'zustand/react/shallow';
|
|
17
15
|
import SignatureCanvas from 'react-signature-canvas';
|
|
18
16
|
|
|
19
17
|
/******************************************************************************
|
|
@@ -203,7 +201,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
203
201
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
204
202
|
};
|
|
205
203
|
|
|
206
|
-
var webSdkVersion = '2.2.
|
|
204
|
+
var webSdkVersion = '2.2.47';
|
|
207
205
|
|
|
208
206
|
function getPlatform() {
|
|
209
207
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -772,11 +770,11 @@ function setDefaultAuthUrl(url) {
|
|
|
772
770
|
if (!allowedAuthUrls.includes(url)) throw new Error('invalid auth url');
|
|
773
771
|
defaultAuthUrl = url;
|
|
774
772
|
}
|
|
775
|
-
var initialState$
|
|
773
|
+
var initialState$5 = {
|
|
776
774
|
authUrl: defaultAuthUrl,
|
|
777
775
|
sessionCheckState: 'READY'
|
|
778
776
|
};
|
|
779
|
-
var AuthStateContext = /*#__PURE__*/createContext(initialState$
|
|
777
|
+
var AuthStateContext = /*#__PURE__*/createContext(initialState$5);
|
|
780
778
|
var AuthDispatchContext = /*#__PURE__*/createContext(function () {});
|
|
781
779
|
var reducer$4 = function reducer(state, action) {
|
|
782
780
|
switch (action.type) {
|
|
@@ -808,7 +806,7 @@ function useAuthReducer(authUrl, sessionId) {
|
|
|
808
806
|
if (authUrl === void 0) {
|
|
809
807
|
authUrl = defaultAuthUrl;
|
|
810
808
|
}
|
|
811
|
-
var _a = useReducer(reducer$4, _assign(_assign({}, initialState$
|
|
809
|
+
var _a = useReducer(reducer$4, _assign(_assign({}, initialState$5), {
|
|
812
810
|
authUrl: authUrl
|
|
813
811
|
})),
|
|
814
812
|
state = _a[0],
|
|
@@ -1321,7 +1319,8 @@ var SubmissionProvider = function SubmissionProvider(_a) {
|
|
|
1321
1319
|
}
|
|
1322
1320
|
};
|
|
1323
1321
|
_e = {
|
|
1324
|
-
filetype: blob.type
|
|
1322
|
+
filetype: blob.type,
|
|
1323
|
+
contentType: blob.type
|
|
1325
1324
|
};
|
|
1326
1325
|
return [4 /*yield*/, calculateMd5(blob)];
|
|
1327
1326
|
case 3:
|
|
@@ -1888,48 +1887,6 @@ function calculateMd5(blob) {
|
|
|
1888
1887
|
});
|
|
1889
1888
|
}
|
|
1890
1889
|
|
|
1891
|
-
var visionTasksBasePath = "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.7/wasm";
|
|
1892
|
-
var visionRuntimePreloading = false;
|
|
1893
|
-
function preloadVisionRuntime() {
|
|
1894
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1895
|
-
function handleDownloadProgress(event) {
|
|
1896
|
-
var detail = event.detail;
|
|
1897
|
-
if (detail.url !== url) return;
|
|
1898
|
-
progressByUseCase.visionRuntime = sumUpProgressForDependencies([url]);
|
|
1899
|
-
document.dispatchEvent(new CustomEvent('idmission.preloadProgress.visionRuntime', {
|
|
1900
|
-
detail: progressByUseCase.visionRuntime
|
|
1901
|
-
}));
|
|
1902
|
-
}
|
|
1903
|
-
var url;
|
|
1904
|
-
return __generator(this, function (_a) {
|
|
1905
|
-
switch (_a.label) {
|
|
1906
|
-
case 0:
|
|
1907
|
-
if (visionRuntimePreloading) return [2 /*return*/, new Promise(function (resolve) {
|
|
1908
|
-
setInterval(function () {
|
|
1909
|
-
if (!visionRuntimePreloading) resolve();
|
|
1910
|
-
}, 100);
|
|
1911
|
-
})];
|
|
1912
|
-
visionRuntimePreloading = true;
|
|
1913
|
-
url = "".concat(visionTasksBasePath, "/vision_wasm_internal.wasm");
|
|
1914
|
-
document.addEventListener('idmission.preloadProgress', handleDownloadProgress);
|
|
1915
|
-
_a.label = 1;
|
|
1916
|
-
case 1:
|
|
1917
|
-
_a.trys.push([1,, 3, 4]);
|
|
1918
|
-
return [4 /*yield*/, preloadDependency(url)];
|
|
1919
|
-
case 2:
|
|
1920
|
-
_a.sent();
|
|
1921
|
-
return [3 /*break*/, 4];
|
|
1922
|
-
case 3:
|
|
1923
|
-
document.removeEventListener('idmission.preloadProgress', handleDownloadProgress);
|
|
1924
|
-
visionRuntimePreloading = false;
|
|
1925
|
-
return [7 /*endfinally*/];
|
|
1926
|
-
case 4:
|
|
1927
|
-
return [2 /*return*/];
|
|
1928
|
-
}
|
|
1929
|
-
});
|
|
1930
|
-
});
|
|
1931
|
-
}
|
|
1932
|
-
|
|
1933
1890
|
function getFrameDimensions(frame) {
|
|
1934
1891
|
var frameWidth = frame.width,
|
|
1935
1892
|
frameHeight = frame.height;
|
|
@@ -1966,219 +1923,827 @@ function clearCanvas(canvas) {
|
|
|
1966
1923
|
}
|
|
1967
1924
|
var templateObject_1$G;
|
|
1968
1925
|
|
|
1969
|
-
function
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
var cropCtx = cropCanvas.getContext('2d');
|
|
1976
|
-
var resizeCtx = resizeCanvas.getContext('2d');
|
|
1977
|
-
if (!rawCtx || !cropCtx || !resizeCtx) throw new Error('could not get 2d context');
|
|
1978
|
-
rawCanvas.width = frame.width;
|
|
1979
|
-
rawCanvas.height = frame.height;
|
|
1980
|
-
rawCtx.putImageData(frame, 0, 0);
|
|
1981
|
-
if (frame.height > frame.width) {
|
|
1982
|
-
cropCanvas.width = frame.width;
|
|
1983
|
-
cropCanvas.height = frame.height;
|
|
1984
|
-
cropCtx.drawImage(rawCanvas, 0, 0, cropCanvas.width, cropCanvas.height);
|
|
1985
|
-
} else {
|
|
1986
|
-
var _a = face.box,
|
|
1987
|
-
xMin = _a.xMin,
|
|
1988
|
-
width = _a.width;
|
|
1989
|
-
var desiredWidth = frame.height * 0.6;
|
|
1990
|
-
var faceCenterX = xMin + width / 2;
|
|
1991
|
-
var xPos = Math.max(0, faceCenterX - desiredWidth / 2);
|
|
1992
|
-
cropCanvas.width = desiredWidth;
|
|
1993
|
-
cropCanvas.height = frame.height;
|
|
1994
|
-
cropCtx.drawImage(rawCanvas, xPos, 0, cropCanvas.width, cropCanvas.height, 0, 0, cropCanvas.width, cropCanvas.height);
|
|
1995
|
-
}
|
|
1996
|
-
resizeCanvas.height = maxHeight !== null && maxHeight !== void 0 ? maxHeight : cropCanvas.height;
|
|
1997
|
-
resizeCanvas.width = cropCanvas.width * (resizeCanvas.height / cropCanvas.height);
|
|
1998
|
-
resizeCtx === null || resizeCtx === void 0 ? void 0 : resizeCtx.drawImage(cropCanvas, 0, 0, resizeCanvas.width, resizeCanvas.height);
|
|
1999
|
-
var dataURL = resizeCanvas.toDataURL('image/jpeg', quality);
|
|
2000
|
-
log('cropToShoulders size', new TextEncoder().encode(dataURL).length);
|
|
2001
|
-
clearCanvas(rawCanvas);
|
|
2002
|
-
clearCanvas(cropCanvas);
|
|
2003
|
-
clearCanvas(resizeCanvas);
|
|
2004
|
-
return dataURL;
|
|
2005
|
-
}
|
|
2006
|
-
function cropToDetectedObjectBox(frame, box, canvas) {
|
|
2007
|
-
canvas || (canvas = document.createElement('canvas'));
|
|
2008
|
-
var ctx = canvas.getContext('2d');
|
|
2009
|
-
if (!ctx) throw new Error('could not get 2d context');
|
|
2010
|
-
var xMin = box.xMin,
|
|
2011
|
-
yMin = box.yMin,
|
|
2012
|
-
width = box.width,
|
|
2013
|
-
height = box.height;
|
|
2014
|
-
canvas.width = width;
|
|
2015
|
-
canvas.height = height;
|
|
2016
|
-
ctx.drawImage(frame, xMin, yMin, width, height, 0, 0, width, height);
|
|
2017
|
-
return canvas;
|
|
2018
|
-
}
|
|
2019
|
-
|
|
2020
|
-
var defaultImageSegmenterModelPath = 'https://websdk-cdn-dev.idmission.com/assets/models/selfiesegmenter20240524/selfie_segmenter.tflite';
|
|
2021
|
-
var imageSegmenterModelSizeInBytes = 256440.32;
|
|
2022
|
-
// The idea here is that we globally set a cache key based on the time at page load. That way our built-in speed test
|
|
2023
|
-
// isn't fooled by cache times, but subsequent downloads of the vision runtime still do load from the cache.
|
|
2024
|
-
var tinyModelCacheKey = new Date().getTime();
|
|
2025
|
-
var initialModelCapabilities = {
|
|
2026
|
-
probeState: 'notProbed',
|
|
2027
|
-
delegate: 'GPU',
|
|
2028
|
-
networkTier: 'untested',
|
|
2029
|
-
networkSpeed: 0,
|
|
2030
|
-
networkTestTime: 0
|
|
2031
|
-
};
|
|
2032
|
-
var modelCapabilities = _assign({}, initialModelCapabilities);
|
|
2033
|
-
function probeModelCapabilities() {
|
|
2034
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2035
|
-
var error_1, error_2;
|
|
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
|
+
}
|
|
2036
1932
|
return __generator(this, function (_a) {
|
|
2037
1933
|
switch (_a.label) {
|
|
2038
1934
|
case 0:
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
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
|
+
];
|
|
2047
1945
|
case 1:
|
|
2048
|
-
_a.sent();
|
|
2049
|
-
|
|
1946
|
+
cameraEnumerationStream = _a.sent();
|
|
1947
|
+
return [4 /*yield*/, navigator.mediaDevices.enumerateDevices()];
|
|
2050
1948
|
case 2:
|
|
2051
|
-
_a.
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
_a.label = 5;
|
|
2063
|
-
case 5:
|
|
2064
|
-
_a.trys.push([5, 7,, 8]);
|
|
2065
|
-
log('Model Probing: testing CPU capabilities...');
|
|
2066
|
-
return [4 /*yield*/, loadTinyModel('CPU')];
|
|
2067
|
-
case 6:
|
|
2068
|
-
_a.sent();
|
|
2069
|
-
log('Model Probing: CPU is capable.');
|
|
2070
|
-
return [3 /*break*/, 8];
|
|
2071
|
-
case 7:
|
|
2072
|
-
error_2 = _a.sent();
|
|
2073
|
-
warn('Model Probing: CPU delegate could not be loaded', error_2);
|
|
2074
|
-
modelCapabilities.delegate = 'NONE';
|
|
2075
|
-
return [3 /*break*/, 8];
|
|
2076
|
-
case 8:
|
|
2077
|
-
return [3 /*break*/, 10];
|
|
2078
|
-
case 9:
|
|
2079
|
-
modelCapabilities.probeState = 'probed';
|
|
2080
|
-
return [7 /*endfinally*/];
|
|
2081
|
-
case 10:
|
|
2082
|
-
return [2 /*return*/];
|
|
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];
|
|
2083
1960
|
}
|
|
2084
1961
|
});
|
|
2085
1962
|
});
|
|
2086
1963
|
}
|
|
2087
|
-
function
|
|
2088
|
-
return
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
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 = '';
|
|
2092
2002
|
}
|
|
2093
|
-
|
|
2094
|
-
|
|
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);
|
|
2095
2102
|
}
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
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
|
|
2474
|
+
});
|
|
2475
|
+
useEffect(function () {
|
|
2476
|
+
if (captureDevice.cameraAccessDenied) onCameraAccessDenied === null || onCameraAccessDenied === void 0 ? void 0 : onCameraAccessDenied();
|
|
2477
|
+
}, [captureDevice.cameraAccessDenied, onCameraAccessDenied]);
|
|
2478
|
+
useEffect(function () {
|
|
2479
|
+
if (captureDevice.microphoneAccessDenied) onMicrophoneAccessDenied === null || onMicrophoneAccessDenied === void 0 ? void 0 : onMicrophoneAccessDenied();
|
|
2480
|
+
}, [captureDevice.microphoneAccessDenied, onMicrophoneAccessDenied]);
|
|
2481
|
+
var releaseCameraAccess = captureDevice.releaseCameraAccess;
|
|
2482
|
+
useEffect(function () {
|
|
2483
|
+
return function () {
|
|
2484
|
+
releaseCameraAccess();
|
|
2485
|
+
};
|
|
2486
|
+
}, [releaseCameraAccess]);
|
|
2487
|
+
return /*#__PURE__*/React__default.createElement(CameraStateContext.Provider, {
|
|
2488
|
+
value: captureDevice
|
|
2489
|
+
}, children);
|
|
2490
|
+
};
|
|
2491
|
+
|
|
2492
|
+
var visionTasksBasePath = "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.7/wasm";
|
|
2493
|
+
var visionRuntimePreloading = false;
|
|
2494
|
+
function preloadVisionRuntime() {
|
|
2495
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2496
|
+
function handleDownloadProgress(event) {
|
|
2497
|
+
var detail = event.detail;
|
|
2498
|
+
if (detail.url !== url) return;
|
|
2499
|
+
progressByUseCase.visionRuntime = sumUpProgressForDependencies([url]);
|
|
2500
|
+
document.dispatchEvent(new CustomEvent('idmission.preloadProgress.visionRuntime', {
|
|
2501
|
+
detail: progressByUseCase.visionRuntime
|
|
2502
|
+
}));
|
|
2503
|
+
}
|
|
2504
|
+
var url;
|
|
2505
|
+
return __generator(this, function (_a) {
|
|
2506
|
+
switch (_a.label) {
|
|
2507
|
+
case 0:
|
|
2508
|
+
if (visionRuntimePreloading) return [2 /*return*/, new Promise(function (resolve) {
|
|
2509
|
+
setInterval(function () {
|
|
2510
|
+
if (!visionRuntimePreloading) resolve();
|
|
2511
|
+
}, 100);
|
|
2512
|
+
})];
|
|
2513
|
+
visionRuntimePreloading = true;
|
|
2514
|
+
url = "".concat(visionTasksBasePath, "/vision_wasm_internal.wasm");
|
|
2515
|
+
document.addEventListener('idmission.preloadProgress', handleDownloadProgress);
|
|
2516
|
+
_a.label = 1;
|
|
2102
2517
|
case 1:
|
|
2103
|
-
|
|
2104
|
-
return [4 /*yield*/,
|
|
2518
|
+
_a.trys.push([1,, 3, 4]);
|
|
2519
|
+
return [4 /*yield*/, preloadDependency(url)];
|
|
2105
2520
|
case 2:
|
|
2106
|
-
|
|
2521
|
+
_a.sent();
|
|
2107
2522
|
return [3 /*break*/, 4];
|
|
2108
2523
|
case 3:
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
return [2 /*return*/];
|
|
2524
|
+
document.removeEventListener('idmission.preloadProgress', handleDownloadProgress);
|
|
2525
|
+
visionRuntimePreloading = false;
|
|
2526
|
+
return [7 /*endfinally*/];
|
|
2113
2527
|
case 4:
|
|
2114
|
-
time = (new Date().getTime() - startedAt.getTime()) / 1000.0;
|
|
2115
|
-
modelCapabilities.networkTestTime || (modelCapabilities.networkTestTime = time);
|
|
2116
|
-
modelCapabilities.networkSpeed || (modelCapabilities.networkSpeed = imageSegmenterModelSizeInBytes / time);
|
|
2117
|
-
modelCapabilities.networkTier = time < 0.5 ? 'fast' : time < 2 ? 'medium' : 'slow';
|
|
2118
|
-
speedMbps = modelCapabilities.networkSpeed / 1024 / 1024;
|
|
2119
|
-
log('Model Probing: network speed', speedMbps.toFixed(3), 'Mbps');
|
|
2120
|
-
log('Model Probing: network test took', time);
|
|
2121
|
-
log('Model Probing: network tier', modelCapabilities.networkTier);
|
|
2122
|
-
_b = (_a = ImageSegmenter).createFromOptions;
|
|
2123
|
-
return [4 /*yield*/, FilesetResolver.forVisionTasks(visionTasksBasePath)];
|
|
2124
|
-
case 5:
|
|
2125
|
-
return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
|
|
2126
|
-
baseOptions: {
|
|
2127
|
-
modelAssetPath: modelAssetPath,
|
|
2128
|
-
delegate: delegate
|
|
2129
|
-
}
|
|
2130
|
-
}])];
|
|
2131
|
-
case 6:
|
|
2132
|
-
model = _c.sent();
|
|
2133
|
-
emptyFrame = document.createElement('canvas');
|
|
2134
|
-
model.segment(emptyFrame);
|
|
2135
|
-
emptyFrame.remove();
|
|
2136
2528
|
return [2 /*return*/];
|
|
2137
2529
|
}
|
|
2138
2530
|
});
|
|
2139
2531
|
});
|
|
2140
2532
|
}
|
|
2141
|
-
function giveUpAfter(maxTime) {
|
|
2142
|
-
return new Promise(function (_resolve, reject) {
|
|
2143
|
-
setTimeout(function () {
|
|
2144
|
-
reject(new Error('gave up after reaching maximum time allowed'));
|
|
2145
|
-
}, maxTime);
|
|
2146
|
-
});
|
|
2147
|
-
}
|
|
2148
2533
|
|
|
2149
|
-
function
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
xMin: (_a = box === null || box === void 0 ? void 0 : box.originX) !== null && _a !== void 0 ? _a : 0,
|
|
2153
|
-
xMax: ((_b = box === null || box === void 0 ? void 0 : box.originX) !== null && _b !== void 0 ? _b : 0) + ((_c = box === null || box === void 0 ? void 0 : box.width) !== null && _c !== void 0 ? _c : 0),
|
|
2154
|
-
yMin: (_d = box === null || box === void 0 ? void 0 : box.originY) !== null && _d !== void 0 ? _d : 0,
|
|
2155
|
-
yMax: ((_e = box === null || box === void 0 ? void 0 : box.originY) !== null && _e !== void 0 ? _e : 0) + ((_f = box === null || box === void 0 ? void 0 : box.height) !== null && _f !== void 0 ? _f : 0),
|
|
2156
|
-
width: (_g = box === null || box === void 0 ? void 0 : box.width) !== null && _g !== void 0 ? _g : 0,
|
|
2157
|
-
height: (_h = box === null || box === void 0 ? void 0 : box.height) !== null && _h !== void 0 ? _h : 0
|
|
2158
|
-
};
|
|
2159
|
-
}
|
|
2160
|
-
function waitForVideoReady(videoRef, checkEveryMs) {
|
|
2161
|
-
if (checkEveryMs === void 0) {
|
|
2162
|
-
checkEveryMs = 100;
|
|
2534
|
+
function cropToShoulders(rawCanvas, cropCanvas, resizeCanvas, frame, face, quality, maxHeight) {
|
|
2535
|
+
if (quality === void 0) {
|
|
2536
|
+
quality = 0.92;
|
|
2163
2537
|
}
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
}
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2538
|
+
if (!rawCanvas || !cropCanvas || !resizeCanvas) return '';
|
|
2539
|
+
var rawCtx = rawCanvas.getContext('2d');
|
|
2540
|
+
var cropCtx = cropCanvas.getContext('2d');
|
|
2541
|
+
var resizeCtx = resizeCanvas.getContext('2d');
|
|
2542
|
+
if (!rawCtx || !cropCtx || !resizeCtx) throw new Error('could not get 2d context');
|
|
2543
|
+
rawCanvas.width = frame.width;
|
|
2544
|
+
rawCanvas.height = frame.height;
|
|
2545
|
+
rawCtx.putImageData(frame, 0, 0);
|
|
2546
|
+
if (frame.height > frame.width) {
|
|
2547
|
+
cropCanvas.width = frame.width;
|
|
2548
|
+
cropCanvas.height = frame.height;
|
|
2549
|
+
cropCtx.drawImage(rawCanvas, 0, 0, cropCanvas.width, cropCanvas.height);
|
|
2550
|
+
} else {
|
|
2551
|
+
var _a = face.box,
|
|
2552
|
+
xMin = _a.xMin,
|
|
2553
|
+
width = _a.width;
|
|
2554
|
+
var desiredWidth = frame.height * 0.6;
|
|
2555
|
+
var faceCenterX = xMin + width / 2;
|
|
2556
|
+
var xPos = Math.max(0, faceCenterX - desiredWidth / 2);
|
|
2557
|
+
cropCanvas.width = desiredWidth;
|
|
2558
|
+
cropCanvas.height = frame.height;
|
|
2559
|
+
cropCtx.drawImage(rawCanvas, xPos, 0, cropCanvas.width, cropCanvas.height, 0, 0, cropCanvas.width, cropCanvas.height);
|
|
2560
|
+
}
|
|
2561
|
+
resizeCanvas.height = maxHeight !== null && maxHeight !== void 0 ? maxHeight : cropCanvas.height;
|
|
2562
|
+
resizeCanvas.width = cropCanvas.width * (resizeCanvas.height / cropCanvas.height);
|
|
2563
|
+
resizeCtx === null || resizeCtx === void 0 ? void 0 : resizeCtx.drawImage(cropCanvas, 0, 0, resizeCanvas.width, resizeCanvas.height);
|
|
2564
|
+
var dataURL = resizeCanvas.toDataURL('image/jpeg', quality);
|
|
2565
|
+
log('cropToShoulders size', new TextEncoder().encode(dataURL).length);
|
|
2566
|
+
clearCanvas(rawCanvas);
|
|
2567
|
+
clearCanvas(cropCanvas);
|
|
2568
|
+
clearCanvas(resizeCanvas);
|
|
2569
|
+
return dataURL;
|
|
2570
|
+
}
|
|
2571
|
+
function cropToDetectedObjectBox(frame, box, canvas) {
|
|
2572
|
+
canvas || (canvas = document.createElement('canvas'));
|
|
2573
|
+
var ctx = canvas.getContext('2d');
|
|
2574
|
+
if (!ctx) throw new Error('could not get 2d context');
|
|
2575
|
+
var xMin = box.xMin,
|
|
2576
|
+
yMin = box.yMin,
|
|
2577
|
+
width = box.width,
|
|
2578
|
+
height = box.height;
|
|
2579
|
+
canvas.width = width;
|
|
2580
|
+
canvas.height = height;
|
|
2581
|
+
ctx.drawImage(frame, xMin, yMin, width, height, 0, 0, width, height);
|
|
2582
|
+
return canvas;
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
var defaultImageSegmenterModelPath = 'https://websdk-cdn-dev.idmission.com/assets/models/selfiesegmenter20240524/selfie_segmenter.tflite';
|
|
2586
|
+
var imageSegmenterModelSizeInBytes = 256440.32;
|
|
2587
|
+
// The idea here is that we globally set a cache key based on the time at page load. That way our built-in speed test
|
|
2588
|
+
// isn't fooled by cache times, but subsequent downloads of the vision runtime still do load from the cache.
|
|
2589
|
+
var tinyModelCacheKey = new Date().getTime();
|
|
2590
|
+
var initialModelCapabilities = {
|
|
2591
|
+
probeState: 'notProbed',
|
|
2592
|
+
delegate: 'GPU',
|
|
2593
|
+
networkTier: 'untested',
|
|
2594
|
+
networkSpeed: 0,
|
|
2595
|
+
networkTestTime: 0
|
|
2596
|
+
};
|
|
2597
|
+
var modelCapabilities = _assign({}, initialModelCapabilities);
|
|
2598
|
+
function probeModelCapabilities() {
|
|
2599
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2600
|
+
var error_1, error_2;
|
|
2601
|
+
return __generator(this, function (_a) {
|
|
2602
|
+
switch (_a.label) {
|
|
2603
|
+
case 0:
|
|
2604
|
+
if (modelCapabilities.probeState === 'probed') return [2 /*return*/];
|
|
2605
|
+
if (modelCapabilities.probeState === 'probing') return [2 /*return*/, new Promise(function (resolve) {
|
|
2606
|
+
setInterval(function () {
|
|
2607
|
+
if (modelCapabilities.probeState === 'probed') resolve();
|
|
2608
|
+
}, 100);
|
|
2609
|
+
})];
|
|
2610
|
+
modelCapabilities.probeState = 'probing';
|
|
2611
|
+
return [4 /*yield*/, preloadVisionRuntime()];
|
|
2612
|
+
case 1:
|
|
2613
|
+
_a.sent();
|
|
2614
|
+
_a.label = 2;
|
|
2615
|
+
case 2:
|
|
2616
|
+
_a.trys.push([2, 4, 9, 10]);
|
|
2617
|
+
log('Model Probing: testing GPU capabilities...');
|
|
2618
|
+
return [4 /*yield*/, loadTinyModel('GPU')];
|
|
2619
|
+
case 3:
|
|
2620
|
+
_a.sent();
|
|
2621
|
+
log('Model Probing: GPU is capable.');
|
|
2622
|
+
return [3 /*break*/, 10];
|
|
2623
|
+
case 4:
|
|
2624
|
+
error_1 = _a.sent();
|
|
2625
|
+
warn('Model Probing: GPU delegate could not be loaded', error_1);
|
|
2626
|
+
modelCapabilities.delegate = 'CPU';
|
|
2627
|
+
_a.label = 5;
|
|
2628
|
+
case 5:
|
|
2629
|
+
_a.trys.push([5, 7,, 8]);
|
|
2630
|
+
log('Model Probing: testing CPU capabilities...');
|
|
2631
|
+
return [4 /*yield*/, loadTinyModel('CPU')];
|
|
2632
|
+
case 6:
|
|
2633
|
+
_a.sent();
|
|
2634
|
+
log('Model Probing: CPU is capable.');
|
|
2635
|
+
return [3 /*break*/, 8];
|
|
2636
|
+
case 7:
|
|
2637
|
+
error_2 = _a.sent();
|
|
2638
|
+
warn('Model Probing: CPU delegate could not be loaded', error_2);
|
|
2639
|
+
modelCapabilities.delegate = 'NONE';
|
|
2640
|
+
return [3 /*break*/, 8];
|
|
2641
|
+
case 8:
|
|
2642
|
+
return [3 /*break*/, 10];
|
|
2643
|
+
case 9:
|
|
2644
|
+
modelCapabilities.probeState = 'probed';
|
|
2645
|
+
return [7 /*endfinally*/];
|
|
2646
|
+
case 10:
|
|
2647
|
+
return [2 /*return*/];
|
|
2648
|
+
}
|
|
2649
|
+
});
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
function loadTinyModel() {
|
|
2653
|
+
return __awaiter(this, arguments, void 0, function (delegate, maxTime) {
|
|
2654
|
+
var modelAssetPath, startedAt, e_1, time, speedMbps, model, _a, _b, emptyFrame;
|
|
2655
|
+
if (delegate === void 0) {
|
|
2656
|
+
delegate = 'GPU';
|
|
2657
|
+
}
|
|
2658
|
+
if (maxTime === void 0) {
|
|
2659
|
+
maxTime = 10000;
|
|
2660
|
+
}
|
|
2661
|
+
return __generator(this, function (_c) {
|
|
2662
|
+
switch (_c.label) {
|
|
2663
|
+
case 0:
|
|
2664
|
+
modelAssetPath = "".concat(defaultImageSegmenterModelPath, "?_=").concat(tinyModelCacheKey);
|
|
2665
|
+
startedAt = new Date();
|
|
2666
|
+
_c.label = 1;
|
|
2667
|
+
case 1:
|
|
2668
|
+
_c.trys.push([1, 3,, 4]);
|
|
2669
|
+
return [4 /*yield*/, Promise.race([preloadDependency(modelAssetPath), giveUpAfter(maxTime)])];
|
|
2670
|
+
case 2:
|
|
2671
|
+
_c.sent();
|
|
2672
|
+
return [3 /*break*/, 4];
|
|
2673
|
+
case 3:
|
|
2674
|
+
e_1 = _c.sent();
|
|
2675
|
+
error('speed test failed', e_1);
|
|
2676
|
+
modelCapabilities.networkTier = 'unusable';
|
|
2677
|
+
return [2 /*return*/];
|
|
2678
|
+
case 4:
|
|
2679
|
+
time = (new Date().getTime() - startedAt.getTime()) / 1000.0;
|
|
2680
|
+
modelCapabilities.networkTestTime || (modelCapabilities.networkTestTime = time);
|
|
2681
|
+
modelCapabilities.networkSpeed || (modelCapabilities.networkSpeed = imageSegmenterModelSizeInBytes / time);
|
|
2682
|
+
modelCapabilities.networkTier = time < 0.5 ? 'fast' : time < 2 ? 'medium' : 'slow';
|
|
2683
|
+
speedMbps = modelCapabilities.networkSpeed / 1024 / 1024;
|
|
2684
|
+
log('Model Probing: network speed', speedMbps.toFixed(3), 'Mbps');
|
|
2685
|
+
log('Model Probing: network test took', time);
|
|
2686
|
+
log('Model Probing: network tier', modelCapabilities.networkTier);
|
|
2687
|
+
_b = (_a = ImageSegmenter).createFromOptions;
|
|
2688
|
+
return [4 /*yield*/, FilesetResolver.forVisionTasks(visionTasksBasePath)];
|
|
2689
|
+
case 5:
|
|
2690
|
+
return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
|
|
2691
|
+
baseOptions: {
|
|
2692
|
+
modelAssetPath: modelAssetPath,
|
|
2693
|
+
delegate: delegate
|
|
2694
|
+
}
|
|
2695
|
+
}])];
|
|
2696
|
+
case 6:
|
|
2697
|
+
model = _c.sent();
|
|
2698
|
+
emptyFrame = document.createElement('canvas');
|
|
2699
|
+
model.segment(emptyFrame);
|
|
2700
|
+
emptyFrame.remove();
|
|
2701
|
+
return [2 /*return*/];
|
|
2702
|
+
}
|
|
2703
|
+
});
|
|
2704
|
+
});
|
|
2705
|
+
}
|
|
2706
|
+
function giveUpAfter(maxTime) {
|
|
2707
|
+
return new Promise(function (_resolve, reject) {
|
|
2708
|
+
setTimeout(function () {
|
|
2709
|
+
reject(new Error('gave up after reaching maximum time allowed'));
|
|
2710
|
+
}, maxTime);
|
|
2711
|
+
});
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
function convertBoundingBox(box) {
|
|
2715
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2716
|
+
return {
|
|
2717
|
+
xMin: (_a = box === null || box === void 0 ? void 0 : box.originX) !== null && _a !== void 0 ? _a : 0,
|
|
2718
|
+
xMax: ((_b = box === null || box === void 0 ? void 0 : box.originX) !== null && _b !== void 0 ? _b : 0) + ((_c = box === null || box === void 0 ? void 0 : box.width) !== null && _c !== void 0 ? _c : 0),
|
|
2719
|
+
yMin: (_d = box === null || box === void 0 ? void 0 : box.originY) !== null && _d !== void 0 ? _d : 0,
|
|
2720
|
+
yMax: ((_e = box === null || box === void 0 ? void 0 : box.originY) !== null && _e !== void 0 ? _e : 0) + ((_f = box === null || box === void 0 ? void 0 : box.height) !== null && _f !== void 0 ? _f : 0),
|
|
2721
|
+
width: (_g = box === null || box === void 0 ? void 0 : box.width) !== null && _g !== void 0 ? _g : 0,
|
|
2722
|
+
height: (_h = box === null || box === void 0 ? void 0 : box.height) !== null && _h !== void 0 ? _h : 0
|
|
2723
|
+
};
|
|
2724
|
+
}
|
|
2725
|
+
function waitForVideoReady(videoRef, checkEveryMs) {
|
|
2726
|
+
if (checkEveryMs === void 0) {
|
|
2727
|
+
checkEveryMs = 100;
|
|
2728
|
+
}
|
|
2729
|
+
return new Promise(function (resolve) {
|
|
2730
|
+
var _a, _b, _c;
|
|
2731
|
+
if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) return resolve();
|
|
2732
|
+
(_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.load();
|
|
2733
|
+
var interval = setInterval(function () {
|
|
2734
|
+
var _a, _b;
|
|
2735
|
+
if (((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.readyState) !== null && _b !== void 0 ? _b : 0) >= 2) {
|
|
2736
|
+
clearInterval(interval);
|
|
2737
|
+
resolve();
|
|
2738
|
+
}
|
|
2739
|
+
}, checkEveryMs);
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2742
|
+
function calculateIoU(boxA, boxB) {
|
|
2743
|
+
var xA = Math.max(boxA.xMin, boxB.xMin);
|
|
2744
|
+
var yA = Math.max(boxA.yMin, boxB.yMin);
|
|
2745
|
+
var xB = Math.min(boxA.xMax, boxB.xMax);
|
|
2746
|
+
var yB = Math.min(boxA.yMax, boxB.yMax);
|
|
2182
2747
|
var intersectWidth = Math.max(0, xB - xA);
|
|
2183
2748
|
var intersectHeight = Math.max(0, yB - yA);
|
|
2184
2749
|
var intersectionArea = intersectWidth * intersectHeight;
|
|
@@ -2269,8 +2834,7 @@ function useLoadFocusModel(_a) {
|
|
|
2269
2834
|
modelPath = _b === void 0 ? defaultFocusModelPath : _b,
|
|
2270
2835
|
_c = _a.modelLoadTimeoutMs,
|
|
2271
2836
|
modelLoadTimeoutMs = _c === void 0 ? defaultFocusModelLoadTimeoutMs : _c,
|
|
2272
|
-
onModelError = _a.onModelError
|
|
2273
|
-
videoRef = _a.videoRef;
|
|
2837
|
+
onModelError = _a.onModelError;
|
|
2274
2838
|
var _d = useState(false),
|
|
2275
2839
|
ready = _d[0],
|
|
2276
2840
|
setReady = _d[1];
|
|
@@ -2280,6 +2844,7 @@ function useLoadFocusModel(_a) {
|
|
|
2280
2844
|
var _f = useState(null),
|
|
2281
2845
|
modelError = _f[0],
|
|
2282
2846
|
setModelError = _f[1];
|
|
2847
|
+
var videoRef = useContext(CameraStateContext).videoRef;
|
|
2283
2848
|
useEffect(function loadModel() {
|
|
2284
2849
|
var _this = this;
|
|
2285
2850
|
setReady(false);
|
|
@@ -2417,8 +2982,7 @@ function closeFaceDetector() {
|
|
|
2417
2982
|
function useLoadFaceDetector(_a) {
|
|
2418
2983
|
var onModelError = _a.onModelError,
|
|
2419
2984
|
_b = _a.modelLoadTimeoutMs,
|
|
2420
|
-
modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b
|
|
2421
|
-
videoRef = _a.videoRef;
|
|
2985
|
+
modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b;
|
|
2422
2986
|
var _c = useState(false),
|
|
2423
2987
|
ready = _c[0],
|
|
2424
2988
|
setReady = _c[1];
|
|
@@ -2428,6 +2992,7 @@ function useLoadFaceDetector(_a) {
|
|
|
2428
2992
|
var _e = useState(null),
|
|
2429
2993
|
modelError = _e[0],
|
|
2430
2994
|
setModelError = _e[1];
|
|
2995
|
+
var videoRef = useContext(CameraStateContext).videoRef;
|
|
2431
2996
|
useEffect(function loadModel() {
|
|
2432
2997
|
var _this = this;
|
|
2433
2998
|
setReady(false);
|
|
@@ -2908,8 +3473,7 @@ function useLoadDocumentDetector(_a) {
|
|
|
2908
3473
|
modelLoadTimeoutMs = _c === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _c,
|
|
2909
3474
|
_d = _a.scoreThreshold,
|
|
2910
3475
|
scoreThreshold = _d === void 0 ? defaultDocumentDetectionScoreThreshold : _d,
|
|
2911
|
-
onModelError = _a.onModelError
|
|
2912
|
-
videoRef = _a.videoRef;
|
|
3476
|
+
onModelError = _a.onModelError;
|
|
2913
3477
|
var _e = useState(false),
|
|
2914
3478
|
ready = _e[0],
|
|
2915
3479
|
setReady = _e[1];
|
|
@@ -2919,6 +3483,7 @@ function useLoadDocumentDetector(_a) {
|
|
|
2919
3483
|
var _g = useState(null),
|
|
2920
3484
|
modelError = _g[0],
|
|
2921
3485
|
setModelError = _g[1];
|
|
3486
|
+
var videoRef = useContext(CameraStateContext).videoRef;
|
|
2922
3487
|
useEffect(function loadModel() {
|
|
2923
3488
|
var _this = this;
|
|
2924
3489
|
setReady(false);
|
|
@@ -3135,582 +3700,96 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
|
|
|
3135
3700
|
idCardFrontDetectionThresholdMet: idCardFrontDetectionThresholdMet,
|
|
3136
3701
|
idCardBackDetectionScore: idCardBackDetectionScore,
|
|
3137
3702
|
idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
|
|
3138
|
-
passportDetectionScore: passportDetectionScore,
|
|
3139
|
-
passportDetectionThresholdMet: passportDetectionThresholdMet,
|
|
3140
|
-
bestDocument: bestDocument,
|
|
3141
|
-
documentInBounds: documentInBounds,
|
|
3142
|
-
documentTooClose: documentTooClose,
|
|
3143
|
-
documentIsStable: documentIsStable,
|
|
3144
|
-
frameWidth: frameWidth,
|
|
3145
|
-
frameHeight: frameHeight,
|
|
3146
|
-
allZero: allZero
|
|
3147
|
-
};
|
|
3148
|
-
}
|
|
3149
|
-
function applyNonMaxSuppression(detectedObjects, isGoodBox) {
|
|
3150
|
-
var maxes = {};
|
|
3151
|
-
detectedObjects.forEach(function (obj, i) {
|
|
3152
|
-
if (obj) {
|
|
3153
|
-
if (!maxes[obj.label]) maxes[obj.label] = [0, -1];
|
|
3154
|
-
if (obj.score > maxes[obj.label][0] && (isGoodBox === null || isGoodBox === void 0 ? void 0 : isGoodBox(obj))) maxes[obj.label] = [obj.score, i];
|
|
3155
|
-
}
|
|
3156
|
-
});
|
|
3157
|
-
return Object.keys(maxes).map(function (label) {
|
|
3158
|
-
return detectedObjects[maxes[label][1]];
|
|
3159
|
-
}).filter(function (obj) {
|
|
3160
|
-
return !!obj;
|
|
3161
|
-
});
|
|
3162
|
-
}
|
|
3163
|
-
|
|
3164
|
-
function useFrameLoop(fn, _a) {
|
|
3165
|
-
var _b = _a.throttleMs,
|
|
3166
|
-
throttleMs = _b === void 0 ? 0 : _b,
|
|
3167
|
-
_c = _a.autoStart,
|
|
3168
|
-
autoStart = _c === void 0 ? false : _c;
|
|
3169
|
-
var _d = useState(false),
|
|
3170
|
-
running = _d[0],
|
|
3171
|
-
setRunning = _d[1];
|
|
3172
|
-
var startedAtRef = useRef(null);
|
|
3173
|
-
var loopId = useRef(0);
|
|
3174
|
-
var frameId = useRef(0);
|
|
3175
|
-
useEffect(function runFrameLoop() {
|
|
3176
|
-
if (!running) return;
|
|
3177
|
-
var timer;
|
|
3178
|
-
var currentLoopId = loopId.current;
|
|
3179
|
-
function renderPrediction() {
|
|
3180
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3181
|
-
var start, timeRunning, took, amountToThrottle;
|
|
3182
|
-
var _a, _b;
|
|
3183
|
-
return __generator(this, function (_c) {
|
|
3184
|
-
switch (_c.label) {
|
|
3185
|
-
case 0:
|
|
3186
|
-
if (currentLoopId !== loopId.current) return [2 /*return*/];
|
|
3187
|
-
start = new Date().getTime();
|
|
3188
|
-
timeRunning = start - ((_b = (_a = startedAtRef.current) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0);
|
|
3189
|
-
return [4 /*yield*/, fn(frameId.current, timeRunning)];
|
|
3190
|
-
case 1:
|
|
3191
|
-
_c.sent();
|
|
3192
|
-
took = new Date().getTime() - start;
|
|
3193
|
-
amountToThrottle = Math.max((throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0) - took, 0);
|
|
3194
|
-
timer = setTimeout(function () {
|
|
3195
|
-
frameId.current = requestAnimationFrame(renderPrediction);
|
|
3196
|
-
}, amountToThrottle);
|
|
3197
|
-
return [2 /*return*/];
|
|
3198
|
-
}
|
|
3199
|
-
});
|
|
3200
|
-
});
|
|
3201
|
-
}
|
|
3202
|
-
renderPrediction().then();
|
|
3203
|
-
return function () {
|
|
3204
|
-
loopId.current += 1;
|
|
3205
|
-
frameId.current && cancelAnimationFrame(frameId.current);
|
|
3206
|
-
timer && clearTimeout(timer);
|
|
3207
|
-
};
|
|
3208
|
-
}, [fn, running, throttleMs]);
|
|
3209
|
-
var start = useCallback(function () {
|
|
3210
|
-
startedAtRef.current = new Date();
|
|
3211
|
-
setRunning(true);
|
|
3212
|
-
}, []);
|
|
3213
|
-
var stop = useCallback(function () {
|
|
3214
|
-
loopId.current += 1; // force the loop to stop immediately.
|
|
3215
|
-
setRunning(false);
|
|
3216
|
-
startedAtRef.current = null;
|
|
3217
|
-
}, []);
|
|
3218
|
-
useEffect(function startAutomatically() {
|
|
3219
|
-
if (autoStart) start();
|
|
3220
|
-
return function () {
|
|
3221
|
-
stop();
|
|
3222
|
-
};
|
|
3223
|
-
}, [autoStart, start, stop]);
|
|
3224
|
-
return {
|
|
3225
|
-
start: start,
|
|
3226
|
-
stop: stop
|
|
3227
|
-
};
|
|
3228
|
-
}
|
|
3229
|
-
|
|
3230
|
-
function listAvailableCameras(facingMode_1) {
|
|
3231
|
-
return __awaiter(this, arguments, void 0, function (facingMode, requestMicAccess) {
|
|
3232
|
-
var cameraEnumerationStream, videoDevices;
|
|
3233
|
-
if (requestMicAccess === void 0) {
|
|
3234
|
-
requestMicAccess = false;
|
|
3235
|
-
}
|
|
3236
|
-
return __generator(this, function (_a) {
|
|
3237
|
-
switch (_a.label) {
|
|
3238
|
-
case 0:
|
|
3239
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3240
|
-
video: {
|
|
3241
|
-
facingMode: {
|
|
3242
|
-
exact: facingMode
|
|
3243
|
-
}
|
|
3244
|
-
},
|
|
3245
|
-
audio: requestMicAccess
|
|
3246
|
-
})
|
|
3247
|
-
// This lists all available cameras attached to the user's device.
|
|
3248
|
-
];
|
|
3249
|
-
case 1:
|
|
3250
|
-
cameraEnumerationStream = _a.sent();
|
|
3251
|
-
return [4 /*yield*/, navigator.mediaDevices.enumerateDevices()];
|
|
3252
|
-
case 2:
|
|
3253
|
-
videoDevices = _a.sent().filter(function (_a) {
|
|
3254
|
-
var kind = _a.kind;
|
|
3255
|
-
return kind === 'videoinput';
|
|
3256
|
-
});
|
|
3257
|
-
// Release the access to the user's camera that we obtained for enumeration purposes.
|
|
3258
|
-
cameraEnumerationStream.getVideoTracks().forEach(function (track) {
|
|
3259
|
-
track.enabled = false;
|
|
3260
|
-
track.stop();
|
|
3261
|
-
});
|
|
3262
|
-
cameraEnumerationStream = null;
|
|
3263
|
-
return [2 /*return*/, videoDevices];
|
|
3264
|
-
}
|
|
3265
|
-
});
|
|
3266
|
-
});
|
|
3267
|
-
}
|
|
3268
|
-
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) {
|
|
3269
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
3270
|
-
});
|
|
3271
|
-
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) {
|
|
3272
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
3273
|
-
});
|
|
3274
|
-
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) {
|
|
3275
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
3276
|
-
});
|
|
3277
|
-
var cameraLabelMatches = function cameraLabelMatches(labelOrDevice, labelSetOrLabel) {
|
|
3278
|
-
var label = labelOrDevice instanceof MediaDeviceInfo ? getDeviceLabel(labelOrDevice) : labelOrDevice;
|
|
3279
|
-
var labelSet = typeof labelSetOrLabel === 'string' ? [labelSetOrLabel] : labelSetOrLabel;
|
|
3280
|
-
return labelSet.some(function (l) {
|
|
3281
|
-
return label.includes(l);
|
|
3282
|
-
});
|
|
3283
|
-
};
|
|
3284
|
-
var getDeviceLabel = function getDeviceLabel(deviceInfo) {
|
|
3285
|
-
return deviceInfo.label.toLocaleLowerCase().split(' ').join('');
|
|
3286
|
-
};
|
|
3287
|
-
var currentCamera;
|
|
3288
|
-
function obtainCameraAccess(stream, deviceLabel, video) {
|
|
3289
|
-
releaseCameraAccess();
|
|
3290
|
-
log('obtaining camera access...');
|
|
3291
|
-
var _a = stream.getVideoTracks()[0].getSettings(),
|
|
3292
|
-
width = _a.width,
|
|
3293
|
-
height = _a.height;
|
|
3294
|
-
log('camera dimensions', width, height);
|
|
3295
|
-
var label = deviceLabel.toLocaleLowerCase().split(' ').join('');
|
|
3296
|
-
log('camera label', label);
|
|
3297
|
-
var isRearFacing = cameraLabelMatches(label, __spreadArray(__spreadArray(__spreadArray([], rearCameraLabels, true), backUltraWideCameraLabels, true), ['iphone'], false));
|
|
3298
|
-
log('is rear facing?', isRearFacing);
|
|
3299
|
-
var release = function release() {
|
|
3300
|
-
stream.getTracks().forEach(function (track) {
|
|
3301
|
-
track.enabled = false;
|
|
3302
|
-
track.stop();
|
|
3303
|
-
});
|
|
3304
|
-
if (video) {
|
|
3305
|
-
video.pause();
|
|
3306
|
-
video.srcObject = null;
|
|
3307
|
-
video.src = '';
|
|
3308
|
-
}
|
|
3309
|
-
};
|
|
3310
|
-
width || (width = 0);
|
|
3311
|
-
height || (height = 0);
|
|
3312
|
-
currentCamera = {
|
|
3313
|
-
label: deviceLabel,
|
|
3314
|
-
stream: stream,
|
|
3315
|
-
width: width,
|
|
3316
|
-
height: height,
|
|
3317
|
-
isRearFacing: isRearFacing,
|
|
3318
|
-
release: release
|
|
3319
|
-
};
|
|
3320
|
-
log('camera access granted');
|
|
3321
|
-
if (video) video.srcObject = stream;
|
|
3322
|
-
log('video source initialized');
|
|
3323
|
-
return currentCamera;
|
|
3324
|
-
}
|
|
3325
|
-
function releaseCameraAccess() {
|
|
3326
|
-
if (!currentCamera) return;
|
|
3327
|
-
log('releasing camera access...');
|
|
3328
|
-
currentCamera.release();
|
|
3329
|
-
currentCamera = undefined;
|
|
3330
|
-
}
|
|
3331
|
-
|
|
3332
|
-
var initialState$5 = {
|
|
3333
|
-
videoRef: {
|
|
3334
|
-
current: null
|
|
3335
|
-
},
|
|
3336
|
-
videoLoaded: false,
|
|
3337
|
-
videoStream: null,
|
|
3338
|
-
videoDevice: null,
|
|
3339
|
-
isRearFacing: false,
|
|
3340
|
-
camera: null,
|
|
3341
|
-
cameraReady: false,
|
|
3342
|
-
cameraAccessDenied: false,
|
|
3343
|
-
iphoneContinuityCameraAvailable: false,
|
|
3344
|
-
iphoneContinuityCameraDenied: false,
|
|
3345
|
-
preferIphoneContinuityCamera: true,
|
|
3346
|
-
audioStream: null,
|
|
3347
|
-
microphoneReady: false,
|
|
3348
|
-
microphoneAccessDenied: false
|
|
3349
|
-
};
|
|
3350
|
-
var createCameraStore = function createCameraStore(config) {
|
|
3351
|
-
var store = createStore(function (set, get) {
|
|
3352
|
-
return _assign(_assign(_assign({}, initialState$5), config), {
|
|
3353
|
-
reset: function reset() {
|
|
3354
|
-
return set(_assign(_assign({}, initialState$5), config));
|
|
3355
|
-
},
|
|
3356
|
-
setConfig: function setConfig(config) {
|
|
3357
|
-
return set(config);
|
|
3358
|
-
},
|
|
3359
|
-
onVideoMounted: function onVideoMounted() {
|
|
3360
|
-
return set({
|
|
3361
|
-
videoLoaded: true
|
|
3362
|
-
});
|
|
3363
|
-
},
|
|
3364
|
-
setIphoneContinuityCameraAllowed: function setIphoneContinuityCameraAllowed(value) {
|
|
3365
|
-
return set({
|
|
3366
|
-
preferIphoneContinuityCamera: value
|
|
3367
|
-
});
|
|
3368
|
-
},
|
|
3369
|
-
requestCameraAccess: function requestCameraAccess() {
|
|
3370
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3371
|
-
var _a, videoRef, releaseCameraAccess, preferFrontFacingCamera, preferIphoneContinuityCamera, iphoneContinuityCameraDenied, availableCameras, selectedCamera, platform_1, iphoneContinuityCamera, constraints, stream_1, e_1, iphoneContinuityCameraAvailable_1, handleStreamEnded_1, videoTrack_1, camera_1, e_3;
|
|
3372
|
-
var _b, _c, _d;
|
|
3373
|
-
return __generator(this, function (_e) {
|
|
3374
|
-
switch (_e.label) {
|
|
3375
|
-
case 0:
|
|
3376
|
-
_a = get(), videoRef = _a.videoRef, releaseCameraAccess = _a.releaseCameraAccess, preferFrontFacingCamera = _a.preferFrontFacingCamera, preferIphoneContinuityCamera = _a.preferIphoneContinuityCamera, iphoneContinuityCameraDenied = _a.iphoneContinuityCameraDenied;
|
|
3377
|
-
releaseCameraAccess();
|
|
3378
|
-
_e.label = 1;
|
|
3379
|
-
case 1:
|
|
3380
|
-
_e.trys.push([1, 11,, 12]);
|
|
3381
|
-
return [4 /*yield*/, listAvailableCameras()];
|
|
3382
|
-
case 2:
|
|
3383
|
-
availableCameras = _e.sent();
|
|
3384
|
-
selectedCamera = void 0;
|
|
3385
|
-
debug('availableCameras', availableCameras);
|
|
3386
|
-
platform_1 = getPlatform();
|
|
3387
|
-
debug('platformDetails', platform_1);
|
|
3388
|
-
if (!iphoneContinuityCameraDenied && (!(platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) || platform_1.os.family === 'OS X')) {
|
|
3389
|
-
iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
|
|
3390
|
-
return cameraLabelMatches(deviceInfo, 'iphone');
|
|
3391
|
-
});
|
|
3392
|
-
set({
|
|
3393
|
-
iphoneContinuityCameraAvailable: !!iphoneContinuityCamera
|
|
3394
|
-
});
|
|
3395
|
-
if (iphoneContinuityCamera && preferIphoneContinuityCamera) {
|
|
3396
|
-
selectedCamera = iphoneContinuityCamera;
|
|
3397
|
-
}
|
|
3398
|
-
} 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) {
|
|
3399
|
-
return c.label.startsWith('camera2 ');
|
|
3400
|
-
})) {
|
|
3401
|
-
availableCameras = availableCameras.sort(function (a, b) {
|
|
3402
|
-
return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
|
|
3403
|
-
});
|
|
3404
|
-
debug('cameras have been sorted', availableCameras);
|
|
3405
|
-
}
|
|
3406
|
-
if (preferFrontFacingCamera) {
|
|
3407
|
-
selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3408
|
-
return cameraLabelMatches(deviceInfo, frontCameraLabels);
|
|
3409
|
-
});
|
|
3410
|
-
}
|
|
3411
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3412
|
-
return cameraLabelMatches(deviceInfo, 'backtriplecamera');
|
|
3413
|
-
}));
|
|
3414
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3415
|
-
return cameraLabelMatches(deviceInfo, 'backdualcamera');
|
|
3416
|
-
}));
|
|
3417
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3418
|
-
return cameraLabelMatches(deviceInfo, rearCameraLabels) && !cameraLabelMatches(deviceInfo, backUltraWideCameraLabels);
|
|
3419
|
-
}));
|
|
3420
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3421
|
-
return cameraLabelMatches(deviceInfo, rearCameraLabels);
|
|
3422
|
-
}));
|
|
3423
|
-
// on iOS, the front facing camera always is at the first position in the list, so we skip it if all else fails.
|
|
3424
|
-
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) {
|
|
3425
|
-
selectedCamera || (selectedCamera = availableCameras[1]);
|
|
3426
|
-
}
|
|
3427
|
-
selectedCamera || (selectedCamera = availableCameras[0]);
|
|
3428
|
-
debug('selectedCamera', selectedCamera);
|
|
3429
|
-
set({
|
|
3430
|
-
videoDevice: selectedCamera
|
|
3431
|
-
});
|
|
3432
|
-
constraints = {
|
|
3433
|
-
audio: false,
|
|
3434
|
-
video: {
|
|
3435
|
-
deviceId: {
|
|
3436
|
-
exact: selectedCamera.deviceId
|
|
3437
|
-
},
|
|
3438
|
-
width: {
|
|
3439
|
-
ideal: config.maxVideoWidth
|
|
3440
|
-
},
|
|
3441
|
-
aspectRatio: 1.777777778,
|
|
3442
|
-
frameRate: {}
|
|
3443
|
-
}
|
|
3444
|
-
};
|
|
3445
|
-
if (config.maxFps) {
|
|
3446
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3447
|
-
// @ts-ignore
|
|
3448
|
-
constraints.video.frameRate = {
|
|
3449
|
-
max: config.maxFps
|
|
3450
|
-
};
|
|
3451
|
-
}
|
|
3452
|
-
stream_1 = null;
|
|
3453
|
-
_e.label = 3;
|
|
3454
|
-
case 3:
|
|
3455
|
-
_e.trys.push([3, 5,, 6]);
|
|
3456
|
-
debug('obtaining camera access with constraints', constraints);
|
|
3457
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
|
|
3458
|
-
case 4:
|
|
3459
|
-
stream_1 = _e.sent();
|
|
3460
|
-
return [3 /*break*/, 6];
|
|
3461
|
-
case 5:
|
|
3462
|
-
e_1 = _e.sent();
|
|
3463
|
-
if (e_1.name === 'NotAllowedError') {
|
|
3464
|
-
if (preferIphoneContinuityCamera) {
|
|
3465
|
-
set({
|
|
3466
|
-
iphoneContinuityCameraAvailable: false,
|
|
3467
|
-
iphoneContinuityCameraDenied: true
|
|
3468
|
-
});
|
|
3469
|
-
} else {
|
|
3470
|
-
set({
|
|
3471
|
-
cameraAccessDenied: true
|
|
3472
|
-
});
|
|
3473
|
-
}
|
|
3474
|
-
return [2 /*return*/];
|
|
3475
|
-
}
|
|
3476
|
-
return [3 /*break*/, 6];
|
|
3477
|
-
case 6:
|
|
3478
|
-
if (!!stream_1) return [3 /*break*/, 10];
|
|
3479
|
-
_e.label = 7;
|
|
3480
|
-
case 7:
|
|
3481
|
-
_e.trys.push([7, 9,, 10]);
|
|
3482
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3483
|
-
audio: false,
|
|
3484
|
-
video: true
|
|
3485
|
-
})];
|
|
3486
|
-
case 8:
|
|
3487
|
-
stream_1 = _e.sent();
|
|
3488
|
-
debug('opened stream with no width and height constraints');
|
|
3489
|
-
return [3 /*break*/, 10];
|
|
3490
|
-
case 9:
|
|
3491
|
-
_e.sent();
|
|
3492
|
-
debug('cannot open stream at all');
|
|
3493
|
-
return [3 /*break*/, 10];
|
|
3494
|
-
case 10:
|
|
3495
|
-
if (!stream_1) {
|
|
3496
|
-
error('failed to open camera');
|
|
3497
|
-
throw new Error('failed to open camera');
|
|
3498
|
-
}
|
|
3499
|
-
debug('camera access granted with constraints', constraints);
|
|
3500
|
-
iphoneContinuityCameraAvailable_1 = get().iphoneContinuityCameraAvailable;
|
|
3501
|
-
handleStreamEnded_1 = function handleStreamEnded_1() {
|
|
3502
|
-
if (iphoneContinuityCameraAvailable_1 && preferIphoneContinuityCamera) {
|
|
3503
|
-
debug('someone unplugged the continuity camera');
|
|
3504
|
-
set({
|
|
3505
|
-
videoStream: null,
|
|
3506
|
-
videoDevice: null,
|
|
3507
|
-
cameraReady: false,
|
|
3508
|
-
iphoneContinuityCameraAvailable: false,
|
|
3509
|
-
iphoneContinuityCameraDenied: true
|
|
3510
|
-
});
|
|
3511
|
-
get().requestCameraAccess();
|
|
3512
|
-
} else {
|
|
3513
|
-
debug('someone unplugged the webcam');
|
|
3514
|
-
releaseCameraAccess();
|
|
3515
|
-
set({
|
|
3516
|
-
videoStream: null,
|
|
3517
|
-
videoDevice: null,
|
|
3518
|
-
videoLoaded: false,
|
|
3519
|
-
cameraReady: false,
|
|
3520
|
-
cameraAccessDenied: true
|
|
3521
|
-
});
|
|
3522
|
-
}
|
|
3523
|
-
};
|
|
3524
|
-
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', handleStreamEnded_1);
|
|
3525
|
-
videoTrack_1 = stream_1.getVideoTracks()[0];
|
|
3526
|
-
videoTrack_1.onended = handleStreamEnded_1;
|
|
3527
|
-
camera_1 = obtainCameraAccess(stream_1, selectedCamera.label, videoRef.current);
|
|
3528
|
-
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
3529
|
-
// when the camera access is being requested. This delay is a workaround for that.
|
|
3530
|
-
setTimeout(function () {
|
|
3531
|
-
videoTrack_1.onmute = handleStreamEnded_1;
|
|
3532
|
-
set({
|
|
3533
|
-
camera: camera_1,
|
|
3534
|
-
cameraReady: true,
|
|
3535
|
-
cameraAccessDenied: false,
|
|
3536
|
-
isRearFacing: camera_1.isRearFacing,
|
|
3537
|
-
videoStream: stream_1
|
|
3538
|
-
});
|
|
3539
|
-
}, 500);
|
|
3540
|
-
return [3 /*break*/, 12];
|
|
3541
|
-
case 11:
|
|
3542
|
-
e_3 = _e.sent();
|
|
3543
|
-
if (e_3.name === 'NotAllowedError') {
|
|
3544
|
-
error('camera access has been blocked by the user', e_3);
|
|
3545
|
-
set({
|
|
3546
|
-
cameraAccessDenied: true
|
|
3547
|
-
});
|
|
3548
|
-
} else {
|
|
3549
|
-
error('camera access encountered some other error', e_3);
|
|
3550
|
-
throw e_3;
|
|
3551
|
-
}
|
|
3552
|
-
return [3 /*break*/, 12];
|
|
3553
|
-
case 12:
|
|
3554
|
-
return [2 /*return*/];
|
|
3555
|
-
}
|
|
3556
|
-
});
|
|
3557
|
-
});
|
|
3558
|
-
},
|
|
3559
|
-
releaseCameraAccess: function releaseCameraAccess() {
|
|
3560
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3561
|
-
var camera;
|
|
3562
|
-
return __generator(this, function (_a) {
|
|
3563
|
-
camera = get().camera;
|
|
3564
|
-
if (!camera) return [2 /*return*/];
|
|
3565
|
-
camera.release();
|
|
3566
|
-
set({
|
|
3567
|
-
camera: null,
|
|
3568
|
-
cameraReady: false,
|
|
3569
|
-
cameraAccessDenied: false
|
|
3570
|
-
});
|
|
3571
|
-
return [2 /*return*/];
|
|
3572
|
-
});
|
|
3573
|
-
});
|
|
3574
|
-
},
|
|
3575
|
-
requestMicrophoneAccess: function requestMicrophoneAccess() {
|
|
3576
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3577
|
-
var stream_2;
|
|
3578
|
-
return __generator(this, function (_a) {
|
|
3579
|
-
switch (_a.label) {
|
|
3580
|
-
case 0:
|
|
3581
|
-
get().releaseMicrophoneAccess();
|
|
3582
|
-
_a.label = 1;
|
|
3583
|
-
case 1:
|
|
3584
|
-
_a.trys.push([1, 3,, 4]);
|
|
3585
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3586
|
-
audio: true,
|
|
3587
|
-
video: false
|
|
3588
|
-
})
|
|
3589
|
-
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
3590
|
-
// when the camera access is being requested. This delay is a workaround for that.
|
|
3591
|
-
];
|
|
3592
|
-
case 2:
|
|
3593
|
-
stream_2 = _a.sent();
|
|
3594
|
-
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
3595
|
-
// when the camera access is being requested. This delay is a workaround for that.
|
|
3596
|
-
setTimeout(function () {
|
|
3597
|
-
set({
|
|
3598
|
-
audioStream: stream_2,
|
|
3599
|
-
microphoneReady: true,
|
|
3600
|
-
microphoneAccessDenied: false
|
|
3601
|
-
});
|
|
3602
|
-
stream_2.getAudioTracks().forEach(function (track) {
|
|
3603
|
-
track.onended = function () {
|
|
3604
|
-
return set({
|
|
3605
|
-
microphoneReady: false,
|
|
3606
|
-
microphoneAccessDenied: true
|
|
3607
|
-
});
|
|
3608
|
-
};
|
|
3609
|
-
track.onmute = function () {
|
|
3610
|
-
return set({
|
|
3611
|
-
microphoneReady: false,
|
|
3612
|
-
microphoneAccessDenied: true
|
|
3613
|
-
});
|
|
3614
|
-
};
|
|
3615
|
-
});
|
|
3616
|
-
}, 500);
|
|
3617
|
-
return [3 /*break*/, 4];
|
|
3618
|
-
case 3:
|
|
3619
|
-
_a.sent();
|
|
3620
|
-
set({
|
|
3621
|
-
microphoneAccessDenied: true
|
|
3622
|
-
});
|
|
3623
|
-
return [3 /*break*/, 4];
|
|
3624
|
-
case 4:
|
|
3625
|
-
return [2 /*return*/];
|
|
3626
|
-
}
|
|
3627
|
-
});
|
|
3628
|
-
});
|
|
3629
|
-
},
|
|
3630
|
-
releaseMicrophoneAccess: function releaseMicrophoneAccess() {
|
|
3631
|
-
var _a;
|
|
3632
|
-
var audioStream = get().audioStream;
|
|
3633
|
-
(_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
|
|
3634
|
-
audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks().forEach(function (track) {
|
|
3635
|
-
var _a;
|
|
3636
|
-
(_a = track.stop) === null || _a === void 0 ? void 0 : _a.call(track);
|
|
3637
|
-
});
|
|
3638
|
-
set({
|
|
3639
|
-
audioStream: null,
|
|
3640
|
-
microphoneReady: false,
|
|
3641
|
-
microphoneAccessDenied: false
|
|
3642
|
-
});
|
|
3643
|
-
}
|
|
3644
|
-
});
|
|
3645
|
-
});
|
|
3646
|
-
if (config.requestAccessAutomatically) {
|
|
3647
|
-
void store.getState().requestCameraAccess();
|
|
3648
|
-
}
|
|
3649
|
-
if (config.requireMicrophoneAccess) {
|
|
3650
|
-
void store.getState().requestMicrophoneAccess();
|
|
3651
|
-
}
|
|
3652
|
-
return _assign(_assign({}, store), {
|
|
3653
|
-
destroy: function destroy() {
|
|
3654
|
-
store.getState().releaseCameraAccess();
|
|
3655
|
-
store.getState().releaseMicrophoneAccess();
|
|
3703
|
+
passportDetectionScore: passportDetectionScore,
|
|
3704
|
+
passportDetectionThresholdMet: passportDetectionThresholdMet,
|
|
3705
|
+
bestDocument: bestDocument,
|
|
3706
|
+
documentInBounds: documentInBounds,
|
|
3707
|
+
documentTooClose: documentTooClose,
|
|
3708
|
+
documentIsStable: documentIsStable,
|
|
3709
|
+
frameWidth: frameWidth,
|
|
3710
|
+
frameHeight: frameHeight,
|
|
3711
|
+
allZero: allZero
|
|
3712
|
+
};
|
|
3713
|
+
}
|
|
3714
|
+
function applyNonMaxSuppression(detectedObjects, isGoodBox) {
|
|
3715
|
+
var maxes = {};
|
|
3716
|
+
detectedObjects.forEach(function (obj, i) {
|
|
3717
|
+
if (obj) {
|
|
3718
|
+
if (!maxes[obj.label]) maxes[obj.label] = [0, -1];
|
|
3719
|
+
if (obj.score > maxes[obj.label][0] && (isGoodBox === null || isGoodBox === void 0 ? void 0 : isGoodBox(obj))) maxes[obj.label] = [obj.score, i];
|
|
3656
3720
|
}
|
|
3657
3721
|
});
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
function
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
var
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3722
|
+
return Object.keys(maxes).map(function (label) {
|
|
3723
|
+
return detectedObjects[maxes[label][1]];
|
|
3724
|
+
}).filter(function (obj) {
|
|
3725
|
+
return !!obj;
|
|
3726
|
+
});
|
|
3727
|
+
}
|
|
3728
|
+
|
|
3729
|
+
function useFrameLoop(fn, _a) {
|
|
3730
|
+
var _b = _a.throttleMs,
|
|
3731
|
+
throttleMs = _b === void 0 ? 0 : _b,
|
|
3732
|
+
_c = _a.autoStart,
|
|
3733
|
+
autoStart = _c === void 0 ? false : _c;
|
|
3734
|
+
var _d = useState(false),
|
|
3735
|
+
running = _d[0],
|
|
3736
|
+
setRunning = _d[1];
|
|
3737
|
+
var startedAtRef = useRef(null);
|
|
3738
|
+
var loopId = useRef(0);
|
|
3739
|
+
var frameId = useRef(0);
|
|
3740
|
+
useEffect(function runFrameLoop() {
|
|
3741
|
+
if (!running) return;
|
|
3742
|
+
var timer;
|
|
3743
|
+
var currentLoopId = loopId.current;
|
|
3744
|
+
function renderPrediction() {
|
|
3745
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3746
|
+
var start, timeRunning, took, amountToThrottle;
|
|
3747
|
+
var _a, _b;
|
|
3748
|
+
return __generator(this, function (_c) {
|
|
3749
|
+
switch (_c.label) {
|
|
3750
|
+
case 0:
|
|
3751
|
+
if (currentLoopId !== loopId.current) return [2 /*return*/];
|
|
3752
|
+
start = new Date().getTime();
|
|
3753
|
+
timeRunning = start - ((_b = (_a = startedAtRef.current) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0);
|
|
3754
|
+
return [4 /*yield*/, fn(frameId.current, timeRunning)];
|
|
3755
|
+
case 1:
|
|
3756
|
+
_c.sent();
|
|
3757
|
+
took = new Date().getTime() - start;
|
|
3758
|
+
amountToThrottle = Math.max((throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0) - took, 0);
|
|
3759
|
+
timer = setTimeout(function () {
|
|
3760
|
+
frameId.current = requestAnimationFrame(renderPrediction);
|
|
3761
|
+
}, amountToThrottle);
|
|
3762
|
+
return [2 /*return*/];
|
|
3763
|
+
}
|
|
3764
|
+
});
|
|
3696
3765
|
});
|
|
3697
|
-
(_c = store.current) === null || _c === void 0 ? void 0 : _c.getState().requestCameraAccess();
|
|
3698
3766
|
}
|
|
3699
|
-
|
|
3700
|
-
useEffect(function () {
|
|
3767
|
+
renderPrediction().then();
|
|
3701
3768
|
return function () {
|
|
3702
|
-
|
|
3703
|
-
|
|
3769
|
+
loopId.current += 1;
|
|
3770
|
+
frameId.current && cancelAnimationFrame(frameId.current);
|
|
3771
|
+
timer && clearTimeout(timer);
|
|
3704
3772
|
};
|
|
3773
|
+
}, [fn, running, throttleMs]);
|
|
3774
|
+
var start = useCallback(function () {
|
|
3775
|
+
startedAtRef.current = new Date();
|
|
3776
|
+
setRunning(true);
|
|
3705
3777
|
}, []);
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
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();
|
|
3785
|
+
return function () {
|
|
3786
|
+
stop();
|
|
3787
|
+
};
|
|
3788
|
+
}, [autoStart, start, stop]);
|
|
3789
|
+
return {
|
|
3790
|
+
start: start,
|
|
3791
|
+
stop: stop
|
|
3792
|
+
};
|
|
3714
3793
|
}
|
|
3715
3794
|
|
|
3716
3795
|
var DocumentDetectionModelContext = /*#__PURE__*/createContext({
|
|
@@ -3758,7 +3837,7 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
3758
3837
|
_g = _a.documentDetectionModelLoadTimeoutMs,
|
|
3759
3838
|
documentDetectionModelLoadTimeoutMs = _g === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _g,
|
|
3760
3839
|
onDocumentDetectionModelError = _a.onDocumentDetectionModelError;
|
|
3761
|
-
var _h =
|
|
3840
|
+
var _h = useContext(CameraStateContext),
|
|
3762
3841
|
videoRef = _h.videoRef,
|
|
3763
3842
|
videoLoaded = _h.videoLoaded,
|
|
3764
3843
|
cameraReady = _h.cameraReady;
|
|
@@ -3781,8 +3860,7 @@ function DocumentDetectionModelProvider(_a) {
|
|
|
3781
3860
|
modelPath: documentDetectionModelPath,
|
|
3782
3861
|
modelLoadTimeoutMs: documentDetectionModelLoadTimeoutMs,
|
|
3783
3862
|
scoreThreshold: documentDetectionModelScoreThreshold,
|
|
3784
|
-
onModelError: onDocumentDetectionModelError
|
|
3785
|
-
videoRef: videoRef
|
|
3863
|
+
onModelError: onDocumentDetectionModelError
|
|
3786
3864
|
}),
|
|
3787
3865
|
ready = _o.ready,
|
|
3788
3866
|
modelDownloadProgress = _o.modelDownloadProgress,
|
|
@@ -3899,12 +3977,10 @@ function FocusModelProvider(_a) {
|
|
|
3899
3977
|
var _e = useState({}),
|
|
3900
3978
|
focusThresholds = _e[0],
|
|
3901
3979
|
setFocusThresholds = _e[1];
|
|
3902
|
-
var videoRef = useCameraStore().videoRef;
|
|
3903
3980
|
var _f = useLoadFocusModel({
|
|
3904
3981
|
modelPath: focusModelPath,
|
|
3905
3982
|
modelLoadTimeoutMs: focusModelLoadTimeoutMs,
|
|
3906
|
-
onModelError: onFocusModelError
|
|
3907
|
-
videoRef: videoRef
|
|
3983
|
+
onModelError: onFocusModelError
|
|
3908
3984
|
}),
|
|
3909
3985
|
ready = _f.ready,
|
|
3910
3986
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
@@ -5026,33 +5102,31 @@ var Button = styled(LoaderButton)(templateObject_5$b || (templateObject_5$b = __
|
|
|
5026
5102
|
var templateObject_1$D, templateObject_2$w, templateObject_3$o, templateObject_4$i, templateObject_5$b;
|
|
5027
5103
|
|
|
5028
5104
|
var IdCapture = function IdCapture(_a) {
|
|
5029
|
-
var _b, _c, _d, _e, _f, _g, _h;
|
|
5105
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
5030
5106
|
var requiredDocumentType = _a.requiredDocumentType,
|
|
5031
|
-
|
|
5032
|
-
thresholds =
|
|
5107
|
+
_k = _a.thresholds,
|
|
5108
|
+
thresholds = _k === void 0 ? defaultIdCaptureThresholds : _k,
|
|
5033
5109
|
guidanceMessage = _a.guidanceMessage,
|
|
5034
5110
|
guidanceSatisfied = _a.guidanceSatisfied,
|
|
5035
5111
|
onCapture = _a.onCapture,
|
|
5036
|
-
|
|
5037
|
-
classNames =
|
|
5038
|
-
|
|
5039
|
-
colors =
|
|
5040
|
-
|
|
5041
|
-
rawVerbiage =
|
|
5042
|
-
|
|
5043
|
-
debugMode =
|
|
5044
|
-
var
|
|
5045
|
-
ref =
|
|
5046
|
-
|
|
5047
|
-
width =
|
|
5048
|
-
|
|
5049
|
-
height =
|
|
5050
|
-
var
|
|
5051
|
-
state =
|
|
5052
|
-
dispatch =
|
|
5053
|
-
var
|
|
5054
|
-
camera = _t.camera,
|
|
5055
|
-
isRearFacing = _t.isRearFacing;
|
|
5112
|
+
_l = _a.classNames,
|
|
5113
|
+
classNames = _l === void 0 ? {} : _l,
|
|
5114
|
+
_m = _a.colors,
|
|
5115
|
+
colors = _m === void 0 ? {} : _m,
|
|
5116
|
+
_o = _a.verbiage,
|
|
5117
|
+
rawVerbiage = _o === void 0 ? {} : _o,
|
|
5118
|
+
_p = _a.debugMode,
|
|
5119
|
+
debugMode = _p === void 0 ? false : _p;
|
|
5120
|
+
var _q = useResizeObserver(),
|
|
5121
|
+
ref = _q.ref,
|
|
5122
|
+
_r = _q.width,
|
|
5123
|
+
width = _r === void 0 ? 1 : _r,
|
|
5124
|
+
_s = _q.height,
|
|
5125
|
+
height = _s === void 0 ? 1 : _s;
|
|
5126
|
+
var _t = useIdCaptureState(),
|
|
5127
|
+
state = _t[0],
|
|
5128
|
+
dispatch = _t[1];
|
|
5129
|
+
var cameraRef = useContext(CameraStateContext).cameraRef;
|
|
5056
5130
|
var _u = useContext(IdCaptureModelsContext),
|
|
5057
5131
|
modelsReady = _u.ready,
|
|
5058
5132
|
setThresholds = _u.setThresholds,
|
|
@@ -5164,16 +5238,17 @@ var IdCapture = function IdCapture(_a) {
|
|
|
5164
5238
|
classNames: classNames.overrideWrongDocumentTypeGuidanceDialog,
|
|
5165
5239
|
verbiage: rawVerbiage.overrideWrongDocumentTypeGuidanceDialog
|
|
5166
5240
|
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugBoundingBoxOverlay, {
|
|
5167
|
-
"$flipX": !isRearFacing,
|
|
5241
|
+
"$flipX": !((_j = cameraRef.current) === null || _j === void 0 ? void 0 : _j.isRearFacing),
|
|
5168
5242
|
scaling: debugScalingDetails
|
|
5169
5243
|
}, state.detectedObjects.map(function (obj, i) {
|
|
5244
|
+
var _a;
|
|
5170
5245
|
return /*#__PURE__*/React__default.createElement(IdCaptureDetectedObjectDebugBox, {
|
|
5171
5246
|
key: i,
|
|
5172
5247
|
obj: obj,
|
|
5173
5248
|
scaling: debugScalingDetails,
|
|
5174
|
-
flipX: !isRearFacing
|
|
5249
|
+
flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing)
|
|
5175
5250
|
});
|
|
5176
|
-
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null,
|
|
5251
|
+
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.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")))));
|
|
5177
5252
|
};
|
|
5178
5253
|
var timeSince = function timeSince(t) {
|
|
5179
5254
|
if (!t) return 0;
|
|
@@ -5190,9 +5265,7 @@ var CameraAccessDeniedOverlay = function CameraAccessDeniedOverlay(_a) {
|
|
|
5190
5265
|
colors = _e === void 0 ? {} : _e,
|
|
5191
5266
|
_f = _a.verbiage,
|
|
5192
5267
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
5193
|
-
var requestCameraAccess =
|
|
5194
|
-
return state.requestCameraAccess;
|
|
5195
|
-
});
|
|
5268
|
+
var requestCameraAccess = useContext(CameraStateContext).requestCameraAccess;
|
|
5196
5269
|
assets.imageUrl || (assets.imageUrl = DEFAULT_CDN_URL + '/camera-disable-icon.png');
|
|
5197
5270
|
var verbiage = useTranslations(rawVerbiage, {
|
|
5198
5271
|
headingText: 'Your camera permission is disabled',
|
|
@@ -5840,7 +5913,7 @@ var IdCaptureLoadingOverlayDefault = function IdCaptureLoadingOverlayDefault(_a)
|
|
|
5840
5913
|
var _o = useContext(IdCaptureModelsContext),
|
|
5841
5914
|
modelsReady = _o.ready,
|
|
5842
5915
|
modelDownloadProgress = _o.modelDownloadProgress;
|
|
5843
|
-
var _p =
|
|
5916
|
+
var _p = useContext(CameraStateContext),
|
|
5844
5917
|
cameraReady = _p.cameraReady,
|
|
5845
5918
|
cameraAccessDenied = _p.cameraAccessDenied,
|
|
5846
5919
|
iphoneContinuityCameraAvailable = _p.iphoneContinuityCameraAvailable,
|
|
@@ -6038,14 +6111,7 @@ var IdCaptureLoadingOverlayLegacy = function IdCaptureLoadingOverlayLegacy(_a) {
|
|
|
6038
6111
|
var _l = useContext(IdCaptureModelsContext),
|
|
6039
6112
|
modelsReady = _l.ready,
|
|
6040
6113
|
modelDownloadProgress = _l.modelDownloadProgress;
|
|
6041
|
-
var _m =
|
|
6042
|
-
return {
|
|
6043
|
-
cameraReady: state.cameraReady,
|
|
6044
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
6045
|
-
iphoneContinuityCameraAvailable: state.iphoneContinuityCameraAvailable,
|
|
6046
|
-
setIphoneContinuityCameraAllowed: state.setIphoneContinuityCameraAllowed
|
|
6047
|
-
};
|
|
6048
|
-
})),
|
|
6114
|
+
var _m = useContext(CameraStateContext),
|
|
6049
6115
|
cameraReady = _m.cameraReady,
|
|
6050
6116
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
6051
6117
|
iphoneContinuityCameraAvailable = _m.iphoneContinuityCameraAvailable,
|
|
@@ -6591,24 +6657,23 @@ function getOrientation(allowPortraitOnMobile) {
|
|
|
6591
6657
|
}
|
|
6592
6658
|
|
|
6593
6659
|
var IdVideoCaptureFlipIdPrompt = function IdVideoCaptureFlipIdPrompt(_a) {
|
|
6594
|
-
var _b
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6660
|
+
var _b;
|
|
6661
|
+
var _c = _a.idCaptureGuideImages,
|
|
6662
|
+
idCaptureGuideImages = _c === void 0 ? defaultIdCaptureGuideImages : _c,
|
|
6663
|
+
_d = _a.classNames,
|
|
6664
|
+
classNames = _d === void 0 ? {} : _d,
|
|
6598
6665
|
borderWidth = _a.borderWidth,
|
|
6599
6666
|
borderColor = _a.borderColor,
|
|
6600
6667
|
borderRadius = _a.borderRadius,
|
|
6601
6668
|
imageStyle = _a.imageStyle;
|
|
6602
|
-
var
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
rotationAngle = _e[0],
|
|
6611
|
-
setRotationAngle = _e[1];
|
|
6669
|
+
var cameraRef = useContext(CameraStateContext).cameraRef;
|
|
6670
|
+
var isMirrored = !((_b = cameraRef.current) === null || _b === void 0 ? void 0 : _b.isRearFacing);
|
|
6671
|
+
var _e = useState(1),
|
|
6672
|
+
transitionTime = _e[0],
|
|
6673
|
+
setTransitionTime = _e[1];
|
|
6674
|
+
var _f = useState(0),
|
|
6675
|
+
rotationAngle = _f[0],
|
|
6676
|
+
setRotationAngle = _f[1];
|
|
6612
6677
|
var frontTransforms = ["rotateY(".concat(rotationAngle, "deg)")];
|
|
6613
6678
|
if (isMirrored) frontTransforms.push('scaleX(-1)');
|
|
6614
6679
|
var backTransforms = ["rotateY(".concat(180 - rotationAngle, "deg)")];
|
|
@@ -7132,30 +7197,29 @@ var Canvas$1 = styled.canvas(templateObject_2$n || (templateObject_2$n = __makeT
|
|
|
7132
7197
|
var templateObject_1$r, templateObject_2$n;
|
|
7133
7198
|
|
|
7134
7199
|
function IdCaptureGuides(_a) {
|
|
7135
|
-
var _b
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7200
|
+
var _b, _c;
|
|
7201
|
+
var _d = _a.guideType,
|
|
7202
|
+
guideType = _d === void 0 ? 'fit' : _d,
|
|
7203
|
+
_e = _a.status,
|
|
7204
|
+
status = _e === void 0 ? 'ready' : _e,
|
|
7205
|
+
_f = _a.progress,
|
|
7206
|
+
progress = _f === void 0 ? 0 : _f,
|
|
7207
|
+
_g = _a.portraitGuidesOnMobile,
|
|
7208
|
+
portraitGuidesOnMobile = _g === void 0 ? true : _g,
|
|
7209
|
+
_h = _a.requestedAction,
|
|
7210
|
+
requestedAction = _h === void 0 ? 'SHOW_ID_FRONT' : _h,
|
|
7211
|
+
_j = _a.isBackToFront,
|
|
7212
|
+
isBackToFront = _j === void 0 ? false : _j,
|
|
7213
|
+
_k = _a.images,
|
|
7214
|
+
images = _k === void 0 ? defaultIdCaptureGuideImages : _k,
|
|
7215
|
+
_l = _a.classNames,
|
|
7216
|
+
classNames = _l === void 0 ? {} : _l,
|
|
7217
|
+
_m = _a.colors,
|
|
7218
|
+
colors = _m === void 0 ? {} : _m,
|
|
7219
|
+
_o = _a.verbiage,
|
|
7220
|
+
rawVerbiage = _o === void 0 ? {} : _o;
|
|
7155
7221
|
var state = useIdCaptureState()[0];
|
|
7156
|
-
var
|
|
7157
|
-
return state.isRearFacing;
|
|
7158
|
-
});
|
|
7222
|
+
var cameraRef = useContext(CameraStateContext).cameraRef;
|
|
7159
7223
|
var verbiage = useTranslations(rawVerbiage, {
|
|
7160
7224
|
instructionText: 'Scan the front of ID',
|
|
7161
7225
|
capturingText: 'Capturing...',
|
|
@@ -7167,7 +7231,7 @@ function IdCaptureGuides(_a) {
|
|
|
7167
7231
|
status: status,
|
|
7168
7232
|
progress: progress,
|
|
7169
7233
|
instruction: state.captureFailed ? verbiage.captureFailedText : state.capturing ? verbiage === null || verbiage === void 0 ? void 0 : verbiage.capturingText : verbiage.instructionText,
|
|
7170
|
-
isMirrored: !isRearFacing,
|
|
7234
|
+
isMirrored: !((_b = cameraRef.current) === null || _b === void 0 ? void 0 : _b.isRearFacing),
|
|
7171
7235
|
borderColor: state.isGoodFrame ? colors.guideBoxSatisfiedColor : colors.guideBoxUnsatisfiedColor,
|
|
7172
7236
|
imageVisible: requestedAction === 'FLIP_ID' || !state.idCardFrontDetectionThresholdMet || !state.documentInBounds || state.documentTooClose
|
|
7173
7237
|
})), guideType === 'fit' && ( /*#__PURE__*/React__default.createElement(IdCaptureFitGuide, {
|
|
@@ -7177,7 +7241,7 @@ function IdCaptureGuides(_a) {
|
|
|
7177
7241
|
status: status,
|
|
7178
7242
|
progress: progress,
|
|
7179
7243
|
instruction: state.captureFailed ? verbiage.captureFailedText : state.capturing ? verbiage === null || verbiage === void 0 ? void 0 : verbiage.capturingText : verbiage.instructionText,
|
|
7180
|
-
isMirrored: !isRearFacing,
|
|
7244
|
+
isMirrored: !((_c = cameraRef.current) === null || _c === void 0 ? void 0 : _c.isRearFacing),
|
|
7181
7245
|
isBackToFront: isBackToFront,
|
|
7182
7246
|
portraitGuidesOnMobile: portraitGuidesOnMobile,
|
|
7183
7247
|
borderColor: state.isGoodFrame ? colors.guideBoxSatisfiedColor : colors.guideBoxUnsatisfiedColor,
|
|
@@ -7276,6 +7340,48 @@ var ImagePreviewText = styled.div(templateObject_3$h || (templateObject_3$h = __
|
|
|
7276
7340
|
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"])));
|
|
7277
7341
|
var templateObject_1$q, templateObject_2$m, templateObject_3$h, templateObject_4$b;
|
|
7278
7342
|
|
|
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
|
+
|
|
7279
7385
|
var documentCaptureInitialState = {
|
|
7280
7386
|
documents: [],
|
|
7281
7387
|
currentDocumentIndex: 0,
|
|
@@ -7394,8 +7500,8 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7394
7500
|
var _c = useReducer(documentCaptureStateReducer, documentCaptureInitialState),
|
|
7395
7501
|
state = _c[0],
|
|
7396
7502
|
dispatch = _c[1];
|
|
7397
|
-
var _d =
|
|
7398
|
-
|
|
7503
|
+
var _d = useContext(CameraStateContext),
|
|
7504
|
+
cameraRef = _d.cameraRef,
|
|
7399
7505
|
videoRef = _d.videoRef;
|
|
7400
7506
|
var uploadDocument = useContext(SubmissionContext).uploadDocument;
|
|
7401
7507
|
var uploadCapturedDocument = useCallback(function (content, filetype) {
|
|
@@ -7486,7 +7592,8 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7486
7592
|
}, [onResize]);
|
|
7487
7593
|
var videoTag = videoRef.current;
|
|
7488
7594
|
useEffect(function () {
|
|
7489
|
-
if (!state.capturing
|
|
7595
|
+
if (!state.capturing) return;
|
|
7596
|
+
if (!cameraRef.current) return;
|
|
7490
7597
|
function onComplete(content) {
|
|
7491
7598
|
if (!content) return;
|
|
7492
7599
|
var contentUrl = URL.createObjectURL(content);
|
|
@@ -7499,7 +7606,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7499
7606
|
});
|
|
7500
7607
|
}
|
|
7501
7608
|
if (typeof ImageCapture !== 'undefined') {
|
|
7502
|
-
var tracks =
|
|
7609
|
+
var tracks = cameraRef.current.stream.getTracks();
|
|
7503
7610
|
var videoCameraTrack = tracks.find(function (track) {
|
|
7504
7611
|
return track.kind === 'video';
|
|
7505
7612
|
});
|
|
@@ -7514,7 +7621,7 @@ var DocumentCaptureStateProvider = function DocumentCaptureStateProvider(_a) {
|
|
|
7514
7621
|
drawToCanvas(canvas, videoTag);
|
|
7515
7622
|
canvas.toBlob(onComplete);
|
|
7516
7623
|
}
|
|
7517
|
-
}, [state.capturing,
|
|
7624
|
+
}, [cameraRef, state.capturing, videoTag]);
|
|
7518
7625
|
var stateWithActions = useMemo(function () {
|
|
7519
7626
|
return _assign(_assign({}, state), {
|
|
7520
7627
|
uploadCapturedDocument: uploadCapturedDocument
|
|
@@ -7629,85 +7736,52 @@ var DocumentCaptureGuideOverlay = function DocumentCaptureGuideOverlay(_a) {
|
|
|
7629
7736
|
ref: canvasRef
|
|
7630
7737
|
}));
|
|
7631
7738
|
};
|
|
7632
|
-
var CanvasWrapper = styled.div(templateObject_1$
|
|
7739
|
+
var CanvasWrapper = styled.div(templateObject_1$o || (templateObject_1$o = __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) {
|
|
7633
7740
|
return props.$maskColor;
|
|
7634
7741
|
});
|
|
7635
7742
|
var Canvas = styled.canvas(templateObject_2$l || (templateObject_2$l = __makeTemplateObject(["\n display: block;\n"], ["\n display: block;\n"])));
|
|
7636
|
-
var templateObject_1$
|
|
7743
|
+
var templateObject_1$o, templateObject_2$l;
|
|
7637
7744
|
|
|
7638
|
-
var CameraFeedWrapper = styled.div(templateObject_1$
|
|
7745
|
+
var CameraFeedWrapper = styled.div(templateObject_1$n || (templateObject_1$n = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (props) {
|
|
7639
7746
|
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;") : "";
|
|
7640
7747
|
});
|
|
7641
|
-
var templateObject_1$o;
|
|
7642
|
-
|
|
7643
|
-
var CameraVideoTag = function CameraVideoTag(props) {
|
|
7644
|
-
var _a = useCameraStore(useShallow(function (store) {
|
|
7645
|
-
return {
|
|
7646
|
-
videoRef: store.videoRef,
|
|
7647
|
-
videoStream: store.videoStream,
|
|
7648
|
-
onVideoMounted: store.onVideoMounted,
|
|
7649
|
-
isRearFacing: store.isRearFacing
|
|
7650
|
-
};
|
|
7651
|
-
})),
|
|
7652
|
-
videoRef = _a.videoRef,
|
|
7653
|
-
videoStream = _a.videoStream,
|
|
7654
|
-
onVideoMounted = _a.onVideoMounted,
|
|
7655
|
-
isRearFacing = _a.isRearFacing;
|
|
7656
|
-
useEffect(function attachCameraStreamToVideoTagWhenReady() {
|
|
7657
|
-
if (videoRef.current && videoStream) {
|
|
7658
|
-
debug('attaching camera stream to video tag');
|
|
7659
|
-
videoRef.current.srcObject = videoStream;
|
|
7660
|
-
}
|
|
7661
|
-
}, [videoStream, videoRef]);
|
|
7662
|
-
return /*#__PURE__*/React__default.createElement(FullscreenVideoTag, _assign({
|
|
7663
|
-
autoPlay: true,
|
|
7664
|
-
playsInline: true,
|
|
7665
|
-
muted: true,
|
|
7666
|
-
ref: videoRef,
|
|
7667
|
-
onLoadedData: onVideoMounted,
|
|
7668
|
-
"$isRearFacing": isRearFacing
|
|
7669
|
-
}, props));
|
|
7670
|
-
};
|
|
7671
|
-
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) {
|
|
7672
|
-
return props.$isRearFacing ? '' : 'scaleX(-1)';
|
|
7673
|
-
});
|
|
7674
7748
|
var templateObject_1$n;
|
|
7675
7749
|
|
|
7676
7750
|
var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
|
|
7677
|
-
var _b, _c, _d, _e, _f;
|
|
7751
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
7678
7752
|
var onCaptureClicked = _a.onCaptureClicked,
|
|
7679
|
-
|
|
7680
|
-
classNames =
|
|
7681
|
-
|
|
7682
|
-
rawVerbiage =
|
|
7683
|
-
var
|
|
7684
|
-
|
|
7685
|
-
documents =
|
|
7686
|
-
currentDocumentIndex =
|
|
7687
|
-
rectX =
|
|
7688
|
-
rectY =
|
|
7689
|
-
rectWidth =
|
|
7690
|
-
rectHeight =
|
|
7691
|
-
rectOffsetTop =
|
|
7692
|
-
capturing =
|
|
7693
|
-
uploadCapturedDocument =
|
|
7694
|
-
dispatch =
|
|
7695
|
-
var
|
|
7696
|
-
title =
|
|
7697
|
-
aspectRatio =
|
|
7698
|
-
cameraFeedMode =
|
|
7699
|
-
instructions =
|
|
7700
|
-
contentUrl =
|
|
7701
|
-
content =
|
|
7702
|
-
uploadState =
|
|
7703
|
-
var
|
|
7704
|
-
|
|
7705
|
-
cameraReady =
|
|
7706
|
-
cameraAccessDenied =
|
|
7707
|
-
requestCameraAccess =
|
|
7708
|
-
var
|
|
7709
|
-
cameraAccessRequested =
|
|
7710
|
-
setCameraAccessRequested =
|
|
7753
|
+
_j = _a.classNames,
|
|
7754
|
+
classNames = _j === void 0 ? {} : _j,
|
|
7755
|
+
_k = _a.verbiage,
|
|
7756
|
+
rawVerbiage = _k === void 0 ? {} : _k;
|
|
7757
|
+
var _l = useDocumentCaptureState(),
|
|
7758
|
+
_m = _l[0],
|
|
7759
|
+
documents = _m.documents,
|
|
7760
|
+
currentDocumentIndex = _m.currentDocumentIndex,
|
|
7761
|
+
rectX = _m.rectX,
|
|
7762
|
+
rectY = _m.rectY,
|
|
7763
|
+
rectWidth = _m.rectWidth,
|
|
7764
|
+
rectHeight = _m.rectHeight,
|
|
7765
|
+
rectOffsetTop = _m.rectOffsetTop,
|
|
7766
|
+
capturing = _m.capturing,
|
|
7767
|
+
uploadCapturedDocument = _m.uploadCapturedDocument,
|
|
7768
|
+
dispatch = _l[1];
|
|
7769
|
+
var _o = (_b = documents[currentDocumentIndex]) !== null && _b !== void 0 ? _b : {},
|
|
7770
|
+
title = _o.title,
|
|
7771
|
+
aspectRatio = _o.aspectRatio,
|
|
7772
|
+
cameraFeedMode = _o.cameraFeedMode,
|
|
7773
|
+
instructions = _o.instructions,
|
|
7774
|
+
contentUrl = _o.contentUrl,
|
|
7775
|
+
content = _o.content,
|
|
7776
|
+
uploadState = _o.uploadState;
|
|
7777
|
+
var _p = useContext(CameraStateContext),
|
|
7778
|
+
cameraRef = _p.cameraRef,
|
|
7779
|
+
cameraReady = _p.cameraReady,
|
|
7780
|
+
cameraAccessDenied = _p.cameraAccessDenied,
|
|
7781
|
+
requestCameraAccess = _p.requestCameraAccess;
|
|
7782
|
+
var _q = useState(false),
|
|
7783
|
+
cameraAccessRequested = _q[0],
|
|
7784
|
+
setCameraAccessRequested = _q[1];
|
|
7711
7785
|
var cameraAccessNeeded =
|
|
7712
7786
|
// we should force the browser to ask for camera access if...
|
|
7713
7787
|
uploadState === 'not_started' &&
|
|
@@ -7716,14 +7790,14 @@ var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
|
|
|
7716
7790
|
// and the user hasn't passed a media blob for the current document...
|
|
7717
7791
|
!cameraAccessRequested &&
|
|
7718
7792
|
// and we haven't already tried to force a camera request...
|
|
7719
|
-
!(
|
|
7793
|
+
!((_d = (_c = cameraRef.current) === null || _c === void 0 ? void 0 : _c.stream) === null || _d === void 0 ? void 0 : _d.active); // and we don't already have camera access.
|
|
7720
7794
|
useEffect(function requestCameraAccessIfNeeded() {
|
|
7721
7795
|
if (!cameraAccessNeeded) return;
|
|
7722
7796
|
setCameraAccessRequested(true);
|
|
7723
7797
|
requestCameraAccess();
|
|
7724
7798
|
}, [cameraAccessNeeded, requestCameraAccess]);
|
|
7725
7799
|
var theme = useTheme();
|
|
7726
|
-
var maskColor = (
|
|
7800
|
+
var maskColor = (_g = (_f = (_e = theme.documentCapture) === null || _e === void 0 ? void 0 : _e.guideBox) === null || _f === void 0 ? void 0 : _f.maskColor) !== null && _g !== void 0 ? _g : cameraFeedMode === 'snapToGuides' ? '#708090' : "rgba(0, 0, 0, 0.5)";
|
|
7727
7801
|
var verbiage = useTranslations(rawVerbiage, {
|
|
7728
7802
|
headingText: title,
|
|
7729
7803
|
loadingBtnText: 'Camera initializing...',
|
|
@@ -7756,7 +7830,7 @@ var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
|
|
|
7756
7830
|
});
|
|
7757
7831
|
}
|
|
7758
7832
|
return /*#__PURE__*/React__default.createElement(PageContainer, {
|
|
7759
|
-
className: "flex ".concat((
|
|
7833
|
+
className: "flex ".concat((_h = classNames.container) !== null && _h !== void 0 ? _h : '')
|
|
7760
7834
|
}, /*#__PURE__*/React__default.createElement(CameraFeedWrapper, {
|
|
7761
7835
|
className: classNames.cameraFeedWrapper,
|
|
7762
7836
|
"$mode": cameraFeedMode !== null && cameraFeedMode !== void 0 ? cameraFeedMode : 'snapToGuides',
|
|
@@ -8181,7 +8255,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
8181
8255
|
var _3 = useIdCaptureState(),
|
|
8182
8256
|
state = _3[0],
|
|
8183
8257
|
dispatch = _3[1];
|
|
8184
|
-
var _4 =
|
|
8258
|
+
var _4 = useContext(CameraStateContext),
|
|
8185
8259
|
cameraAccessDenied = _4.cameraAccessDenied,
|
|
8186
8260
|
requestCameraAccess = _4.requestCameraAccess,
|
|
8187
8261
|
releaseCameraAccess = _4.releaseCameraAccess;
|
|
@@ -8306,7 +8380,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
|
|
|
8306
8380
|
type: 'resetWizard'
|
|
8307
8381
|
});
|
|
8308
8382
|
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
8309
|
-
|
|
8383
|
+
requestCameraAccess();
|
|
8310
8384
|
}, [dispatch, onExitCapture, releaseCameraAccess, requestCameraAccess]);
|
|
8311
8385
|
useEffect(function () {
|
|
8312
8386
|
if (submissionStatus !== SubmissionStatus.READY) {
|
|
@@ -9129,13 +9203,7 @@ function SelfieGuidanceModelsProvider(_a) {
|
|
|
9129
9203
|
modelLoadTimeoutMs = _c === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _c,
|
|
9130
9204
|
_d = _a.requireVerticalFaceCentering,
|
|
9131
9205
|
requireVerticalFaceCentering = _d === void 0 ? true : _d;
|
|
9132
|
-
var _e =
|
|
9133
|
-
return {
|
|
9134
|
-
videoRef: state.videoRef,
|
|
9135
|
-
videoLoaded: state.videoLoaded,
|
|
9136
|
-
cameraReady: state.cameraReady
|
|
9137
|
-
};
|
|
9138
|
-
})),
|
|
9206
|
+
var _e = useContext(CameraStateContext),
|
|
9139
9207
|
videoRef = _e.videoRef,
|
|
9140
9208
|
videoLoaded = _e.videoLoaded,
|
|
9141
9209
|
cameraReady = _e.cameraReady;
|
|
@@ -9143,8 +9211,7 @@ function SelfieGuidanceModelsProvider(_a) {
|
|
|
9143
9211
|
var onPredictionHandler = useRef();
|
|
9144
9212
|
var _f = useLoadFaceDetector({
|
|
9145
9213
|
onModelError: onModelError,
|
|
9146
|
-
modelLoadTimeoutMs: modelLoadTimeoutMs
|
|
9147
|
-
videoRef: videoRef
|
|
9214
|
+
modelLoadTimeoutMs: modelLoadTimeoutMs
|
|
9148
9215
|
}),
|
|
9149
9216
|
ready = _f.ready,
|
|
9150
9217
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
@@ -9477,14 +9544,8 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
9477
9544
|
prediction = _t.prediction,
|
|
9478
9545
|
dispatch = _s[1];
|
|
9479
9546
|
var lastPredictionCanvas = useRef(null);
|
|
9480
|
-
var _u =
|
|
9481
|
-
|
|
9482
|
-
camera: state.camera,
|
|
9483
|
-
cameraReady: state.cameraReady,
|
|
9484
|
-
videoRef: state.videoRef
|
|
9485
|
-
};
|
|
9486
|
-
})),
|
|
9487
|
-
camera = _u.camera,
|
|
9547
|
+
var _u = useContext(CameraStateContext),
|
|
9548
|
+
cameraRef = _u.cameraRef,
|
|
9488
9549
|
videoRef = _u.videoRef;
|
|
9489
9550
|
var _v = useContext(SelfieGuidanceModelsContext),
|
|
9490
9551
|
onPredictionMade = _v.onPredictionMade,
|
|
@@ -9574,7 +9635,7 @@ var SelfieCapture = function SelfieCapture(_a) {
|
|
|
9574
9635
|
face: prediction.face,
|
|
9575
9636
|
scaling: debugScalingDetails,
|
|
9576
9637
|
color: satisfied ? 'green' : 'red'
|
|
9577
|
-
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null,
|
|
9638
|
+
}))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.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, {
|
|
9578
9639
|
onClick: onExit,
|
|
9579
9640
|
className: classNames.exitCaptureBtn
|
|
9580
9641
|
}));
|
|
@@ -10030,9 +10091,7 @@ var MicrophoneAccessDeniedOverlay = function MicrophoneAccessDeniedOverlay(_a) {
|
|
|
10030
10091
|
colors = _e === void 0 ? {} : _e,
|
|
10031
10092
|
_f = _a.verbiage,
|
|
10032
10093
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
10033
|
-
var requestMicrophoneAccess =
|
|
10034
|
-
return state.requestMicrophoneAccess;
|
|
10035
|
-
});
|
|
10094
|
+
var requestMicrophoneAccess = useContext(CameraStateContext).requestMicrophoneAccess;
|
|
10036
10095
|
assets.imageUrl || (assets.imageUrl = DEFAULT_CDN_URL + '/microphone-disable-icon.svg');
|
|
10037
10096
|
var verbiage = useTranslations(rawVerbiage, {
|
|
10038
10097
|
headingText: 'Your microphone permission is disabled',
|
|
@@ -10080,13 +10139,7 @@ var SelfieCaptureLoadingOverlayLegacy = function SelfieCaptureLoadingOverlayLega
|
|
|
10080
10139
|
colors = _e === void 0 ? {} : _e,
|
|
10081
10140
|
_f = _a.verbiage,
|
|
10082
10141
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
10083
|
-
var _g =
|
|
10084
|
-
return {
|
|
10085
|
-
cameraReady: state.cameraReady,
|
|
10086
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
10087
|
-
microphoneAccessDenied: state.microphoneAccessDenied
|
|
10088
|
-
};
|
|
10089
|
-
})),
|
|
10142
|
+
var _g = useContext(CameraStateContext),
|
|
10090
10143
|
cameraReady = _g.cameraReady,
|
|
10091
10144
|
cameraAccessDenied = _g.cameraAccessDenied,
|
|
10092
10145
|
microphoneAccessDenied = _g.microphoneAccessDenied;
|
|
@@ -10173,13 +10226,7 @@ var SelfieCaptureLoadingOverlayDefault = function SelfieCaptureLoadingOverlayDef
|
|
|
10173
10226
|
colors = _e === void 0 ? {} : _e,
|
|
10174
10227
|
_f = _a.verbiage,
|
|
10175
10228
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
10176
|
-
var _g =
|
|
10177
|
-
return {
|
|
10178
|
-
cameraReady: state.cameraReady,
|
|
10179
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
10180
|
-
microphoneAccessDenied: state.microphoneAccessDenied
|
|
10181
|
-
};
|
|
10182
|
-
})),
|
|
10229
|
+
var _g = useContext(CameraStateContext),
|
|
10183
10230
|
cameraReady = _g.cameraReady,
|
|
10184
10231
|
cameraAccessDenied = _g.cameraAccessDenied,
|
|
10185
10232
|
microphoneAccessDenied = _g.microphoneAccessDenied;
|
|
@@ -10396,13 +10443,7 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
|
|
|
10396
10443
|
livenessCheckRequest = _t.livenessCheckRequest,
|
|
10397
10444
|
setSelfieImage = _t.setSelfieImage,
|
|
10398
10445
|
logSelfieCaptureAttempt = _t.logSelfieCaptureAttempt;
|
|
10399
|
-
var _u =
|
|
10400
|
-
return {
|
|
10401
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
10402
|
-
requestCameraAccess: state.requestCameraAccess,
|
|
10403
|
-
releaseCameraAccess: state.releaseCameraAccess
|
|
10404
|
-
};
|
|
10405
|
-
})),
|
|
10446
|
+
var _u = useContext(CameraStateContext),
|
|
10406
10447
|
cameraAccessDenied = _u.cameraAccessDenied,
|
|
10407
10448
|
requestCameraAccess = _u.requestCameraAccess,
|
|
10408
10449
|
releaseCameraAccess = _u.releaseCameraAccess;
|
|
@@ -11123,10 +11164,10 @@ function VideoSignatureContextProvider(_a) {
|
|
|
11123
11164
|
setSignatureVideoUrl = _e[1];
|
|
11124
11165
|
var signatureRecorder = useRef(null);
|
|
11125
11166
|
var recordedChunks = useRef([]);
|
|
11126
|
-
var _f =
|
|
11127
|
-
|
|
11167
|
+
var _f = useContext(CameraStateContext),
|
|
11168
|
+
cameraRef = _f.cameraRef,
|
|
11128
11169
|
videoRef = _f.videoRef;
|
|
11129
|
-
var _g = useVideoRecorder(
|
|
11170
|
+
var _g = useVideoRecorder(cameraRef.current),
|
|
11130
11171
|
isRecordingVideo = _g.isRecordingVideo,
|
|
11131
11172
|
startRecordingVideo = _g.startRecordingVideo,
|
|
11132
11173
|
stopRecordingVideo = _g.stopRecordingVideo,
|
|
@@ -11194,8 +11235,8 @@ function VideoSignatureContextProvider(_a) {
|
|
|
11194
11235
|
var animationFrame = useRef(0);
|
|
11195
11236
|
useEffect(function () {
|
|
11196
11237
|
var _a;
|
|
11197
|
-
if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !
|
|
11198
|
-
var _b = [
|
|
11238
|
+
if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !cameraRef.current || !isRecording || !isRecordingVideo) return;
|
|
11239
|
+
var _b = [cameraRef.current.width, cameraRef.current.height],
|
|
11199
11240
|
w = _b[0],
|
|
11200
11241
|
h = _b[1];
|
|
11201
11242
|
var isPortrait = typeof window !== 'undefined' && window.innerWidth < window.innerHeight;
|
|
@@ -11228,7 +11269,7 @@ function VideoSignatureContextProvider(_a) {
|
|
|
11228
11269
|
return function () {
|
|
11229
11270
|
cancelAnimationFrame(animationFrame.current);
|
|
11230
11271
|
};
|
|
11231
|
-
}, [
|
|
11272
|
+
}, [cameraRef, isRecording, isRecordingVideo, videoRef]);
|
|
11232
11273
|
var onAcceptClicked = useCallback(function () {
|
|
11233
11274
|
return __awaiter(_this, void 0, void 0, function () {
|
|
11234
11275
|
var imageUrl;
|
|
@@ -11357,29 +11398,27 @@ var AcceptBtn = styled(LoaderButton)(templateObject_7$1 || (templateObject_7$1 =
|
|
|
11357
11398
|
var templateObject_1$9, templateObject_2$8, templateObject_3$8, templateObject_4$3, templateObject_5$2, templateObject_6$2, templateObject_7$1;
|
|
11358
11399
|
|
|
11359
11400
|
var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
11360
|
-
var _b;
|
|
11401
|
+
var _b, _c, _d;
|
|
11361
11402
|
var onVideoCaptured = _a.onVideoCaptured,
|
|
11362
11403
|
onFaceNotDetected = _a.onFaceNotDetected,
|
|
11363
11404
|
onExit = _a.onExit,
|
|
11364
11405
|
guidesComponent = _a.guidesComponent,
|
|
11365
|
-
|
|
11366
|
-
classNames =
|
|
11367
|
-
|
|
11368
|
-
colors =
|
|
11369
|
-
|
|
11370
|
-
rawVerbiage =
|
|
11371
|
-
|
|
11372
|
-
debugMode =
|
|
11373
|
-
var
|
|
11374
|
-
return state.camera;
|
|
11375
|
-
});
|
|
11406
|
+
_e = _a.classNames,
|
|
11407
|
+
classNames = _e === void 0 ? {} : _e,
|
|
11408
|
+
_f = _a.colors,
|
|
11409
|
+
colors = _f === void 0 ? {} : _f,
|
|
11410
|
+
_g = _a.verbiage,
|
|
11411
|
+
rawVerbiage = _g === void 0 ? {} : _g,
|
|
11412
|
+
_h = _a.debugMode,
|
|
11413
|
+
debugMode = _h === void 0 ? false : _h;
|
|
11414
|
+
var cameraRef = useContext(CameraStateContext).cameraRef;
|
|
11376
11415
|
var onPredictionMade = useContext(SelfieGuidanceModelsContext).onPredictionMade;
|
|
11377
|
-
var
|
|
11378
|
-
signatureData =
|
|
11379
|
-
signatureDataUrl =
|
|
11380
|
-
signatureVideoData =
|
|
11381
|
-
startRecording =
|
|
11382
|
-
stopRecording =
|
|
11416
|
+
var _j = useVideoSignatureContext(),
|
|
11417
|
+
signatureData = _j.signatureData,
|
|
11418
|
+
signatureDataUrl = _j.signatureDataUrl,
|
|
11419
|
+
signatureVideoData = _j.signatureVideoData,
|
|
11420
|
+
startRecording = _j.startRecording,
|
|
11421
|
+
stopRecording = _j.stopRecording;
|
|
11383
11422
|
useEffect(function () {
|
|
11384
11423
|
startRecording();
|
|
11385
11424
|
return function () {
|
|
@@ -11396,9 +11435,9 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
11396
11435
|
onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(signatureVideoData, signatureData, signatureDataUrl);
|
|
11397
11436
|
}
|
|
11398
11437
|
}, [onVideoCaptured, signatureData, signatureDataUrl, signatureVideoData]);
|
|
11399
|
-
var
|
|
11400
|
-
numFramesWithoutFaces =
|
|
11401
|
-
setNumFramesWithoutFaces =
|
|
11438
|
+
var _k = useState(0),
|
|
11439
|
+
numFramesWithoutFaces = _k[0],
|
|
11440
|
+
setNumFramesWithoutFaces = _k[1];
|
|
11402
11441
|
useEffect(function () {
|
|
11403
11442
|
onPredictionMade(function (_a) {
|
|
11404
11443
|
var face = _a.face;
|
|
@@ -11425,7 +11464,7 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
|
11425
11464
|
}, verbiage.guidanceMessageText))), /*#__PURE__*/React__default.createElement(GuidesComponent, {
|
|
11426
11465
|
classNames: classNames.videoSignatureGuidesClassNames,
|
|
11427
11466
|
status: "success"
|
|
11428
|
-
}), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, "Video: ",
|
|
11467
|
+
}), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, "Video: ", (_c = cameraRef.current) === null || _c === void 0 ? void 0 : _c.width, "x", (_d = cameraRef.current) === null || _d === void 0 ? void 0 : _d.height)), /*#__PURE__*/React__default.createElement(ExitCaptureButton, {
|
|
11429
11468
|
onClick: onExit,
|
|
11430
11469
|
className: classNames.exitCaptureBtn
|
|
11431
11470
|
}));
|
|
@@ -11519,13 +11558,7 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
|
|
|
11519
11558
|
setSignatureData = _l.setSignatureData,
|
|
11520
11559
|
setSignatureVideoUrl = _l.setSignatureVideoUrl,
|
|
11521
11560
|
logSelfieCaptureAttempt = _l.logSelfieCaptureAttempt;
|
|
11522
|
-
var _m =
|
|
11523
|
-
return {
|
|
11524
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
11525
|
-
requestCameraAccess: state.requestCameraAccess,
|
|
11526
|
-
releaseCameraAccess: state.releaseCameraAccess
|
|
11527
|
-
};
|
|
11528
|
-
})),
|
|
11561
|
+
var _m = useContext(CameraStateContext),
|
|
11529
11562
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
11530
11563
|
requestCameraAccess = _m.requestCameraAccess,
|
|
11531
11564
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
@@ -11685,29 +11718,27 @@ var VideoSignatureWizard = function VideoSignatureWizard(_a) {
|
|
|
11685
11718
|
};
|
|
11686
11719
|
|
|
11687
11720
|
var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
11688
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
11689
|
-
var
|
|
11690
|
-
requestedAction =
|
|
11691
|
-
|
|
11692
|
-
satisfied =
|
|
11693
|
-
|
|
11694
|
-
faceGuideStatus =
|
|
11721
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
11722
|
+
var _0 = _a.requestedAction,
|
|
11723
|
+
requestedAction = _0 === void 0 ? 'SHOW_ID_FRONT' : _0,
|
|
11724
|
+
_1 = _a.satisfied,
|
|
11725
|
+
satisfied = _1 === void 0 ? false : _1,
|
|
11726
|
+
_2 = _a.faceGuideStatus,
|
|
11727
|
+
faceGuideStatus = _2 === void 0 ? 'success' : _2,
|
|
11695
11728
|
faceGuideBorderWidth = _a.faceGuideBorderWidth,
|
|
11696
11729
|
faceGuideBorderColor = _a.faceGuideBorderColor,
|
|
11697
|
-
|
|
11698
|
-
idCardGuideStatus =
|
|
11730
|
+
_3 = _a.idCardGuideStatus,
|
|
11731
|
+
idCardGuideStatus = _3 === void 0 ? 'ready' : _3,
|
|
11699
11732
|
idCardGuideBorderWidth = _a.idCardGuideBorderWidth,
|
|
11700
11733
|
idCardGuideBorderColor = _a.idCardGuideBorderColor,
|
|
11701
11734
|
idCardCaptureProgress = _a.idCardCaptureProgress,
|
|
11702
|
-
|
|
11703
|
-
userSuppliedImages =
|
|
11704
|
-
|
|
11705
|
-
classNames =
|
|
11706
|
-
|
|
11707
|
-
rawVerbiage =
|
|
11708
|
-
var
|
|
11709
|
-
return state.isRearFacing;
|
|
11710
|
-
});
|
|
11735
|
+
_4 = _a.idCardCaptureGuideImages,
|
|
11736
|
+
userSuppliedImages = _4 === void 0 ? defaultIdCaptureGuideImages : _4,
|
|
11737
|
+
_5 = _a.classNames,
|
|
11738
|
+
classNames = _5 === void 0 ? {} : _5,
|
|
11739
|
+
_6 = _a.verbiage,
|
|
11740
|
+
rawVerbiage = _6 === void 0 ? {} : _6;
|
|
11741
|
+
var cameraRef = useContext(CameraStateContext).cameraRef;
|
|
11711
11742
|
var verbiage = useTranslations(rawVerbiage, {
|
|
11712
11743
|
idFrontInstructionText: 'Display the front of your ID card...',
|
|
11713
11744
|
idBackInstructionText: 'Display the back of your ID card...',
|
|
@@ -11720,17 +11751,17 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
|
11720
11751
|
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';
|
|
11721
11752
|
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;
|
|
11722
11753
|
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';
|
|
11723
|
-
var
|
|
11724
|
-
idCardGuideRef =
|
|
11725
|
-
|
|
11726
|
-
idCardGuideWidth =
|
|
11727
|
-
|
|
11728
|
-
idCardGuideHeight =
|
|
11754
|
+
var _7 = useResizeObserver(),
|
|
11755
|
+
idCardGuideRef = _7.ref,
|
|
11756
|
+
_8 = _7.width,
|
|
11757
|
+
idCardGuideWidth = _8 === void 0 ? 0 : _8,
|
|
11758
|
+
_9 = _7.height,
|
|
11759
|
+
idCardGuideHeight = _9 === void 0 ? 0 : _9;
|
|
11729
11760
|
var idCaptureGuideImages = useGuideImages(userSuppliedImages);
|
|
11730
11761
|
var idCaptureGuideImagesByUrl = useGuideImagesByUrl(idCaptureGuideImages);
|
|
11731
|
-
var
|
|
11732
|
-
aspectRatio =
|
|
11733
|
-
setAspectRatio =
|
|
11762
|
+
var _10 = useState(undefined),
|
|
11763
|
+
aspectRatio = _10[0],
|
|
11764
|
+
setAspectRatio = _10[1];
|
|
11734
11765
|
var onImageLoaded = useCallback(function (e) {
|
|
11735
11766
|
var _a, _b, _c, _d;
|
|
11736
11767
|
var img = e.currentTarget;
|
|
@@ -11777,7 +11808,7 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
|
11777
11808
|
}, /*#__PURE__*/React__default.createElement(IdCardGuideImage, {
|
|
11778
11809
|
alt: "",
|
|
11779
11810
|
className: classNames.idCardGuideImage,
|
|
11780
|
-
"$isMirrored": !isRearFacing,
|
|
11811
|
+
"$isMirrored": !((_v = cameraRef.current) === null || _v === void 0 ? void 0 : _v.isRearFacing),
|
|
11781
11812
|
style: idCardImageStyle,
|
|
11782
11813
|
src: requestedAction === 'SHOW_ID_BACK' ? idCaptureGuideImages.landscape.SHOW_ID_BACK.url : idCaptureGuideImages.landscape.SHOW_ID_FRONT.url,
|
|
11783
11814
|
onLoad: onImageLoaded
|
|
@@ -11791,8 +11822,8 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
|
11791
11822
|
className: classNames.idCardGuideInstructionsContainer
|
|
11792
11823
|
}, /*#__PURE__*/React__default.createElement(IdCardGuideInstructions, {
|
|
11793
11824
|
className: classNames.idCardGuideInstructions,
|
|
11794
|
-
"$textColor": (
|
|
11795
|
-
"$background": (
|
|
11825
|
+
"$textColor": (_x = (_w = theme.idVideoCapture) === null || _w === void 0 ? void 0 : _w.idCardGuides) === null || _x === void 0 ? void 0 : _x.instructionsTextColor,
|
|
11826
|
+
"$background": (_z = (_y = theme.idVideoCapture) === null || _y === void 0 ? void 0 : _y.idCardGuides) === null || _z === void 0 ? void 0 : _z.instructionsBackgroundColor
|
|
11796
11827
|
}, instructionText))))));
|
|
11797
11828
|
};
|
|
11798
11829
|
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) {
|
|
@@ -11937,100 +11968,99 @@ var defaultVideoIdCaptureThresholds = {
|
|
|
11937
11968
|
flipShortcutThreshold: 0.7
|
|
11938
11969
|
};
|
|
11939
11970
|
var IdVideoCapture = function IdVideoCapture(_a) {
|
|
11940
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
11971
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
11941
11972
|
var onComplete = _a.onComplete,
|
|
11942
11973
|
onIdFrontImageCaptured = _a.onIdFrontImageCaptured,
|
|
11943
11974
|
onIdBackImageCaptured = _a.onIdBackImageCaptured,
|
|
11944
11975
|
onFaceNotDetected = _a.onFaceNotDetected,
|
|
11945
11976
|
onRecordingFailed = _a.onRecordingFailed,
|
|
11946
11977
|
onExitCapture = _a.onExitCapture,
|
|
11947
|
-
|
|
11948
|
-
idCaptureModelsEnabled =
|
|
11949
|
-
|
|
11950
|
-
idCardCaptureGuideImages =
|
|
11951
|
-
|
|
11952
|
-
idCardFrontDelay =
|
|
11953
|
-
|
|
11954
|
-
videoIdCaptureThresholds =
|
|
11955
|
-
|
|
11956
|
-
skipShowIdCardBack =
|
|
11957
|
-
|
|
11958
|
-
captureCountdownSeconds =
|
|
11978
|
+
_x = _a.idCaptureModelsEnabled,
|
|
11979
|
+
idCaptureModelsEnabled = _x === void 0 ? true : _x,
|
|
11980
|
+
_y = _a.idCardCaptureGuideImages,
|
|
11981
|
+
idCardCaptureGuideImages = _y === void 0 ? defaultIdCaptureGuideImages : _y,
|
|
11982
|
+
_z = _a.idCardFrontDelay,
|
|
11983
|
+
idCardFrontDelay = _z === void 0 ? 1000 : _z,
|
|
11984
|
+
_0 = _a.videoIdCaptureThresholds,
|
|
11985
|
+
videoIdCaptureThresholds = _0 === void 0 ? defaultVideoIdCaptureThresholds : _0,
|
|
11986
|
+
_1 = _a.skipShowIdCardBack,
|
|
11987
|
+
skipShowIdCardBack = _1 === void 0 ? false : _1,
|
|
11988
|
+
_2 = _a.captureCountdownSeconds,
|
|
11989
|
+
captureCountdownSeconds = _2 === void 0 ? 3 : _2,
|
|
11959
11990
|
readTextPrompt = _a.readTextPrompt,
|
|
11960
|
-
|
|
11961
|
-
readTextTimeoutDurationMs =
|
|
11962
|
-
|
|
11963
|
-
readTextMinReadingMs =
|
|
11964
|
-
|
|
11965
|
-
disableFaceDetectionWhileAudioCapture =
|
|
11966
|
-
|
|
11967
|
-
disableFaceDetectionWhileAudioCaptureMsDelay =
|
|
11968
|
-
|
|
11969
|
-
mergeAVStreams =
|
|
11970
|
-
|
|
11971
|
-
classNames =
|
|
11972
|
-
|
|
11973
|
-
colors =
|
|
11974
|
-
|
|
11975
|
-
rawVerbiage =
|
|
11976
|
-
|
|
11977
|
-
debugMode =
|
|
11978
|
-
var
|
|
11979
|
-
ref =
|
|
11980
|
-
|
|
11981
|
-
width =
|
|
11982
|
-
|
|
11983
|
-
height =
|
|
11984
|
-
var
|
|
11985
|
-
|
|
11986
|
-
videoRef =
|
|
11987
|
-
videoLoaded =
|
|
11988
|
-
cameraReady =
|
|
11989
|
-
microphoneReady =
|
|
11990
|
-
audioStream =
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
|
|
11995
|
-
|
|
11996
|
-
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
|
|
12000
|
-
|
|
12001
|
-
|
|
12002
|
-
|
|
12003
|
-
|
|
12004
|
-
|
|
12005
|
-
|
|
12006
|
-
|
|
12007
|
-
|
|
12008
|
-
|
|
12009
|
-
|
|
12010
|
-
|
|
12011
|
-
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
|
|
12015
|
-
|
|
12016
|
-
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12023
|
-
|
|
12024
|
-
|
|
12025
|
-
|
|
12026
|
-
|
|
12027
|
-
|
|
12028
|
-
|
|
12029
|
-
audioUrl = _21.audioUrl;
|
|
11991
|
+
_3 = _a.readTextTimeoutDurationMs,
|
|
11992
|
+
readTextTimeoutDurationMs = _3 === void 0 ? 15000 : _3,
|
|
11993
|
+
_4 = _a.readTextMinReadingMs,
|
|
11994
|
+
readTextMinReadingMs = _4 === void 0 ? 10000 : _4,
|
|
11995
|
+
_5 = _a.disableFaceDetectionWhileAudioCapture,
|
|
11996
|
+
disableFaceDetectionWhileAudioCapture = _5 === void 0 ? false : _5,
|
|
11997
|
+
_6 = _a.disableFaceDetectionWhileAudioCaptureMsDelay,
|
|
11998
|
+
disableFaceDetectionWhileAudioCaptureMsDelay = _6 === void 0 ? 2000 : _6,
|
|
11999
|
+
_7 = _a.mergeAVStreams,
|
|
12000
|
+
mergeAVStreams = _7 === void 0 ? false : _7,
|
|
12001
|
+
_8 = _a.classNames,
|
|
12002
|
+
classNames = _8 === void 0 ? {} : _8,
|
|
12003
|
+
_9 = _a.colors,
|
|
12004
|
+
colors = _9 === void 0 ? {} : _9,
|
|
12005
|
+
_10 = _a.verbiage,
|
|
12006
|
+
rawVerbiage = _10 === void 0 ? {} : _10,
|
|
12007
|
+
_11 = _a.debugMode,
|
|
12008
|
+
debugMode = _11 === void 0 ? false : _11;
|
|
12009
|
+
var _12 = useResizeObserver(),
|
|
12010
|
+
ref = _12.ref,
|
|
12011
|
+
_13 = _12.width,
|
|
12012
|
+
width = _13 === void 0 ? 1 : _13,
|
|
12013
|
+
_14 = _12.height,
|
|
12014
|
+
height = _14 === void 0 ? 1 : _14;
|
|
12015
|
+
var _15 = useContext(CameraStateContext),
|
|
12016
|
+
cameraRef = _15.cameraRef,
|
|
12017
|
+
videoRef = _15.videoRef,
|
|
12018
|
+
videoLoaded = _15.videoLoaded,
|
|
12019
|
+
cameraReady = _15.cameraReady,
|
|
12020
|
+
microphoneReady = _15.microphoneReady,
|
|
12021
|
+
audioStream = _15.audioStream,
|
|
12022
|
+
setVideoLoaded = _15.setVideoLoaded;
|
|
12023
|
+
var _16 = useState([]),
|
|
12024
|
+
detectedObjects = _16[0],
|
|
12025
|
+
setDetectedObjects = _16[1];
|
|
12026
|
+
var _17 = useState(null),
|
|
12027
|
+
face = _17[0],
|
|
12028
|
+
setFace = _17[1];
|
|
12029
|
+
var _18 = useContext(IdCaptureModelsContext),
|
|
12030
|
+
idModelsReady = _18.ready,
|
|
12031
|
+
startIdModels = _18.start,
|
|
12032
|
+
stopIdModels = _18.stop,
|
|
12033
|
+
onIdPredictionMade = _18.onPredictionMade,
|
|
12034
|
+
setThresholds = _18.setThresholds,
|
|
12035
|
+
setDocumentDetectionBoundaries = _18.setDocumentDetectionBoundaries,
|
|
12036
|
+
bestFrameDetails = _18.bestFrameDetails,
|
|
12037
|
+
resetBestFrame = _18.resetBestFrame,
|
|
12038
|
+
idModelError = _18.modelError;
|
|
12039
|
+
var _19 = useState(null),
|
|
12040
|
+
videoStartsAt = _19[0],
|
|
12041
|
+
setVideoStartsAt = _19[1];
|
|
12042
|
+
var _20 = useContext(SubmissionContext),
|
|
12043
|
+
setIdCaptureVideoAudioStartsAt = _20.setIdCaptureVideoAudioStartsAt,
|
|
12044
|
+
setExpectedAudioText = _20.setExpectedAudioText;
|
|
12045
|
+
var _21 = useContext(SelfieGuidanceModelsContext),
|
|
12046
|
+
startSelfieGuidance = _21.start,
|
|
12047
|
+
stopSelfieGuidance = _21.stop,
|
|
12048
|
+
onSelfiePredictionMade = _21.onPredictionMade,
|
|
12049
|
+
selfieModelError = _21.error;
|
|
12050
|
+
var _22 = useVideoRecorder(cameraRef.current, audioStream, mergeAVStreams),
|
|
12051
|
+
isRecordingVideo = _22.isRecordingVideo,
|
|
12052
|
+
startRecordingVideo = _22.startRecordingVideo,
|
|
12053
|
+
startRecordingAudio = _22.startRecordingAudio,
|
|
12054
|
+
stopRecordingVideo = _22.stopRecordingVideo,
|
|
12055
|
+
stopRecordingAudio = _22.stopRecordingAudio,
|
|
12056
|
+
videoRecordingUnintentionallyStopped = _22.videoRecordingUnintentionallyStopped,
|
|
12057
|
+
audioRecordingUnintentionallyStopped = _22.audioRecordingUnintentionallyStopped,
|
|
12058
|
+
videoUrl = _22.videoUrl,
|
|
12059
|
+
audioUrl = _22.audioUrl;
|
|
12030
12060
|
var countdownTimeoutRef = useRef(undefined);
|
|
12031
|
-
var
|
|
12032
|
-
countdownRemaining =
|
|
12033
|
-
setCountdownRemaining =
|
|
12061
|
+
var _23 = useState(-1),
|
|
12062
|
+
countdownRemaining = _23[0],
|
|
12063
|
+
setCountdownRemaining = _23[1];
|
|
12034
12064
|
useEffect(function () {
|
|
12035
12065
|
if (!isRecordingVideo && !videoUrl) {
|
|
12036
12066
|
startRecordingVideo();
|
|
@@ -12041,18 +12071,18 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12041
12071
|
var needsAudio = !!readTextPrompt && !mergeAVStreams;
|
|
12042
12072
|
var audioReady = !needsAudio || audioUrl;
|
|
12043
12073
|
if (videoUrl && audioReady) {
|
|
12044
|
-
|
|
12074
|
+
setVideoLoaded(false);
|
|
12045
12075
|
onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl, audioUrl);
|
|
12046
12076
|
}
|
|
12047
|
-
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt,
|
|
12077
|
+
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, setVideoLoaded, startRecordingVideo, videoUrl]);
|
|
12048
12078
|
useEffect(function () {
|
|
12049
12079
|
if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped) {
|
|
12050
12080
|
onRecordingFailed === null || onRecordingFailed === void 0 ? void 0 : onRecordingFailed();
|
|
12051
12081
|
}
|
|
12052
12082
|
}, [audioRecordingUnintentionallyStopped, onRecordingFailed, videoRecordingUnintentionallyStopped]);
|
|
12053
|
-
var
|
|
12054
|
-
requestedAction =
|
|
12055
|
-
setRequestedAction =
|
|
12083
|
+
var _24 = useState('SHOW_ID_FRONT'),
|
|
12084
|
+
requestedAction = _24[0],
|
|
12085
|
+
setRequestedAction = _24[1];
|
|
12056
12086
|
var shouldRunIdModels = idCaptureModelsEnabled && videoLoaded && cameraReady && idModelsReady && !idModelError && requestedAction !== 'READ_TEXT' && (!readTextPrompt || microphoneReady);
|
|
12057
12087
|
useEffect(function startModelsWhenCapturing() {
|
|
12058
12088
|
if (!shouldRunIdModels) return;
|
|
@@ -12072,18 +12102,18 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12072
12102
|
bottom: 1
|
|
12073
12103
|
});
|
|
12074
12104
|
}, [setDocumentDetectionBoundaries]);
|
|
12075
|
-
var
|
|
12076
|
-
currentDetectionScore =
|
|
12077
|
-
setCurrentDetectionScore =
|
|
12078
|
-
var
|
|
12079
|
-
currentDetectedDocumentType =
|
|
12080
|
-
setCurrentDetectedDocumentType =
|
|
12081
|
-
var _26 = useState(0),
|
|
12082
|
-
currentFocusScore = _26[0],
|
|
12083
|
-
setCurrentFocusScore = _26[1];
|
|
12105
|
+
var _25 = useState(0),
|
|
12106
|
+
currentDetectionScore = _25[0],
|
|
12107
|
+
setCurrentDetectionScore = _25[1];
|
|
12108
|
+
var _26 = useState('none'),
|
|
12109
|
+
currentDetectedDocumentType = _26[0],
|
|
12110
|
+
setCurrentDetectedDocumentType = _26[1];
|
|
12084
12111
|
var _27 = useState(0),
|
|
12085
|
-
|
|
12086
|
-
|
|
12112
|
+
currentFocusScore = _27[0],
|
|
12113
|
+
setCurrentFocusScore = _27[1];
|
|
12114
|
+
var _28 = useState(0),
|
|
12115
|
+
goodFramesCount = _28[0],
|
|
12116
|
+
setGoodFramesCount = _28[1];
|
|
12087
12117
|
var goodFramesThreshold = requestedAction === 'SHOW_ID_FRONT' ? videoIdCaptureThresholds.goodFrames.idCardFront : videoIdCaptureThresholds.goodFrames.idCardBack;
|
|
12088
12118
|
var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
|
|
12089
12119
|
useEffect(function () {
|
|
@@ -12104,9 +12134,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12104
12134
|
} : 0);
|
|
12105
12135
|
});
|
|
12106
12136
|
}, [idCaptureModelsEnabled, onIdPredictionMade, idModelError, requestedAction, videoIdCaptureThresholds.flipShortcutThreshold]);
|
|
12107
|
-
var
|
|
12108
|
-
idFrontCaptureStartedAt =
|
|
12109
|
-
setFirstGoodFrameTime =
|
|
12137
|
+
var _29 = useState(null),
|
|
12138
|
+
idFrontCaptureStartedAt = _29[0],
|
|
12139
|
+
setFirstGoodFrameTime = _29[1];
|
|
12110
12140
|
useEffect(function () {
|
|
12111
12141
|
if (goodFramesCount === 1) setFirstGoodFrameTime(new Date().getTime());
|
|
12112
12142
|
}, [goodFramesCount]);
|
|
@@ -12127,9 +12157,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12127
12157
|
var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
|
|
12128
12158
|
var faceBox = face === null || face === void 0 ? void 0 : face.box;
|
|
12129
12159
|
var faceCentered = !faceBox || !frameWidth || faceBox.xMin > frameWidth * edgeBoundary && faceBox.yMin > frameHeight * edgeBoundary && faceBox.xMax < frameWidth * (1 - edgeBoundary) && faceBox.yMax < frameHeight * (1 - edgeBoundary);
|
|
12130
|
-
var
|
|
12131
|
-
countdownStartedAt =
|
|
12132
|
-
setCountdownStartedAt =
|
|
12160
|
+
var _30 = useState(),
|
|
12161
|
+
countdownStartedAt = _30[0],
|
|
12162
|
+
setCountdownStartedAt = _30[1];
|
|
12133
12163
|
var photoCanvas = useRef(null);
|
|
12134
12164
|
var frameLock = useRef(false);
|
|
12135
12165
|
var captureFrame = useCallback(function () {
|
|
@@ -12252,9 +12282,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12252
12282
|
stopSelfieGuidance();
|
|
12253
12283
|
};
|
|
12254
12284
|
}, [startSelfieGuidance, stopSelfieGuidance]);
|
|
12255
|
-
var
|
|
12256
|
-
numFramesWithoutFaces =
|
|
12257
|
-
setNumFramesWithoutFaces =
|
|
12285
|
+
var _31 = useState(0),
|
|
12286
|
+
numFramesWithoutFaces = _31[0],
|
|
12287
|
+
setNumFramesWithoutFaces = _31[1];
|
|
12258
12288
|
onSelfiePredictionMade(useThrottledCallback(useCallback(function (_a) {
|
|
12259
12289
|
var face = _a.face;
|
|
12260
12290
|
if (selfieModelError) return;
|
|
@@ -12270,12 +12300,12 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12270
12300
|
}
|
|
12271
12301
|
}, [disableFaceDetectionWhileAudioCapture, disableFaceDetectionWhileAudioCaptureMsDelay, numFramesWithoutFaces, onFaceNotDetected, timeoutStartedAt]);
|
|
12272
12302
|
var theme = useTheme();
|
|
12273
|
-
var
|
|
12303
|
+
var _32 = useTranslations(rawVerbiage, {
|
|
12274
12304
|
faceNotCenteredText: 'Please move your face to the center...',
|
|
12275
12305
|
captureBtnText: 'Capture'
|
|
12276
12306
|
}),
|
|
12277
|
-
captureBtnText =
|
|
12278
|
-
faceNotCenteredText =
|
|
12307
|
+
captureBtnText = _32.captureBtnText,
|
|
12308
|
+
faceNotCenteredText = _32.faceNotCenteredText;
|
|
12279
12309
|
var debugScalingDetails = useDebugScalingDetails({
|
|
12280
12310
|
enabled: debugMode,
|
|
12281
12311
|
pageWidth: width,
|
|
@@ -12311,14 +12341,15 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12311
12341
|
faceGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor,
|
|
12312
12342
|
idCardGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor
|
|
12313
12343
|
}), debugMode && capturingId && ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ObjectDetectionDebugOverlayDiv, {
|
|
12314
|
-
"$flipX": !isRearFacing
|
|
12344
|
+
"$flipX": !((_l = cameraRef.current) === null || _l === void 0 ? void 0 : _l.isRearFacing)
|
|
12315
12345
|
}, detectedObjects.map(function (obj, i) {
|
|
12346
|
+
var _a;
|
|
12316
12347
|
return /*#__PURE__*/React__default.createElement(IdCaptureDetectedObjectDebugBox, {
|
|
12317
12348
|
key: i,
|
|
12318
12349
|
obj: obj,
|
|
12319
12350
|
scaling: debugScalingDetails,
|
|
12320
12351
|
color: "blue",
|
|
12321
|
-
flipX: !isRearFacing
|
|
12352
|
+
flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing)
|
|
12322
12353
|
});
|
|
12323
12354
|
})), /*#__PURE__*/React__default.createElement(DebugBoundingBoxOverlay, null, face && ( /*#__PURE__*/React__default.createElement(SelfieCaptureFaceDebugBox, {
|
|
12324
12355
|
face: face,
|
|
@@ -12327,9 +12358,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
|
|
|
12327
12358
|
className: classNames.guidanceMessageContainer
|
|
12328
12359
|
}, /*#__PURE__*/React__default.createElement(GuidanceMessage, {
|
|
12329
12360
|
className: classNames.guidanceMessage,
|
|
12330
|
-
"$background": (
|
|
12331
|
-
"$textColor": (
|
|
12332
|
-
}, guidanceText))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null,
|
|
12361
|
+
"$background": (_p = (_o = (_m = theme.guidanceMessages) === null || _m === void 0 ? void 0 : _m.negative) === null || _o === void 0 ? void 0 : _o.backgroundColor) !== null && _p !== void 0 ? _p : 'red',
|
|
12362
|
+
"$textColor": (_s = (_r = (_q = theme.guidanceMessages) === null || _q === void 0 ? void 0 : _q.negative) === null || _r === void 0 ? void 0 : _r.textColor) !== null && _s !== void 0 ? _s : 'white'
|
|
12363
|
+
}, guidanceText))), debugMode && ( /*#__PURE__*/React__default.createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.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:", ' ', (_u = (_t = bestFrameDetails.current) === null || _t === void 0 ? void 0 : _t.detectionScore) !== null && _u !== void 0 ? _u : 0, /*#__PURE__*/React__default.createElement("br", null), "Best Frame Focus Score: ", (_w = (_v = bestFrameDetails.current) === null || _v === void 0 ? void 0 : _v.focusScore) !== null && _w !== void 0 ? _w : 0)), countdownRemaining > 0 && capturingId && ( /*#__PURE__*/React__default.createElement(CountdownContainer, {
|
|
12333
12364
|
className: classNames.countdownContainer
|
|
12334
12365
|
}, /*#__PURE__*/React__default.createElement(Countdown, {
|
|
12335
12366
|
className: classNames.countdown
|
|
@@ -12626,14 +12657,16 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
12626
12657
|
className: "flex"
|
|
12627
12658
|
}, /*#__PURE__*/React__default.createElement(Spinner, null));
|
|
12628
12659
|
}
|
|
12629
|
-
return /*#__PURE__*/React__default.createElement(
|
|
12630
|
-
|
|
12660
|
+
return /*#__PURE__*/React__default.createElement(CameraProvider, {
|
|
12661
|
+
key: "".concat(isCapturingId ? 'id' : 'selfie', "-camera-").concat(attempt),
|
|
12662
|
+
preferContinuityCamera: isCapturingId,
|
|
12631
12663
|
preferFrontFacingCamera: !isCapturingId,
|
|
12632
12664
|
requireMicrophoneAccess: !isCapturingId && !!readTextPrompt,
|
|
12633
12665
|
maxVideoWidth: isCapturingId ? 1920 : 1280,
|
|
12634
12666
|
maxFps: isCapturingId ? 60 : 30,
|
|
12635
12667
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12636
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12668
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
12669
|
+
debugMode: debugMode
|
|
12637
12670
|
}, /*#__PURE__*/React__default.createElement(IdCaptureModelsProvider, {
|
|
12638
12671
|
autoStart: false,
|
|
12639
12672
|
documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
|
|
@@ -12644,7 +12677,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
|
|
|
12644
12677
|
autoStart: false,
|
|
12645
12678
|
onModelError: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onModelError,
|
|
12646
12679
|
modelLoadTimeoutMs: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.modelLoadTimeoutMs,
|
|
12647
|
-
requireVerticalFaceCentering:
|
|
12680
|
+
requireVerticalFaceCentering: captureState === 'CHECKING_LIVENESS'
|
|
12648
12681
|
}, /*#__PURE__*/React__default.createElement(PageContainer, {
|
|
12649
12682
|
className: "flex ".concat((_k = classNames.container) !== null && _k !== void 0 ? _k : '')
|
|
12650
12683
|
}, ['CHECKING_LIVENESS', 'CAPTURING_VIDEO'].includes(captureState) && /*#__PURE__*/React__default.createElement(CameraVideoTag, {
|
|
@@ -12759,15 +12792,17 @@ function CompositeWizard(_a) {
|
|
|
12759
12792
|
_o = _a.captureSignatureVideo,
|
|
12760
12793
|
captureSignatureVideo = _o === void 0 ? false : _o,
|
|
12761
12794
|
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
12762
|
-
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12795
|
+
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
|
|
12796
|
+
_p = _a.debugMode,
|
|
12797
|
+
debugMode = _p === void 0 ? false : _p;
|
|
12798
|
+
var _q = useContext(SubmissionContext),
|
|
12799
|
+
submit = _q.submit,
|
|
12800
|
+
submissionStatus = _q.submissionStatus,
|
|
12801
|
+
setSignatureData = _q.setSignatureData,
|
|
12802
|
+
setAdditionalDocuments = _q.setAdditionalDocuments;
|
|
12803
|
+
var _r = useState(0),
|
|
12804
|
+
checkIndex = _r[0],
|
|
12805
|
+
setCheckIndex = _r[1];
|
|
12771
12806
|
var checks = useMemo(function () {
|
|
12772
12807
|
var _a, _b;
|
|
12773
12808
|
var checks = __spreadArray([], userChecks, true);
|
|
@@ -12845,6 +12880,16 @@ function CompositeWizard(_a) {
|
|
|
12845
12880
|
return i + 1;
|
|
12846
12881
|
});
|
|
12847
12882
|
}, [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]);
|
|
12848
12893
|
var onAdditionalDocumentCaptureCompleteProp = additionalDocumentCaptureProps === null || additionalDocumentCaptureProps === void 0 ? void 0 : additionalDocumentCaptureProps.onComplete;
|
|
12849
12894
|
var onAdditionalDocumentCaptureComplete = useCallback(function (uploadedDocuments) {
|
|
12850
12895
|
setAdditionalDocuments(uploadedDocuments);
|
|
@@ -12873,9 +12918,11 @@ function CompositeWizard(_a) {
|
|
|
12873
12918
|
}
|
|
12874
12919
|
switch (checks[checkIndex]) {
|
|
12875
12920
|
case 'IdCapture':
|
|
12876
|
-
return /*#__PURE__*/React__default.createElement(
|
|
12921
|
+
return /*#__PURE__*/React__default.createElement(CameraProvider, {
|
|
12922
|
+
key: "IdCaptureCamera",
|
|
12877
12923
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12878
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12924
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
12925
|
+
debugMode: debugMode
|
|
12879
12926
|
}, /*#__PURE__*/React__default.createElement(IdCaptureModelsProvider, {
|
|
12880
12927
|
autoStart: false,
|
|
12881
12928
|
documentDetectionModelUrl: (_d = (_c = idCaptureProps.assets) === null || _c === void 0 ? void 0 : _c.documentDetectionModelUrl) !== null && _d !== void 0 ? _d : '',
|
|
@@ -12892,11 +12939,13 @@ function CompositeWizard(_a) {
|
|
|
12892
12939
|
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12893
12940
|
}));
|
|
12894
12941
|
case 'FaceLiveness':
|
|
12895
|
-
return /*#__PURE__*/React__default.createElement(
|
|
12942
|
+
return /*#__PURE__*/React__default.createElement(CameraProvider, {
|
|
12943
|
+
key: "FaceLivenessCamera",
|
|
12896
12944
|
preferFrontFacingCamera: true,
|
|
12897
|
-
|
|
12945
|
+
preferContinuityCamera: false,
|
|
12898
12946
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12899
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12947
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
12948
|
+
debugMode: debugMode
|
|
12900
12949
|
}, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
|
|
12901
12950
|
autoStart: false,
|
|
12902
12951
|
onModelError: faceLivenessProps.onModelError,
|
|
@@ -12909,13 +12958,15 @@ function CompositeWizard(_a) {
|
|
|
12909
12958
|
onAccept: onSignatureCaptureSuccess
|
|
12910
12959
|
}));
|
|
12911
12960
|
case 'VideoSignatureCapture':
|
|
12912
|
-
return /*#__PURE__*/React__default.createElement(
|
|
12913
|
-
|
|
12961
|
+
return /*#__PURE__*/React__default.createElement(CameraProvider, {
|
|
12962
|
+
key: "SignatureKycCamera-".concat(videoSignatureAttempts),
|
|
12963
|
+
preferContinuityCamera: false,
|
|
12914
12964
|
preferFrontFacingCamera: true,
|
|
12915
12965
|
maxVideoWidth: 1280,
|
|
12916
12966
|
maxFps: 30,
|
|
12917
12967
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
12918
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
12968
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
12969
|
+
debugMode: debugMode
|
|
12919
12970
|
}, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
|
|
12920
12971
|
autoStart: false,
|
|
12921
12972
|
throttleMs: 250,
|
|
@@ -12923,7 +12974,8 @@ function CompositeWizard(_a) {
|
|
|
12923
12974
|
modelLoadTimeoutMs: videoSignatureCaptureProps.modelLoadTimeoutMs,
|
|
12924
12975
|
requireVerticalFaceCentering: false
|
|
12925
12976
|
}, /*#__PURE__*/React__default.createElement(VideoSignatureWizard, _assign({}, videoSignatureCaptureProps, {
|
|
12926
|
-
onComplete: onVideoSignatureComplete
|
|
12977
|
+
onComplete: onVideoSignatureComplete,
|
|
12978
|
+
onRetryClicked: onVideoSignatureRetry
|
|
12927
12979
|
}))));
|
|
12928
12980
|
case 'AdditionalDocumentCapture':
|
|
12929
12981
|
return /*#__PURE__*/React__default.createElement(AdditionalDocumentCaptureWizard, _assign({}, additionalDocumentCaptureProps, {
|
|
@@ -13374,7 +13426,8 @@ var IdValidation = function IdValidation(_a) {
|
|
|
13374
13426
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
13375
13427
|
captureSignature: captureSignature,
|
|
13376
13428
|
captureSignatureVideo: captureSignatureVideo,
|
|
13377
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
13429
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
13430
|
+
debugMode: debugMode
|
|
13378
13431
|
}))));
|
|
13379
13432
|
};
|
|
13380
13433
|
|
|
@@ -13480,7 +13533,8 @@ var FaceValidation = function FaceValidation(_a) {
|
|
|
13480
13533
|
return ['FaceLiveness'];
|
|
13481
13534
|
}, []),
|
|
13482
13535
|
faceLivenessProps: faceLivenessProps,
|
|
13483
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
13536
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
13537
|
+
debugMode: debugMode
|
|
13484
13538
|
}))));
|
|
13485
13539
|
};
|
|
13486
13540
|
|
|
@@ -13713,7 +13767,8 @@ var IdAndFaceValidation = function IdAndFaceValidation(_a) {
|
|
|
13713
13767
|
additionalDocumentCaptureProps: additionalDocumentCaptureProps,
|
|
13714
13768
|
captureSignature: captureSignature,
|
|
13715
13769
|
captureSignatureVideo: captureSignatureVideo,
|
|
13716
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
13770
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
13771
|
+
debugMode: debugMode
|
|
13717
13772
|
}))));
|
|
13718
13773
|
};
|
|
13719
13774
|
|
|
@@ -13968,7 +14023,8 @@ var CustomerIdAndBiometricsEnrollment = function CustomerIdAndBiometricsEnrollme
|
|
|
13968
14023
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
13969
14024
|
captureSignature: captureSignature,
|
|
13970
14025
|
captureSignatureVideo: captureSignatureVideo,
|
|
13971
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
14026
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
14027
|
+
debugMode: debugMode
|
|
13972
14028
|
}))));
|
|
13973
14029
|
};
|
|
13974
14030
|
|
|
@@ -14300,7 +14356,7 @@ var CustomerVerificationWizard = function CustomerVerificationWizard(_a) {
|
|
|
14300
14356
|
var _l = useState('LOADING'),
|
|
14301
14357
|
captureState = _l[0],
|
|
14302
14358
|
setCaptureState = _l[1];
|
|
14303
|
-
var _m =
|
|
14359
|
+
var _m = useContext(CameraStateContext),
|
|
14304
14360
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
14305
14361
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
14306
14362
|
var _o = useContext(SelfieGuidanceModelsContext),
|
|
@@ -14506,9 +14562,10 @@ var CustomerVerification = function CustomerVerification(_a) {
|
|
|
14506
14562
|
onSubmit: onSubmit,
|
|
14507
14563
|
geolocationEnabled: geolocationEnabled,
|
|
14508
14564
|
geolocationRequired: geolocationRequired
|
|
14509
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
14565
|
+
}, /*#__PURE__*/React__default.createElement(CameraProvider, {
|
|
14510
14566
|
preferFrontFacingCamera: true,
|
|
14511
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
14567
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
14568
|
+
debugMode: debugMode
|
|
14512
14569
|
}, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
|
|
14513
14570
|
autoStart: false,
|
|
14514
14571
|
onModelError: onModelError,
|
|
@@ -14857,7 +14914,7 @@ var CustomerIdentificationWizard = function CustomerIdentificationWizard(_a) {
|
|
|
14857
14914
|
var _l = useState('LOADING'),
|
|
14858
14915
|
captureState = _l[0],
|
|
14859
14916
|
setCaptureState = _l[1];
|
|
14860
|
-
var _m =
|
|
14917
|
+
var _m = useContext(CameraStateContext),
|
|
14861
14918
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
14862
14919
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
14863
14920
|
var _o = useContext(SelfieGuidanceModelsContext),
|
|
@@ -15061,9 +15118,10 @@ var CustomerIdentification = function CustomerIdentification(_a) {
|
|
|
15061
15118
|
onSubmit: onSubmit,
|
|
15062
15119
|
geolocationEnabled: geolocationEnabled,
|
|
15063
15120
|
geolocationRequired: geolocationRequired
|
|
15064
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
15121
|
+
}, /*#__PURE__*/React__default.createElement(CameraProvider, {
|
|
15065
15122
|
preferFrontFacingCamera: true,
|
|
15066
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
15123
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
15124
|
+
debugMode: debugMode
|
|
15067
15125
|
}, /*#__PURE__*/React__default.createElement(SelfieGuidanceModelsProvider, {
|
|
15068
15126
|
autoStart: false,
|
|
15069
15127
|
modelLoadTimeoutMs: modelLoadTimeoutMs,
|
|
@@ -15390,7 +15448,8 @@ var VideoIdValidation = function VideoIdValidation(_a) {
|
|
|
15390
15448
|
captureSignature: captureSignature,
|
|
15391
15449
|
captureSignatureVideo: captureSignatureVideo,
|
|
15392
15450
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
15393
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
15451
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
15452
|
+
debugMode: debugMode
|
|
15394
15453
|
}))));
|
|
15395
15454
|
};
|
|
15396
15455
|
|
|
@@ -15547,7 +15606,8 @@ var CustomerBiometricsEnrollment = function CustomerBiometricsEnrollment(_a) {
|
|
|
15547
15606
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
15548
15607
|
captureSignature: captureSignature,
|
|
15549
15608
|
captureSignatureVideo: captureSignatureVideo,
|
|
15550
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
15609
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
15610
|
+
debugMode: debugMode
|
|
15551
15611
|
}))));
|
|
15552
15612
|
};
|
|
15553
15613
|
|
|
@@ -15605,10 +15665,11 @@ var DocumentCapture = function DocumentCapture(_a) {
|
|
|
15605
15665
|
onDocumentUploadFailed: onDocumentUploadFailed,
|
|
15606
15666
|
geolocationEnabled: geolocationEnabled,
|
|
15607
15667
|
geolocationRequired: geolocationRequired
|
|
15608
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
15668
|
+
}, /*#__PURE__*/React__default.createElement(CameraProvider, {
|
|
15609
15669
|
requestAccessAutomatically: false,
|
|
15610
|
-
|
|
15611
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
15670
|
+
preferContinuityCamera: true,
|
|
15671
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
15672
|
+
debugMode: debugMode
|
|
15612
15673
|
}, /*#__PURE__*/React__default.createElement(DocumentCaptureWizard, {
|
|
15613
15674
|
onSuccess: onComplete,
|
|
15614
15675
|
onExitCapture: onExitCapture,
|