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
|
@@ -211,7 +211,7 @@
|
|
|
211
211
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
var webSdkVersion = '2.2.
|
|
214
|
+
var webSdkVersion = '2.2.47';
|
|
215
215
|
|
|
216
216
|
function getPlatform() {
|
|
217
217
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -1088,11 +1088,11 @@
|
|
|
1088
1088
|
if (!allowedAuthUrls.includes(url)) throw new Error('invalid auth url');
|
|
1089
1089
|
exports.defaultAuthUrl = url;
|
|
1090
1090
|
}
|
|
1091
|
-
var initialState$
|
|
1091
|
+
var initialState$5 = {
|
|
1092
1092
|
authUrl: exports.defaultAuthUrl,
|
|
1093
1093
|
sessionCheckState: 'READY'
|
|
1094
1094
|
};
|
|
1095
|
-
var AuthStateContext = /*#__PURE__*/React.createContext(initialState$
|
|
1095
|
+
var AuthStateContext = /*#__PURE__*/React.createContext(initialState$5);
|
|
1096
1096
|
var AuthDispatchContext = /*#__PURE__*/React.createContext(function () {});
|
|
1097
1097
|
var reducer$4 = function reducer(state, action) {
|
|
1098
1098
|
switch (action.type) {
|
|
@@ -1124,7 +1124,7 @@
|
|
|
1124
1124
|
if (authUrl === void 0) {
|
|
1125
1125
|
authUrl = exports.defaultAuthUrl;
|
|
1126
1126
|
}
|
|
1127
|
-
var _a = React.useReducer(reducer$4, _assign(_assign({}, initialState$
|
|
1127
|
+
var _a = React.useReducer(reducer$4, _assign(_assign({}, initialState$5), {
|
|
1128
1128
|
authUrl: authUrl
|
|
1129
1129
|
})),
|
|
1130
1130
|
state = _a[0],
|
|
@@ -2293,7 +2293,8 @@
|
|
|
2293
2293
|
}
|
|
2294
2294
|
};
|
|
2295
2295
|
_e = {
|
|
2296
|
-
filetype: blob.type
|
|
2296
|
+
filetype: blob.type,
|
|
2297
|
+
contentType: blob.type
|
|
2297
2298
|
};
|
|
2298
2299
|
return [4 /*yield*/, calculateMd5(blob)];
|
|
2299
2300
|
case 3:
|
|
@@ -3037,149 +3038,751 @@
|
|
|
3037
3038
|
}, [refCallback, size.width, size.height]);
|
|
3038
3039
|
}
|
|
3039
3040
|
|
|
3040
|
-
function
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
3047
|
-
}, _typeof$1(o);
|
|
3048
|
-
}
|
|
3049
|
-
|
|
3050
|
-
function toPrimitive(t, r) {
|
|
3051
|
-
if ("object" != _typeof$1(t) || !t) return t;
|
|
3052
|
-
var e = t[Symbol.toPrimitive];
|
|
3053
|
-
if (void 0 !== e) {
|
|
3054
|
-
var i = e.call(t, r);
|
|
3055
|
-
if ("object" != _typeof$1(i)) return i;
|
|
3056
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3041
|
+
function getFrameDimensions(frame) {
|
|
3042
|
+
var frameWidth = frame.width,
|
|
3043
|
+
frameHeight = frame.height;
|
|
3044
|
+
if (frame instanceof HTMLImageElement) {
|
|
3045
|
+
frameWidth = frame.naturalWidth;
|
|
3046
|
+
frameHeight = frame.naturalHeight;
|
|
3057
3047
|
}
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
return "symbol" == _typeof$1(i) ? i : i + "";
|
|
3048
|
+
if (frame instanceof HTMLVideoElement) {
|
|
3049
|
+
frameWidth = frame.videoWidth;
|
|
3050
|
+
frameHeight = frame.videoHeight;
|
|
3051
|
+
}
|
|
3052
|
+
return [frameWidth, frameHeight];
|
|
3064
3053
|
}
|
|
3065
3054
|
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3055
|
+
var InvisibleCanvas = styled.canvas(templateObject_1$G || (templateObject_1$G = __makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
|
|
3056
|
+
function drawToCanvas(canvas, frame, width, height) {
|
|
3057
|
+
if (!canvas) return;
|
|
3058
|
+
var ctx = canvas.getContext('2d');
|
|
3059
|
+
if (!ctx) return;
|
|
3060
|
+
if (!width || !height) {
|
|
3061
|
+
var _a = getFrameDimensions(frame),
|
|
3062
|
+
frameWidth = _a[0],
|
|
3063
|
+
frameHeight = _a[1];
|
|
3064
|
+
width || (width = frameWidth);
|
|
3065
|
+
height || (height = frameHeight);
|
|
3070
3066
|
}
|
|
3067
|
+
canvas.width = width;
|
|
3068
|
+
canvas.height = height;
|
|
3069
|
+
ctx.drawImage(frame, 0, 0, width, height);
|
|
3071
3070
|
}
|
|
3072
|
-
function
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
}), e;
|
|
3071
|
+
function clearCanvas(canvas) {
|
|
3072
|
+
var _a;
|
|
3073
|
+
(_a = canvas === null || canvas === void 0 ? void 0 : canvas.getContext('2d')) === null || _a === void 0 ? void 0 : _a.clearRect(0, 0, canvas === null || canvas === void 0 ? void 0 : canvas.width, canvas === null || canvas === void 0 ? void 0 : canvas.height);
|
|
3076
3074
|
}
|
|
3075
|
+
var templateObject_1$G;
|
|
3077
3076
|
|
|
3078
|
-
function
|
|
3079
|
-
|
|
3080
|
-
var
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3077
|
+
function listAvailableCameras(facingMode_1) {
|
|
3078
|
+
return __awaiter(this, arguments, void 0, function (facingMode, requestMicAccess) {
|
|
3079
|
+
var cameraEnumerationStream, videoDevices;
|
|
3080
|
+
if (requestMicAccess === void 0) {
|
|
3081
|
+
requestMicAccess = false;
|
|
3082
|
+
}
|
|
3083
|
+
return __generator(this, function (_a) {
|
|
3084
|
+
switch (_a.label) {
|
|
3085
|
+
case 0:
|
|
3086
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3087
|
+
video: {
|
|
3088
|
+
facingMode: {
|
|
3089
|
+
exact: facingMode
|
|
3090
|
+
}
|
|
3091
|
+
},
|
|
3092
|
+
audio: requestMicAccess
|
|
3093
|
+
})
|
|
3094
|
+
// This lists all available cameras attached to the user's device.
|
|
3095
|
+
];
|
|
3096
|
+
case 1:
|
|
3097
|
+
cameraEnumerationStream = _a.sent();
|
|
3098
|
+
return [4 /*yield*/, navigator.mediaDevices.enumerateDevices()];
|
|
3099
|
+
case 2:
|
|
3100
|
+
videoDevices = _a.sent().filter(function (_a) {
|
|
3101
|
+
var kind = _a.kind;
|
|
3102
|
+
return kind === 'videoinput';
|
|
3103
|
+
});
|
|
3104
|
+
// Release the access to the user's camera that we obtained for enumeration purposes.
|
|
3105
|
+
cameraEnumerationStream.getVideoTracks().forEach(function (track) {
|
|
3106
|
+
track.enabled = false;
|
|
3107
|
+
track.stop();
|
|
3108
|
+
});
|
|
3109
|
+
cameraEnumerationStream = null;
|
|
3110
|
+
return [2 /*return*/, videoDevices];
|
|
3098
3111
|
}
|
|
3099
|
-
_next(void 0);
|
|
3100
3112
|
});
|
|
3101
|
-
};
|
|
3102
|
-
}
|
|
3103
|
-
|
|
3104
|
-
function _setPrototypeOf(t, e) {
|
|
3105
|
-
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
3106
|
-
return t.__proto__ = e, t;
|
|
3107
|
-
}, _setPrototypeOf(t, e);
|
|
3108
|
-
}
|
|
3109
|
-
|
|
3110
|
-
function _inheritsLoose(t, o) {
|
|
3111
|
-
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
3112
|
-
}
|
|
3113
|
-
|
|
3114
|
-
function _getPrototypeOf(t) {
|
|
3115
|
-
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
3116
|
-
return t.__proto__ || Object.getPrototypeOf(t);
|
|
3117
|
-
}, _getPrototypeOf(t);
|
|
3113
|
+
});
|
|
3118
3114
|
}
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3115
|
+
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) {
|
|
3116
|
+
return s.toLocaleLowerCase().split(' ').join('');
|
|
3117
|
+
});
|
|
3118
|
+
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) {
|
|
3119
|
+
return s.toLocaleLowerCase().split(' ').join('');
|
|
3120
|
+
});
|
|
3121
|
+
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) {
|
|
3122
|
+
return s.toLocaleLowerCase().split(' ').join('');
|
|
3123
|
+
});
|
|
3124
|
+
var labelMatches = function labelMatches(labelOrDevice, labelSetOrLabel) {
|
|
3125
|
+
var label = labelOrDevice instanceof MediaDeviceInfo ? getDeviceLabel(labelOrDevice) : labelOrDevice;
|
|
3126
|
+
var labelSet = typeof labelSetOrLabel === 'string' ? [labelSetOrLabel] : labelSetOrLabel;
|
|
3127
|
+
return labelSet.some(function (l) {
|
|
3128
|
+
return label.includes(l);
|
|
3129
|
+
});
|
|
3130
|
+
};
|
|
3131
|
+
var getDeviceLabel = function getDeviceLabel(deviceInfo) {
|
|
3132
|
+
return deviceInfo.label.toLocaleLowerCase().split(' ').join('');
|
|
3133
|
+
};
|
|
3134
|
+
var currentCamera;
|
|
3135
|
+
var currentAudioStream;
|
|
3136
|
+
function obtainCameraAccess(stream, deviceLabel, video) {
|
|
3137
|
+
releaseCameraAccess();
|
|
3138
|
+
log('obtaining camera access...');
|
|
3139
|
+
var _a = stream.getVideoTracks()[0].getSettings(),
|
|
3140
|
+
width = _a.width,
|
|
3141
|
+
height = _a.height;
|
|
3142
|
+
var label = deviceLabel.toLocaleLowerCase().split(' ').join('');
|
|
3143
|
+
var isRearFacing = labelMatches(label, __spreadArray(__spreadArray(__spreadArray([], rearLabels, true), backUltraWideLabels, true), ['iphone'], false));
|
|
3144
|
+
var release = function release() {
|
|
3145
|
+
stream.getTracks().forEach(function (track) {
|
|
3146
|
+
track.enabled = false;
|
|
3147
|
+
track.stop();
|
|
3148
|
+
});
|
|
3149
|
+
if (video) {
|
|
3150
|
+
video.pause();
|
|
3151
|
+
video.srcObject = null;
|
|
3152
|
+
video.src = '';
|
|
3153
|
+
}
|
|
3154
|
+
};
|
|
3155
|
+
width || (width = 0);
|
|
3156
|
+
height || (height = 0);
|
|
3157
|
+
currentCamera = {
|
|
3158
|
+
label: deviceLabel,
|
|
3159
|
+
stream: stream,
|
|
3160
|
+
width: width,
|
|
3161
|
+
height: height,
|
|
3162
|
+
isRearFacing: isRearFacing,
|
|
3163
|
+
release: release
|
|
3164
|
+
};
|
|
3165
|
+
if (video) video.srcObject = stream;
|
|
3166
|
+
return currentCamera;
|
|
3126
3167
|
}
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
|
|
3133
|
-
return !!t;
|
|
3134
|
-
})();
|
|
3168
|
+
function releaseCameraAccess() {
|
|
3169
|
+
if (!currentCamera) return;
|
|
3170
|
+
log('releasing camera access...');
|
|
3171
|
+
currentCamera.release();
|
|
3172
|
+
currentCamera = undefined;
|
|
3135
3173
|
}
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
if (
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3174
|
+
function releaseMicrophoneAccess() {
|
|
3175
|
+
var _a;
|
|
3176
|
+
if (!currentAudioStream) return;
|
|
3177
|
+
log('releasing microphone access...');
|
|
3178
|
+
(_a = currentAudioStream.stop) === null || _a === void 0 ? void 0 : _a.call(currentAudioStream);
|
|
3179
|
+
currentAudioStream.getAudioTracks().forEach(function (t) {
|
|
3180
|
+
var _a;
|
|
3181
|
+
(_a = t.stop) === null || _a === void 0 ? void 0 : _a.call(t);
|
|
3182
|
+
});
|
|
3183
|
+
currentAudioStream = undefined;
|
|
3143
3184
|
}
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3185
|
+
function usePreferredCaptureDevice(_a) {
|
|
3186
|
+
var _b = _a === void 0 ? {} : _a,
|
|
3187
|
+
_c = _b.requestAccessAutomatically,
|
|
3188
|
+
requestAccessAutomatically = _c === void 0 ? true : _c,
|
|
3189
|
+
_d = _b.preferFrontFacingCamera,
|
|
3190
|
+
preferFrontFacingCamera = _d === void 0 ? false : _d,
|
|
3191
|
+
_e = _b.preferContinuityCamera,
|
|
3192
|
+
preferContinuityCamera = _e === void 0 ? true : _e,
|
|
3193
|
+
_f = _b.requireMicrophoneAccess,
|
|
3194
|
+
requireMicrophoneAccess = _f === void 0 ? false : _f,
|
|
3195
|
+
_g = _b.maxVideoWidth,
|
|
3196
|
+
maxVideoWidth = _g === void 0 ? 1920 : _g,
|
|
3197
|
+
maxFps = _b.maxFps,
|
|
3198
|
+
_h = _b.debugMode,
|
|
3199
|
+
debugMode = _h === void 0 ? false : _h;
|
|
3200
|
+
var videoRef = React.useRef(null);
|
|
3201
|
+
var videoRefStack = React.useRef([]);
|
|
3202
|
+
var cameraRef = React.useRef(null);
|
|
3203
|
+
var _j = React.useState(false),
|
|
3204
|
+
cameraReady = _j[0],
|
|
3205
|
+
setCameraReady = _j[1];
|
|
3206
|
+
var _k = React.useState(false),
|
|
3207
|
+
microphoneReady = _k[0],
|
|
3208
|
+
setMicrophoneReady = _k[1];
|
|
3209
|
+
var _l = React.useState(null),
|
|
3210
|
+
videoDevice = _l[0],
|
|
3211
|
+
setVideoDevice = _l[1];
|
|
3212
|
+
var _m = React.useState(null),
|
|
3213
|
+
audioStream = _m[0],
|
|
3214
|
+
setAudioStream = _m[1];
|
|
3215
|
+
var _o = React.useState(false),
|
|
3216
|
+
videoLoaded = _o[0],
|
|
3217
|
+
setVideoLoaded = _o[1];
|
|
3218
|
+
var _p = React.useState(false),
|
|
3219
|
+
iphoneContinuityCameraAvailable = _p[0],
|
|
3220
|
+
setIphoneContinuityCameraAvailable = _p[1];
|
|
3221
|
+
var _q = React.useState(preferContinuityCamera),
|
|
3222
|
+
iphoneContinuityCameraAllowed = _q[0],
|
|
3223
|
+
setIphoneContinuityCameraAllowed = _q[1];
|
|
3224
|
+
var _r = React.useState(false),
|
|
3225
|
+
iphoneContinuityCameraDenied = _r[0],
|
|
3226
|
+
setIphoneContinuityCameraDenied = _r[1];
|
|
3227
|
+
var _s = React.useState(false),
|
|
3228
|
+
cameraAccessDenied = _s[0],
|
|
3229
|
+
setCameraAccessDenied = _s[1];
|
|
3230
|
+
var _t = React.useState(false),
|
|
3231
|
+
microphoneAccessDenied = _t[0],
|
|
3232
|
+
setMicrophoneAccessDenied = _t[1];
|
|
3233
|
+
var videoRefElement = videoRef.current;
|
|
3234
|
+
React.useEffect(function pushVideoRefToStackWhenChanged() {
|
|
3235
|
+
// proceed if the video element being mounted is not already at the top of the videoRefStack.
|
|
3236
|
+
var topOfStack = videoRefStack.current.slice(-1)[0];
|
|
3237
|
+
if (videoRefElement && videoRefElement !== topOfStack) {
|
|
3238
|
+
log('adding video to stack', videoRefElement);
|
|
3239
|
+
videoRefStack.current.push(videoRefElement);
|
|
3240
|
+
}
|
|
3241
|
+
}, [videoRefElement]);
|
|
3242
|
+
var onVideoUnmounted = React.useCallback(function (videoElement) {
|
|
3243
|
+
log('removing video from stack', videoElement);
|
|
3244
|
+
videoRefStack.current = videoRefStack.current.filter(function (v) {
|
|
3245
|
+
return v !== videoElement;
|
|
3246
|
+
});
|
|
3247
|
+
videoRef.current = videoRefStack.current.slice(-1)[0]; // top of stack.
|
|
3248
|
+
log('new videoRef is', videoRef.current);
|
|
3249
|
+
}, []);
|
|
3250
|
+
React.useEffect(function resetCameraOnContinuityPreferenceChanged() {
|
|
3251
|
+
if (debugMode) {
|
|
3252
|
+
log('iphone continuity camera allowed changed', iphoneContinuityCameraAllowed);
|
|
3156
3253
|
}
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3254
|
+
releaseCameraAccess();
|
|
3255
|
+
cameraRef.current = null;
|
|
3256
|
+
setVideoLoaded(false);
|
|
3257
|
+
}, [debugMode, iphoneContinuityCameraAllowed]);
|
|
3258
|
+
// NOTE: the bound callback function here is called requestCameraAccess, because
|
|
3259
|
+
// it initiates the useEffect chain that results in camera access being requested
|
|
3260
|
+
// (requestCameraAccessAutomatically -> chooseFromAvailableCameras -> accessChosenCamera).
|
|
3261
|
+
//
|
|
3262
|
+
// We chose to title the inner function "chooseFromAvailableCameras" because
|
|
3263
|
+
// that's all it literally does -- the available cameras are enumerated, and then
|
|
3264
|
+
// the result is parsed to decide which one we like best, which is then passed to
|
|
3265
|
+
// setVideoDevice, which causes accessChosenCamera to trigger.
|
|
3266
|
+
//
|
|
3267
|
+
// I am not a huge fan of getUserMedia's design -- you need to call it twice in order
|
|
3268
|
+
// to select the "best" camera for your application's purposes.
|
|
3269
|
+
var requestCameraAccess = React.useCallback(function chooseFromAvailableCameras() {
|
|
3270
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3271
|
+
var availableCameras, selectedCamera, platform_1, iphoneContinuityCamera, e_1;
|
|
3272
|
+
var _a, _b;
|
|
3273
|
+
return __generator(this, function (_c) {
|
|
3274
|
+
switch (_c.label) {
|
|
3275
|
+
case 0:
|
|
3276
|
+
setCameraReady(false);
|
|
3277
|
+
setCameraAccessDenied(false);
|
|
3278
|
+
_c.label = 1;
|
|
3279
|
+
case 1:
|
|
3280
|
+
_c.trys.push([1, 3,, 4]);
|
|
3281
|
+
return [4 /*yield*/, listAvailableCameras()];
|
|
3282
|
+
case 2:
|
|
3283
|
+
availableCameras = _c.sent();
|
|
3284
|
+
selectedCamera = void 0;
|
|
3285
|
+
if (debugMode) {
|
|
3286
|
+
log('availableCameras', availableCameras);
|
|
3287
|
+
}
|
|
3288
|
+
platform_1 = getPlatform();
|
|
3289
|
+
if (debugMode) {
|
|
3290
|
+
log('platformDetails', platform_1);
|
|
3291
|
+
}
|
|
3292
|
+
if (!iphoneContinuityCameraDenied && (!(platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) || platform_1.os.family === 'OS X')) {
|
|
3293
|
+
iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
|
|
3294
|
+
return labelMatches(deviceInfo, 'iphone');
|
|
3295
|
+
});
|
|
3296
|
+
setIphoneContinuityCameraAvailable(!!iphoneContinuityCamera);
|
|
3297
|
+
if (iphoneContinuityCamera && iphoneContinuityCameraAllowed) {
|
|
3298
|
+
selectedCamera = iphoneContinuityCamera;
|
|
3299
|
+
}
|
|
3300
|
+
} 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) {
|
|
3301
|
+
return c.label.startsWith('camera2 ');
|
|
3302
|
+
})) {
|
|
3303
|
+
availableCameras = availableCameras.sort(function (a, b) {
|
|
3304
|
+
return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
|
|
3305
|
+
});
|
|
3306
|
+
if (debugMode) {
|
|
3307
|
+
log('cameras have been sorted', availableCameras);
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
if (preferFrontFacingCamera) {
|
|
3311
|
+
selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3312
|
+
return labelMatches(deviceInfo, frontLabels);
|
|
3313
|
+
});
|
|
3314
|
+
}
|
|
3315
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3316
|
+
return labelMatches(deviceInfo, 'backtriplecamera');
|
|
3317
|
+
}));
|
|
3318
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3319
|
+
return labelMatches(deviceInfo, 'backdualcamera');
|
|
3320
|
+
}));
|
|
3321
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3322
|
+
return labelMatches(deviceInfo, rearLabels) && !labelMatches(deviceInfo, backUltraWideLabels);
|
|
3323
|
+
}));
|
|
3324
|
+
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
3325
|
+
return labelMatches(deviceInfo, rearLabels);
|
|
3326
|
+
}));
|
|
3327
|
+
// on iOS, the front facing camera always is at the first position in the list, so we skip it if all else fails.
|
|
3328
|
+
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) {
|
|
3329
|
+
selectedCamera || (selectedCamera = availableCameras[1]);
|
|
3330
|
+
}
|
|
3331
|
+
selectedCamera || (selectedCamera = availableCameras[0]);
|
|
3332
|
+
if (debugMode) log('selectedCamera', selectedCamera);
|
|
3333
|
+
setVideoDevice(selectedCamera);
|
|
3334
|
+
return [3 /*break*/, 4];
|
|
3335
|
+
case 3:
|
|
3336
|
+
e_1 = _c.sent();
|
|
3337
|
+
if (e_1.name === 'NotAllowedError') {
|
|
3338
|
+
error('camera access has been blocked by the user', e_1);
|
|
3339
|
+
setCameraAccessDenied(true);
|
|
3340
|
+
} else {
|
|
3341
|
+
error('camera access encountered some other error', e_1);
|
|
3342
|
+
throw e_1;
|
|
3343
|
+
}
|
|
3344
|
+
return [3 /*break*/, 4];
|
|
3345
|
+
case 4:
|
|
3346
|
+
return [2 /*return*/];
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
});
|
|
3350
|
+
}, [debugMode, iphoneContinuityCameraAllowed, iphoneContinuityCameraDenied, preferFrontFacingCamera]);
|
|
3351
|
+
React.useEffect(function requestCameraAccessAutomatically() {
|
|
3352
|
+
if (requestAccessAutomatically && !cameraAccessDenied) {
|
|
3353
|
+
requestCameraAccess()["catch"](error);
|
|
3354
|
+
}
|
|
3355
|
+
}, [cameraAccessDenied, requestAccessAutomatically, requestCameraAccess]);
|
|
3356
|
+
React.useEffect(function accessChosenCamera() {
|
|
3357
|
+
var _this = this;
|
|
3358
|
+
var _a;
|
|
3359
|
+
if (!videoDevice) return;
|
|
3360
|
+
var cleanup = function cleanup() {
|
|
3361
|
+
releaseCameraAccess();
|
|
3362
|
+
cameraRef.current = null;
|
|
3363
|
+
setVideoLoaded(false);
|
|
3364
|
+
};
|
|
3365
|
+
if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) return cleanup;
|
|
3366
|
+
(function () {
|
|
3367
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
3368
|
+
var constraints, stream, e_2, handleStreamEnded;
|
|
3369
|
+
var _a;
|
|
3370
|
+
return __generator(this, function (_b) {
|
|
3371
|
+
switch (_b.label) {
|
|
3372
|
+
case 0:
|
|
3373
|
+
constraints = {
|
|
3374
|
+
audio: false,
|
|
3375
|
+
video: {
|
|
3376
|
+
deviceId: {
|
|
3377
|
+
exact: videoDevice.deviceId
|
|
3378
|
+
},
|
|
3379
|
+
width: {
|
|
3380
|
+
ideal: maxVideoWidth
|
|
3381
|
+
},
|
|
3382
|
+
aspectRatio: 1.777777778,
|
|
3383
|
+
frameRate: {}
|
|
3384
|
+
}
|
|
3385
|
+
};
|
|
3386
|
+
if (maxFps) {
|
|
3387
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3388
|
+
// @ts-ignore
|
|
3389
|
+
constraints.video.frameRate = {
|
|
3390
|
+
max: maxFps
|
|
3391
|
+
};
|
|
3392
|
+
}
|
|
3393
|
+
stream = null;
|
|
3394
|
+
_b.label = 1;
|
|
3395
|
+
case 1:
|
|
3396
|
+
_b.trys.push([1, 3,, 4]);
|
|
3397
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
|
|
3398
|
+
case 2:
|
|
3399
|
+
stream = _b.sent();
|
|
3400
|
+
return [3 /*break*/, 4];
|
|
3401
|
+
case 3:
|
|
3402
|
+
e_2 = _b.sent();
|
|
3403
|
+
if (e_2.name === 'NotAllowedError') {
|
|
3404
|
+
if (iphoneContinuityCameraAllowed) {
|
|
3405
|
+
setIphoneContinuityCameraAvailable(false);
|
|
3406
|
+
setIphoneContinuityCameraDenied(true);
|
|
3407
|
+
} else {
|
|
3408
|
+
setCameraAccessDenied(true);
|
|
3409
|
+
}
|
|
3410
|
+
return [2 /*return*/];
|
|
3411
|
+
}
|
|
3412
|
+
return [3 /*break*/, 4];
|
|
3413
|
+
case 4:
|
|
3414
|
+
if (!!stream) return [3 /*break*/, 8];
|
|
3415
|
+
_b.label = 5;
|
|
3416
|
+
case 5:
|
|
3417
|
+
_b.trys.push([5, 7,, 8]);
|
|
3418
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3419
|
+
audio: false,
|
|
3420
|
+
video: true
|
|
3421
|
+
})];
|
|
3422
|
+
case 6:
|
|
3423
|
+
stream = _b.sent();
|
|
3424
|
+
log('opened stream with no width and height constraints');
|
|
3425
|
+
return [3 /*break*/, 8];
|
|
3426
|
+
case 7:
|
|
3427
|
+
_b.sent();
|
|
3428
|
+
log('cannot open stream at all');
|
|
3429
|
+
return [3 /*break*/, 8];
|
|
3430
|
+
case 8:
|
|
3431
|
+
if (!stream) {
|
|
3432
|
+
throw new Error('failed to open camera');
|
|
3433
|
+
}
|
|
3434
|
+
handleStreamEnded = function handleStreamEnded() {
|
|
3435
|
+
if (iphoneContinuityCameraAvailable && iphoneContinuityCameraAllowed) {
|
|
3436
|
+
log('someone unplugged the continuity camera');
|
|
3437
|
+
releaseCameraAccess();
|
|
3438
|
+
cameraRef.current = null;
|
|
3439
|
+
setIphoneContinuityCameraAvailable(false);
|
|
3440
|
+
setIphoneContinuityCameraDenied(true);
|
|
3441
|
+
setVideoDevice(null);
|
|
3442
|
+
} else {
|
|
3443
|
+
log('someone unplugged the webcam');
|
|
3444
|
+
releaseCameraAccess();
|
|
3445
|
+
cameraRef.current = null;
|
|
3446
|
+
setVideoLoaded(false);
|
|
3447
|
+
setCameraAccessDenied(true);
|
|
3448
|
+
}
|
|
3449
|
+
};
|
|
3450
|
+
(_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', handleStreamEnded);
|
|
3451
|
+
stream.getVideoTracks().forEach(function (track) {
|
|
3452
|
+
track.onended = handleStreamEnded;
|
|
3453
|
+
});
|
|
3454
|
+
cameraRef.current = obtainCameraAccess(stream, videoDevice.label, videoRef.current);
|
|
3455
|
+
return [2 /*return*/];
|
|
3456
|
+
}
|
|
3457
|
+
});
|
|
3458
|
+
});
|
|
3459
|
+
})();
|
|
3460
|
+
return cleanup;
|
|
3461
|
+
}, [iphoneContinuityCameraAllowed, iphoneContinuityCameraAvailable, maxFps, maxVideoWidth, videoDevice]);
|
|
3462
|
+
React.useEffect(function triggerCameraReady() {
|
|
3463
|
+
// TODO: in the future let's evaluate whether we can simplify this to just
|
|
3464
|
+
// setCameraReady(!!videoDevice && videoLoaded) -- we are wondering whether
|
|
3465
|
+
// we somehow depend on this being set twice.
|
|
3466
|
+
setCameraReady(false);
|
|
3467
|
+
if (videoDevice && videoLoaded) {
|
|
3468
|
+
setCameraReady(videoDevice && videoLoaded);
|
|
3469
|
+
}
|
|
3470
|
+
}, [videoLoaded, videoDevice]);
|
|
3471
|
+
var requestMicrophoneAccess = React.useCallback(function _requestMicrophoneAccess() {
|
|
3472
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3473
|
+
var stream;
|
|
3474
|
+
return __generator(this, function (_a) {
|
|
3475
|
+
switch (_a.label) {
|
|
3476
|
+
case 0:
|
|
3477
|
+
setMicrophoneReady(false);
|
|
3478
|
+
setMicrophoneAccessDenied(false);
|
|
3479
|
+
_a.label = 1;
|
|
3480
|
+
case 1:
|
|
3481
|
+
_a.trys.push([1, 3,, 4]);
|
|
3482
|
+
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
3483
|
+
audio: true,
|
|
3484
|
+
video: false
|
|
3485
|
+
})];
|
|
3486
|
+
case 2:
|
|
3487
|
+
stream = _a.sent();
|
|
3488
|
+
currentAudioStream = stream;
|
|
3489
|
+
setAudioStream(stream);
|
|
3490
|
+
setMicrophoneReady(true);
|
|
3491
|
+
stream.getAudioTracks().forEach(function (track) {
|
|
3492
|
+
track.onended = function () {
|
|
3493
|
+
setMicrophoneAccessDenied(true);
|
|
3494
|
+
};
|
|
3495
|
+
});
|
|
3496
|
+
return [3 /*break*/, 4];
|
|
3497
|
+
case 3:
|
|
3498
|
+
_a.sent();
|
|
3499
|
+
setMicrophoneAccessDenied(true);
|
|
3500
|
+
return [3 /*break*/, 4];
|
|
3501
|
+
case 4:
|
|
3502
|
+
return [2 /*return*/];
|
|
3503
|
+
}
|
|
3504
|
+
});
|
|
3505
|
+
});
|
|
3506
|
+
}, []);
|
|
3507
|
+
React.useEffect(function requestMicrophoneAccessIfNeeded() {
|
|
3508
|
+
if (!requireMicrophoneAccess || microphoneAccessDenied) return;
|
|
3509
|
+
requestMicrophoneAccess()["catch"](error);
|
|
3510
|
+
return function () {
|
|
3511
|
+
releaseMicrophoneAccess();
|
|
3512
|
+
setAudioStream(null);
|
|
3513
|
+
setMicrophoneReady(false);
|
|
3514
|
+
};
|
|
3515
|
+
}, [microphoneAccessDenied, requestMicrophoneAccess, requireMicrophoneAccess]);
|
|
3516
|
+
var takePhoto = React.useCallback(function _takePhoto() {
|
|
3517
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3518
|
+
var canvas;
|
|
3519
|
+
return __generator(this, function (_a) {
|
|
3520
|
+
switch (_a.label) {
|
|
3521
|
+
case 0:
|
|
3522
|
+
if (!cameraRef.current) return [2 /*return*/, null];
|
|
3523
|
+
if (!(typeof ImageCapture !== 'undefined')) return [3 /*break*/, 2];
|
|
3524
|
+
return [4 /*yield*/, new ImageCapture(cameraRef.current.stream.getTracks()[0]).takePhoto()];
|
|
3525
|
+
case 1:
|
|
3526
|
+
return [2 /*return*/, _a.sent()];
|
|
3527
|
+
case 2:
|
|
3528
|
+
if (!videoRef.current) return [2 /*return*/, null];
|
|
3529
|
+
canvas = document.createElement('canvas');
|
|
3530
|
+
drawToCanvas(canvas, videoRef.current);
|
|
3531
|
+
return [2 /*return*/, new Promise(function (resolve) {
|
|
3532
|
+
return canvas.toBlob(resolve);
|
|
3533
|
+
})];
|
|
3534
|
+
}
|
|
3535
|
+
});
|
|
3536
|
+
});
|
|
3537
|
+
}, []);
|
|
3538
|
+
return React.useMemo(function () {
|
|
3539
|
+
return {
|
|
3540
|
+
videoRef: videoRef,
|
|
3541
|
+
videoDevice: videoDevice,
|
|
3542
|
+
videoLoaded: videoLoaded,
|
|
3543
|
+
setVideoLoaded: setVideoLoaded,
|
|
3544
|
+
onVideoUnmounted: onVideoUnmounted,
|
|
3545
|
+
cameraRef: cameraRef,
|
|
3546
|
+
cameraReady: cameraReady,
|
|
3547
|
+
cameraAccessDenied: cameraAccessDenied,
|
|
3548
|
+
requestCameraAccess: requestCameraAccess,
|
|
3549
|
+
releaseCameraAccess: releaseCameraAccess,
|
|
3550
|
+
iphoneContinuityCameraAvailable: iphoneContinuityCameraAvailable,
|
|
3551
|
+
iphoneContinuityCameraAllowed: iphoneContinuityCameraAllowed,
|
|
3552
|
+
setIphoneContinuityCameraAllowed: setIphoneContinuityCameraAllowed,
|
|
3553
|
+
takePhoto: takePhoto,
|
|
3554
|
+
audioStream: audioStream,
|
|
3555
|
+
microphoneReady: microphoneReady,
|
|
3556
|
+
microphoneAccessDenied: microphoneAccessDenied,
|
|
3557
|
+
requestMicrophoneAccess: requestMicrophoneAccess
|
|
3558
|
+
};
|
|
3559
|
+
}, [audioStream, cameraAccessDenied, cameraReady, iphoneContinuityCameraAllowed, iphoneContinuityCameraAvailable, microphoneAccessDenied, microphoneReady, onVideoUnmounted, requestCameraAccess, requestMicrophoneAccess, takePhoto, videoDevice, videoLoaded]);
|
|
3560
|
+
}
|
|
3561
|
+
|
|
3562
|
+
var CameraStateContext = /*#__PURE__*/React.createContext({
|
|
3563
|
+
videoRef: {
|
|
3564
|
+
current: null
|
|
3565
|
+
},
|
|
3566
|
+
videoDevice: null,
|
|
3567
|
+
videoLoaded: false,
|
|
3568
|
+
cameraRef: {
|
|
3569
|
+
current: null
|
|
3570
|
+
},
|
|
3571
|
+
cameraReady: false,
|
|
3572
|
+
cameraAccessDenied: false,
|
|
3573
|
+
requestCameraAccess: function requestCameraAccess() {
|
|
3574
|
+
return null;
|
|
3575
|
+
},
|
|
3576
|
+
releaseCameraAccess: function releaseCameraAccess() {
|
|
3577
|
+
return null;
|
|
3578
|
+
},
|
|
3579
|
+
iphoneContinuityCameraAvailable: false,
|
|
3580
|
+
iphoneContinuityCameraAllowed: true,
|
|
3581
|
+
setIphoneContinuityCameraAllowed: function setIphoneContinuityCameraAllowed() {
|
|
3582
|
+
return null;
|
|
3583
|
+
},
|
|
3584
|
+
takePhoto: function takePhoto() {
|
|
3585
|
+
return Promise.resolve(null);
|
|
3586
|
+
},
|
|
3587
|
+
setVideoLoaded: function setVideoLoaded() {
|
|
3588
|
+
return null;
|
|
3589
|
+
},
|
|
3590
|
+
onVideoUnmounted: function onVideoUnmounted() {
|
|
3591
|
+
return null;
|
|
3592
|
+
},
|
|
3593
|
+
audioStream: null,
|
|
3594
|
+
microphoneReady: false,
|
|
3595
|
+
microphoneAccessDenied: false,
|
|
3596
|
+
requestMicrophoneAccess: function requestMicrophoneAccess() {
|
|
3597
|
+
return null;
|
|
3598
|
+
}
|
|
3599
|
+
});
|
|
3600
|
+
var CameraProvider = function CameraProvider(_a) {
|
|
3601
|
+
var children = _a.children,
|
|
3602
|
+
_b = _a.requestAccessAutomatically,
|
|
3603
|
+
requestAccessAutomatically = _b === void 0 ? true : _b,
|
|
3604
|
+
_c = _a.preferFrontFacingCamera,
|
|
3605
|
+
preferFrontFacingCamera = _c === void 0 ? false : _c,
|
|
3606
|
+
_d = _a.preferContinuityCamera,
|
|
3607
|
+
preferContinuityCamera = _d === void 0 ? true : _d,
|
|
3608
|
+
_e = _a.requireMicrophoneAccess,
|
|
3609
|
+
requireMicrophoneAccess = _e === void 0 ? false : _e,
|
|
3610
|
+
_f = _a.maxVideoWidth,
|
|
3611
|
+
maxVideoWidth = _f === void 0 ? 1920 : _f,
|
|
3612
|
+
maxFps = _a.maxFps,
|
|
3613
|
+
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
3614
|
+
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
|
|
3615
|
+
_g = _a.debugMode,
|
|
3616
|
+
debugMode = _g === void 0 ? false : _g;
|
|
3617
|
+
var captureDevice = usePreferredCaptureDevice({
|
|
3618
|
+
requestAccessAutomatically: requestAccessAutomatically,
|
|
3619
|
+
preferFrontFacingCamera: preferFrontFacingCamera,
|
|
3620
|
+
preferContinuityCamera: preferContinuityCamera,
|
|
3621
|
+
requireMicrophoneAccess: requireMicrophoneAccess,
|
|
3622
|
+
maxVideoWidth: maxVideoWidth,
|
|
3623
|
+
maxFps: maxFps,
|
|
3624
|
+
debugMode: debugMode
|
|
3625
|
+
});
|
|
3626
|
+
React.useEffect(function () {
|
|
3627
|
+
if (captureDevice.cameraAccessDenied) onCameraAccessDenied === null || onCameraAccessDenied === void 0 ? void 0 : onCameraAccessDenied();
|
|
3628
|
+
}, [captureDevice.cameraAccessDenied, onCameraAccessDenied]);
|
|
3629
|
+
React.useEffect(function () {
|
|
3630
|
+
if (captureDevice.microphoneAccessDenied) onMicrophoneAccessDenied === null || onMicrophoneAccessDenied === void 0 ? void 0 : onMicrophoneAccessDenied();
|
|
3631
|
+
}, [captureDevice.microphoneAccessDenied, onMicrophoneAccessDenied]);
|
|
3632
|
+
var releaseCameraAccess = captureDevice.releaseCameraAccess;
|
|
3633
|
+
React.useEffect(function () {
|
|
3634
|
+
return function () {
|
|
3635
|
+
releaseCameraAccess();
|
|
3636
|
+
};
|
|
3637
|
+
}, [releaseCameraAccess]);
|
|
3638
|
+
return /*#__PURE__*/React.createElement(CameraStateContext.Provider, {
|
|
3639
|
+
value: captureDevice
|
|
3640
|
+
}, children);
|
|
3641
|
+
};
|
|
3642
|
+
|
|
3643
|
+
function _typeof$1(o) {
|
|
3644
|
+
"@babel/helpers - typeof";
|
|
3645
|
+
|
|
3646
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
3647
|
+
return typeof o;
|
|
3648
|
+
} : function (o) {
|
|
3649
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
3650
|
+
}, _typeof$1(o);
|
|
3651
|
+
}
|
|
3652
|
+
|
|
3653
|
+
function toPrimitive(t, r) {
|
|
3654
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
3655
|
+
var e = t[Symbol.toPrimitive];
|
|
3656
|
+
if (void 0 !== e) {
|
|
3657
|
+
var i = e.call(t, r);
|
|
3658
|
+
if ("object" != _typeof$1(i)) return i;
|
|
3659
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
3660
|
+
}
|
|
3661
|
+
return (String )(t);
|
|
3662
|
+
}
|
|
3663
|
+
|
|
3664
|
+
function toPropertyKey(t) {
|
|
3665
|
+
var i = toPrimitive(t, "string");
|
|
3666
|
+
return "symbol" == _typeof$1(i) ? i : i + "";
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
function _defineProperties(e, r) {
|
|
3670
|
+
for (var t = 0; t < r.length; t++) {
|
|
3671
|
+
var o = r[t];
|
|
3672
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
|
|
3673
|
+
}
|
|
3674
|
+
}
|
|
3675
|
+
function _createClass(e, r, t) {
|
|
3676
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
3677
|
+
writable: !1
|
|
3678
|
+
}), e;
|
|
3679
|
+
}
|
|
3680
|
+
|
|
3681
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
3682
|
+
try {
|
|
3683
|
+
var i = n[a](c),
|
|
3684
|
+
u = i.value;
|
|
3685
|
+
} catch (n) {
|
|
3686
|
+
return void e(n);
|
|
3687
|
+
}
|
|
3688
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
3689
|
+
}
|
|
3690
|
+
function _asyncToGenerator(n) {
|
|
3691
|
+
return function () {
|
|
3692
|
+
var t = this,
|
|
3693
|
+
e = arguments;
|
|
3694
|
+
return new Promise(function (r, o) {
|
|
3695
|
+
var a = n.apply(t, e);
|
|
3696
|
+
function _next(n) {
|
|
3697
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
3698
|
+
}
|
|
3699
|
+
function _throw(n) {
|
|
3700
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
3701
|
+
}
|
|
3702
|
+
_next(void 0);
|
|
3703
|
+
});
|
|
3704
|
+
};
|
|
3705
|
+
}
|
|
3706
|
+
|
|
3707
|
+
function _setPrototypeOf(t, e) {
|
|
3708
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
3709
|
+
return t.__proto__ = e, t;
|
|
3710
|
+
}, _setPrototypeOf(t, e);
|
|
3711
|
+
}
|
|
3712
|
+
|
|
3713
|
+
function _inheritsLoose(t, o) {
|
|
3714
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
3715
|
+
}
|
|
3716
|
+
|
|
3717
|
+
function _getPrototypeOf(t) {
|
|
3718
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
3719
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
3720
|
+
}, _getPrototypeOf(t);
|
|
3721
|
+
}
|
|
3722
|
+
|
|
3723
|
+
function _isNativeFunction(t) {
|
|
3724
|
+
try {
|
|
3725
|
+
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
3726
|
+
} catch (n) {
|
|
3727
|
+
return "function" == typeof t;
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3731
|
+
function _isNativeReflectConstruct() {
|
|
3732
|
+
try {
|
|
3733
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
3734
|
+
} catch (t) {}
|
|
3735
|
+
return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
|
|
3736
|
+
return !!t;
|
|
3737
|
+
})();
|
|
3738
|
+
}
|
|
3739
|
+
|
|
3740
|
+
function _construct(t, e, r) {
|
|
3741
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
3742
|
+
var o = [null];
|
|
3743
|
+
o.push.apply(o, e);
|
|
3744
|
+
var p = new (t.bind.apply(t, o))();
|
|
3745
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
3746
|
+
}
|
|
3747
|
+
|
|
3748
|
+
function _wrapNativeSuper(t) {
|
|
3749
|
+
var r = "function" == typeof Map ? new Map() : void 0;
|
|
3750
|
+
return _wrapNativeSuper = function _wrapNativeSuper(t) {
|
|
3751
|
+
if (null === t || !_isNativeFunction(t)) return t;
|
|
3752
|
+
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
3753
|
+
if (void 0 !== r) {
|
|
3754
|
+
if (r.has(t)) return r.get(t);
|
|
3755
|
+
r.set(t, Wrapper);
|
|
3756
|
+
}
|
|
3757
|
+
function Wrapper() {
|
|
3758
|
+
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|
3759
|
+
}
|
|
3760
|
+
return Wrapper.prototype = Object.create(t.prototype, {
|
|
3761
|
+
constructor: {
|
|
3762
|
+
value: Wrapper,
|
|
3763
|
+
enumerable: !1,
|
|
3764
|
+
writable: !0,
|
|
3765
|
+
configurable: !0
|
|
3766
|
+
}
|
|
3767
|
+
}), _setPrototypeOf(Wrapper, t);
|
|
3768
|
+
}, _wrapNativeSuper(t);
|
|
3769
|
+
}
|
|
3770
|
+
|
|
3771
|
+
var regeneratorRuntime$1 = {exports: {}};
|
|
3772
|
+
|
|
3773
|
+
var _typeof = {exports: {}};
|
|
3774
|
+
|
|
3775
|
+
(function (module) {
|
|
3776
|
+
function _typeof(o) {
|
|
3777
|
+
"@babel/helpers - typeof";
|
|
3778
|
+
|
|
3779
|
+
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
3780
|
+
return typeof o;
|
|
3781
|
+
} : function (o) {
|
|
3782
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
3783
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
|
|
3784
|
+
}
|
|
3785
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
3183
3786
|
})(_typeof);
|
|
3184
3787
|
var _typeofExports = _typeof.exports;
|
|
3185
3788
|
|
|
@@ -3509,9 +4112,9 @@
|
|
|
3509
4112
|
}
|
|
3510
4113
|
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
3511
4114
|
|
|
3512
|
-
function _createForOfIteratorHelperLoose$
|
|
3513
|
-
function _unsupportedIterableToArray$
|
|
3514
|
-
function _arrayLikeToArray$
|
|
4115
|
+
function _createForOfIteratorHelperLoose$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4116
|
+
function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
|
|
4117
|
+
function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
3515
4118
|
var t = self;
|
|
3516
4119
|
function e() {
|
|
3517
4120
|
throw Error("Invalid UTF8");
|
|
@@ -5738,7 +6341,7 @@
|
|
|
5738
6341
|
height: (_hn4 = hn(e, 4)) != null ? _hn4 : 0,
|
|
5739
6342
|
angle: 0
|
|
5740
6343
|
}), (_en2 = en(t, ws, 4)) != null && _en2.g().length) {
|
|
5741
|
-
for (var _iterator = _createForOfIteratorHelperLoose$
|
|
6344
|
+
for (var _iterator = _createForOfIteratorHelperLoose$1(en(t, ws, 4).g()), _step; !(_step = _iterator()).done;) {
|
|
5742
6345
|
var _We, _We2, _We3, _un3;
|
|
5743
6346
|
var _e16 = _step.value;
|
|
5744
6347
|
i.keypoints.push({
|
|
@@ -5753,7 +6356,7 @@
|
|
|
5753
6356
|
}
|
|
5754
6357
|
function Qi(t) {
|
|
5755
6358
|
var e = [];
|
|
5756
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose$
|
|
6359
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose$1(rn(t, Fs, 1)), _step2; !(_step2 = _iterator2()).done;) {
|
|
5757
6360
|
var _fn2, _fn3, _fn4;
|
|
5758
6361
|
var _n14 = _step2.value;
|
|
5759
6362
|
e.push({
|
|
@@ -5766,7 +6369,7 @@
|
|
|
5766
6369
|
}
|
|
5767
6370
|
function to(t) {
|
|
5768
6371
|
var e = [];
|
|
5769
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose$
|
|
6372
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose$1(rn(t, Ts, 1)), _step3; !(_step3 = _iterator3()).done;) {
|
|
5770
6373
|
var _fn5, _fn6, _fn7;
|
|
5771
6374
|
var _n15 = _step3.value;
|
|
5772
6375
|
e.push({
|
|
@@ -5914,7 +6517,7 @@
|
|
|
5914
6517
|
var r = new Uint32Array(e.length);
|
|
5915
6518
|
for (var _n16 = 0; _n16 < e.length; _n16++) r[_n16] = t.i.stringToNewUTF8(e[_n16]);
|
|
5916
6519
|
e = t.i._malloc(4 * r.length), t.i.HEAPU32.set(r, e >> 2), n(e);
|
|
5917
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose$
|
|
6520
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose$1(r), _step4; !(_step4 = _iterator4()).done;) {
|
|
5918
6521
|
var _e17 = _step4.value;
|
|
5919
6522
|
t.i._free(_e17);
|
|
5920
6523
|
}
|
|
@@ -6280,7 +6883,7 @@
|
|
|
6280
6883
|
}
|
|
6281
6884
|
t.push(n);
|
|
6282
6885
|
};
|
|
6283
|
-
for (var _iterator7 = _createForOfIteratorHelperLoose$
|
|
6886
|
+
for (var _iterator7 = _createForOfIteratorHelperLoose$1(this.g), _step7; !(_step7 = _iterator7()).done;) {
|
|
6284
6887
|
_loop();
|
|
6285
6888
|
}
|
|
6286
6889
|
return new _Yo(t, this.ba(), this.K(), this.canvas, this.l, this.width, this.height);
|
|
@@ -6412,7 +7015,7 @@
|
|
|
6412
7015
|
}
|
|
6413
7016
|
t.push(n);
|
|
6414
7017
|
};
|
|
6415
|
-
for (var _iterator8 = _createForOfIteratorHelperLoose$
|
|
7018
|
+
for (var _iterator8 = _createForOfIteratorHelperLoose$1(this.g), _step8; !(_step8 = _iterator8()).done;) {
|
|
6416
7019
|
_loop2();
|
|
6417
7020
|
}
|
|
6418
7021
|
return new _ia(t, this.K(), this.canvas, this.l, this.width, this.height);
|
|
@@ -6892,7 +7495,7 @@
|
|
|
6892
7495
|
yn(e, si, this.h);
|
|
6893
7496
|
var n = new qr();
|
|
6894
7497
|
Hr(n, "mediapipe.tasks.vision.face_detector.FaceDetectorGraph"), Yr(n, "IMAGE:image_in"), Yr(n, "NORM_RECT:norm_rect_in"), $r(n, "DETECTIONS:detections"), n.o(e), es(t, n), this.g.attachProtoVectorListener("detections", function (t, e) {
|
|
6895
|
-
for (var _iterator9 = _createForOfIteratorHelperLoose$
|
|
7498
|
+
for (var _iterator9 = _createForOfIteratorHelperLoose$1(t), _step9; !(_step9 = _iterator9()).done;) {
|
|
6896
7499
|
var _e23 = _step9.value;
|
|
6897
7500
|
t = Es(_e23), _this43.j.detections.push(Zi(t));
|
|
6898
7501
|
}
|
|
@@ -6986,7 +7589,7 @@
|
|
|
6986
7589
|
yn(e, di, this.h);
|
|
6987
7590
|
var n = new qr();
|
|
6988
7591
|
Hr(n, "mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"), Yr(n, "IMAGE:image_in"), Yr(n, "NORM_RECT:norm_rect"), $r(n, "NORM_LANDMARKS:face_landmarks"), n.o(e), es(t, n), this.g.attachProtoVectorListener("face_landmarks", function (t, e) {
|
|
6989
|
-
for (var _iterator10 = _createForOfIteratorHelperLoose$
|
|
7592
|
+
for (var _iterator10 = _createForOfIteratorHelperLoose$1(t), _step10; !(_step10 = _iterator10()).done;) {
|
|
6990
7593
|
var _e24 = _step10.value;
|
|
6991
7594
|
t = Ms(_e24), _this45.j.faceLandmarks.push(Qi(t));
|
|
6992
7595
|
}
|
|
@@ -6995,7 +7598,7 @@
|
|
|
6995
7598
|
_o(_this45, t);
|
|
6996
7599
|
}), this.outputFaceBlendshapes && (rs(t, "blendshapes"), $r(n, "BLENDSHAPES:blendshapes"), this.g.attachProtoVectorListener("blendshapes", function (t, e) {
|
|
6997
7600
|
if (_this45.outputFaceBlendshapes) {
|
|
6998
|
-
for (var _iterator11 = _createForOfIteratorHelperLoose$
|
|
7601
|
+
for (var _iterator11 = _createForOfIteratorHelperLoose$1(t), _step11; !(_step11 = _iterator11()).done;) {
|
|
6999
7602
|
var _t$g;
|
|
7000
7603
|
var _e25 = _step11.value;
|
|
7001
7604
|
t = fs(_e25), _this45.j.faceBlendshapes.push(Ji((_t$g = t.g()) != null ? _t$g : []));
|
|
@@ -7006,7 +7609,7 @@
|
|
|
7006
7609
|
_o(_this45, t);
|
|
7007
7610
|
})), this.outputFacialTransformationMatrixes && (rs(t, "face_geometry"), $r(n, "FACE_GEOMETRY:face_geometry"), this.g.attachProtoVectorListener("face_geometry", function (t, e) {
|
|
7008
7611
|
if (_this45.outputFacialTransformationMatrixes) {
|
|
7009
|
-
for (var _iterator12 = _createForOfIteratorHelperLoose$
|
|
7612
|
+
for (var _iterator12 = _createForOfIteratorHelperLoose$1(t), _step12; !(_step12 = _iterator12()).done;) {
|
|
7010
7613
|
var _ln2, _ln3, _He;
|
|
7011
7614
|
var _e26 = _step12.value;
|
|
7012
7615
|
(t = en(ai(_e26), Ps, 2)) && _this45.j.facialTransformationMatrixes.push({
|
|
@@ -7137,11 +7740,11 @@
|
|
|
7137
7740
|
e = !0;
|
|
7138
7741
|
}
|
|
7139
7742
|
var n = [];
|
|
7140
|
-
for (var _iterator13 = _createForOfIteratorHelperLoose$
|
|
7743
|
+
for (var _iterator13 = _createForOfIteratorHelperLoose$1(t), _step13; !(_step13 = _iterator13()).done;) {
|
|
7141
7744
|
var _s9 = _step13.value;
|
|
7142
7745
|
var r = fs(_s9);
|
|
7143
7746
|
t = [];
|
|
7144
|
-
for (var _iterator14 = _createForOfIteratorHelperLoose$
|
|
7747
|
+
for (var _iterator14 = _createForOfIteratorHelperLoose$1(r.g()), _step14; !(_step14 = _iterator14()).done;) {
|
|
7145
7748
|
var _fn8, _ref9, _un4, _ref10, _un5;
|
|
7146
7749
|
var _n24 = _step14.value;
|
|
7147
7750
|
r = e && null != hn(_n24, 1) ? ln(hn(_n24, 1)) : -1, t.push({
|
|
@@ -7187,11 +7790,11 @@
|
|
|
7187
7790
|
yn(e, Oi, this.v);
|
|
7188
7791
|
var n = new qr();
|
|
7189
7792
|
Hr(n, "mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"), Yr(n, "IMAGE:image_in"), Yr(n, "NORM_RECT:norm_rect"), $r(n, "HAND_GESTURES:hand_gestures"), $r(n, "LANDMARKS:hand_landmarks"), $r(n, "WORLD_LANDMARKS:world_hand_landmarks"), $r(n, "HANDEDNESS:handedness"), n.o(e), es(t, n), this.g.attachProtoVectorListener("hand_landmarks", function (t, e) {
|
|
7190
|
-
for (var _iterator15 = _createForOfIteratorHelperLoose$
|
|
7793
|
+
for (var _iterator15 = _createForOfIteratorHelperLoose$1(t), _step15; !(_step15 = _iterator15()).done;) {
|
|
7191
7794
|
var _e28 = _step15.value;
|
|
7192
7795
|
t = Ms(_e28);
|
|
7193
7796
|
var _n25 = [];
|
|
7194
|
-
for (var _iterator16 = _createForOfIteratorHelperLoose$
|
|
7797
|
+
for (var _iterator16 = _createForOfIteratorHelperLoose$1(rn(t, Fs, 1)), _step16; !(_step16 = _iterator16()).done;) {
|
|
7195
7798
|
var _fn9, _fn10, _fn11;
|
|
7196
7799
|
var _e29 = _step16.value;
|
|
7197
7800
|
_n25.push({
|
|
@@ -7206,11 +7809,11 @@
|
|
|
7206
7809
|
}), this.g.attachEmptyPacketListener("hand_landmarks", function (t) {
|
|
7207
7810
|
_o(_this49, t);
|
|
7208
7811
|
}), this.g.attachProtoVectorListener("world_hand_landmarks", function (t, e) {
|
|
7209
|
-
for (var _iterator17 = _createForOfIteratorHelperLoose$
|
|
7812
|
+
for (var _iterator17 = _createForOfIteratorHelperLoose$1(t), _step17; !(_step17 = _iterator17()).done;) {
|
|
7210
7813
|
var _e30 = _step17.value;
|
|
7211
7814
|
t = Ls(_e30);
|
|
7212
7815
|
var _n26 = [];
|
|
7213
|
-
for (var _iterator18 = _createForOfIteratorHelperLoose$
|
|
7816
|
+
for (var _iterator18 = _createForOfIteratorHelperLoose$1(rn(t, Ts, 1)), _step18; !(_step18 = _iterator18()).done;) {
|
|
7214
7817
|
var _fn12, _fn13, _fn14;
|
|
7215
7818
|
var _e31 = _step18.value;
|
|
7216
7819
|
_n26.push({
|
|
@@ -7295,7 +7898,7 @@
|
|
|
7295
7898
|
yn(e, Si, this.j);
|
|
7296
7899
|
var n = new qr();
|
|
7297
7900
|
Hr(n, "mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"), Yr(n, "IMAGE:image_in"), Yr(n, "NORM_RECT:norm_rect"), $r(n, "LANDMARKS:hand_landmarks"), $r(n, "WORLD_LANDMARKS:world_hand_landmarks"), $r(n, "HANDEDNESS:handedness"), n.o(e), es(t, n), this.g.attachProtoVectorListener("hand_landmarks", function (t, e) {
|
|
7298
|
-
for (var _iterator19 = _createForOfIteratorHelperLoose$
|
|
7901
|
+
for (var _iterator19 = _createForOfIteratorHelperLoose$1(t), _step19; !(_step19 = _iterator19()).done;) {
|
|
7299
7902
|
var _e32 = _step19.value;
|
|
7300
7903
|
t = Ms(_e32), _this51.landmarks.push(Qi(t));
|
|
7301
7904
|
}
|
|
@@ -7303,7 +7906,7 @@
|
|
|
7303
7906
|
}), this.g.attachEmptyPacketListener("hand_landmarks", function (t) {
|
|
7304
7907
|
_o(_this51, t);
|
|
7305
7908
|
}), this.g.attachProtoVectorListener("world_hand_landmarks", function (t, e) {
|
|
7306
|
-
for (var _iterator20 = _createForOfIteratorHelperLoose$
|
|
7909
|
+
for (var _iterator20 = _createForOfIteratorHelperLoose$1(t), _step20; !(_step20 = _iterator20()).done;) {
|
|
7307
7910
|
var _e33 = _step20.value;
|
|
7308
7911
|
t = Ls(_e33), _this51.worldLandmarks.push(to(t));
|
|
7309
7912
|
}
|
|
@@ -7314,11 +7917,11 @@
|
|
|
7314
7917
|
var n = _this51.handedness,
|
|
7315
7918
|
r = n.push;
|
|
7316
7919
|
var s = [];
|
|
7317
|
-
for (var _iterator21 = _createForOfIteratorHelperLoose$
|
|
7920
|
+
for (var _iterator21 = _createForOfIteratorHelperLoose$1(t), _step21; !(_step21 = _iterator21()).done;) {
|
|
7318
7921
|
var _e34 = _step21.value;
|
|
7319
7922
|
t = fs(_e34);
|
|
7320
7923
|
var _n27 = [];
|
|
7321
|
-
for (var _iterator22 = _createForOfIteratorHelperLoose$
|
|
7924
|
+
for (var _iterator22 = _createForOfIteratorHelperLoose$1(t.g()), _step22; !(_step22 = _iterator22()).done;) {
|
|
7322
7925
|
var _fn15, _ln4, _ref11, _un6, _ref12, _un7;
|
|
7323
7926
|
var _e35 = _step22.value;
|
|
7324
7927
|
_n27.push({
|
|
@@ -7710,7 +8313,7 @@
|
|
|
7710
8313
|
dn(a, 3, !0), gn(a, 1, e.keypoint.x), gn(a, 2, e.keypoint.y), on(i, 5, oh, a);
|
|
7711
8314
|
} else {
|
|
7712
8315
|
if (!e.scribble) throw Error("Must provide either a keypoint or a scribble.");
|
|
7713
|
-
for (var _iterator23 = _createForOfIteratorHelperLoose$
|
|
8316
|
+
for (var _iterator23 = _createForOfIteratorHelperLoose$1((o = new sh(), e.scribble)), _step23; !(_step23 = _iterator23()).done;) {
|
|
7714
8317
|
a = _step23.value;
|
|
7715
8318
|
dn(e = new nh(), 3, !0), gn(e, 1, a.x), gn(e, 2, a.y), an(o, nh, e);
|
|
7716
8319
|
}
|
|
@@ -7811,7 +8414,7 @@
|
|
|
7811
8414
|
yn(e, Vi, this.h);
|
|
7812
8415
|
var n = new qr();
|
|
7813
8416
|
Hr(n, "mediapipe.tasks.vision.ObjectDetectorGraph"), Yr(n, "IMAGE:input_frame_gpu"), Yr(n, "NORM_RECT:norm_rect"), $r(n, "DETECTIONS:detections"), n.o(e), es(t, n), this.g.attachProtoVectorListener("detections", function (t, e) {
|
|
7814
|
-
for (var _iterator24 = _createForOfIteratorHelperLoose$
|
|
8417
|
+
for (var _iterator24 = _createForOfIteratorHelperLoose$1(t), _step24; !(_step24 = _iterator24()).done;) {
|
|
7815
8418
|
var _e37 = _step24.value;
|
|
7816
8419
|
t = Es(_e37), _this61.j.detections.push(Zi(t));
|
|
7817
8420
|
}
|
|
@@ -7911,7 +8514,7 @@
|
|
|
7911
8514
|
var n = new qr();
|
|
7912
8515
|
Hr(n, "mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"), Yr(n, "IMAGE:image_in"), Yr(n, "NORM_RECT:norm_rect"), $r(n, "NORM_LANDMARKS:normalized_landmarks"), $r(n, "WORLD_LANDMARKS:world_landmarks"), n.o(e), es(t, n), wo(this, t), this.g.attachProtoVectorListener("normalized_landmarks", function (t, e) {
|
|
7913
8516
|
_this63.landmarks = [];
|
|
7914
|
-
for (var _iterator25 = _createForOfIteratorHelperLoose$
|
|
8517
|
+
for (var _iterator25 = _createForOfIteratorHelperLoose$1(t), _step25; !(_step25 = _iterator25()).done;) {
|
|
7915
8518
|
var _e39 = _step25.value;
|
|
7916
8519
|
t = Ms(_e39), _this63.landmarks.push(Qi(t));
|
|
7917
8520
|
}
|
|
@@ -7920,7 +8523,7 @@
|
|
|
7920
8523
|
_this63.landmarks = [], _o(_this63, t);
|
|
7921
8524
|
}), this.g.attachProtoVectorListener("world_landmarks", function (t, e) {
|
|
7922
8525
|
_this63.worldLandmarks = [];
|
|
7923
|
-
for (var _iterator26 = _createForOfIteratorHelperLoose$
|
|
8526
|
+
for (var _iterator26 = _createForOfIteratorHelperLoose$1(t), _step26; !(_step26 = _iterator26()).done;) {
|
|
7924
8527
|
var _e40 = _step26.value;
|
|
7925
8528
|
t = Ls(_e40), _this63.worldLandmarks.push(to(t));
|
|
7926
8529
|
}
|
|
@@ -7989,55 +8592,19 @@
|
|
|
7989
8592
|
case 1:
|
|
7990
8593
|
_a.trys.push([1,, 3, 4]);
|
|
7991
8594
|
return [4 /*yield*/, preloadDependency(url)];
|
|
7992
|
-
case 2:
|
|
7993
|
-
_a.sent();
|
|
7994
|
-
return [3 /*break*/, 4];
|
|
7995
|
-
case 3:
|
|
7996
|
-
document.removeEventListener('idmission.preloadProgress', handleDownloadProgress);
|
|
7997
|
-
visionRuntimePreloading = false;
|
|
7998
|
-
return [7 /*endfinally*/];
|
|
7999
|
-
case 4:
|
|
8000
|
-
return [2 /*return*/];
|
|
8001
|
-
}
|
|
8002
|
-
});
|
|
8003
|
-
});
|
|
8004
|
-
}
|
|
8005
|
-
|
|
8006
|
-
function getFrameDimensions(frame) {
|
|
8007
|
-
var frameWidth = frame.width,
|
|
8008
|
-
frameHeight = frame.height;
|
|
8009
|
-
if (frame instanceof HTMLImageElement) {
|
|
8010
|
-
frameWidth = frame.naturalWidth;
|
|
8011
|
-
frameHeight = frame.naturalHeight;
|
|
8012
|
-
}
|
|
8013
|
-
if (frame instanceof HTMLVideoElement) {
|
|
8014
|
-
frameWidth = frame.videoWidth;
|
|
8015
|
-
frameHeight = frame.videoHeight;
|
|
8016
|
-
}
|
|
8017
|
-
return [frameWidth, frameHeight];
|
|
8018
|
-
}
|
|
8019
|
-
|
|
8020
|
-
var InvisibleCanvas = styled.canvas(templateObject_1$G || (templateObject_1$G = __makeTemplateObject(["\n display: none;\n"], ["\n display: none;\n"])));
|
|
8021
|
-
function drawToCanvas(canvas, frame, width, height) {
|
|
8022
|
-
if (!canvas) return;
|
|
8023
|
-
var ctx = canvas.getContext('2d');
|
|
8024
|
-
if (!ctx) return;
|
|
8025
|
-
if (!width || !height) {
|
|
8026
|
-
var _a = getFrameDimensions(frame),
|
|
8027
|
-
frameWidth = _a[0],
|
|
8028
|
-
frameHeight = _a[1];
|
|
8029
|
-
width || (width = frameWidth);
|
|
8030
|
-
height || (height = frameHeight);
|
|
8031
|
-
}
|
|
8032
|
-
canvas.width = width;
|
|
8033
|
-
canvas.height = height;
|
|
8034
|
-
ctx.drawImage(frame, 0, 0, width, height);
|
|
8035
|
-
}
|
|
8036
|
-
function clearCanvas(canvas) {
|
|
8037
|
-
var _a;
|
|
8038
|
-
(_a = canvas === null || canvas === void 0 ? void 0 : canvas.getContext('2d')) === null || _a === void 0 ? void 0 : _a.clearRect(0, 0, canvas === null || canvas === void 0 ? void 0 : canvas.width, canvas === null || canvas === void 0 ? void 0 : canvas.height);
|
|
8595
|
+
case 2:
|
|
8596
|
+
_a.sent();
|
|
8597
|
+
return [3 /*break*/, 4];
|
|
8598
|
+
case 3:
|
|
8599
|
+
document.removeEventListener('idmission.preloadProgress', handleDownloadProgress);
|
|
8600
|
+
visionRuntimePreloading = false;
|
|
8601
|
+
return [7 /*endfinally*/];
|
|
8602
|
+
case 4:
|
|
8603
|
+
return [2 /*return*/];
|
|
8604
|
+
}
|
|
8605
|
+
});
|
|
8606
|
+
});
|
|
8039
8607
|
}
|
|
8040
|
-
var templateObject_1$G;
|
|
8041
8608
|
|
|
8042
8609
|
function cropToShoulders(rawCanvas, cropCanvas, resizeCanvas, frame, face, quality, maxHeight) {
|
|
8043
8610
|
if (quality === void 0) {
|
|
@@ -8342,8 +8909,7 @@
|
|
|
8342
8909
|
modelPath = _b === void 0 ? defaultFocusModelPath : _b,
|
|
8343
8910
|
_c = _a.modelLoadTimeoutMs,
|
|
8344
8911
|
modelLoadTimeoutMs = _c === void 0 ? defaultFocusModelLoadTimeoutMs : _c,
|
|
8345
|
-
onModelError = _a.onModelError
|
|
8346
|
-
videoRef = _a.videoRef;
|
|
8912
|
+
onModelError = _a.onModelError;
|
|
8347
8913
|
var _d = React.useState(false),
|
|
8348
8914
|
ready = _d[0],
|
|
8349
8915
|
setReady = _d[1];
|
|
@@ -8353,6 +8919,7 @@
|
|
|
8353
8919
|
var _f = React.useState(null),
|
|
8354
8920
|
modelError = _f[0],
|
|
8355
8921
|
setModelError = _f[1];
|
|
8922
|
+
var videoRef = React.useContext(CameraStateContext).videoRef;
|
|
8356
8923
|
React.useEffect(function loadModel() {
|
|
8357
8924
|
var _this = this;
|
|
8358
8925
|
setReady(false);
|
|
@@ -8490,8 +9057,7 @@
|
|
|
8490
9057
|
function useLoadFaceDetector(_a) {
|
|
8491
9058
|
var onModelError = _a.onModelError,
|
|
8492
9059
|
_b = _a.modelLoadTimeoutMs,
|
|
8493
|
-
modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b
|
|
8494
|
-
videoRef = _a.videoRef;
|
|
9060
|
+
modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b;
|
|
8495
9061
|
var _c = React.useState(false),
|
|
8496
9062
|
ready = _c[0],
|
|
8497
9063
|
setReady = _c[1];
|
|
@@ -8501,6 +9067,7 @@
|
|
|
8501
9067
|
var _e = React.useState(null),
|
|
8502
9068
|
modelError = _e[0],
|
|
8503
9069
|
setModelError = _e[1];
|
|
9070
|
+
var videoRef = React.useContext(CameraStateContext).videoRef;
|
|
8504
9071
|
React.useEffect(function loadModel() {
|
|
8505
9072
|
var _this = this;
|
|
8506
9073
|
setReady(false);
|
|
@@ -8981,8 +9548,7 @@
|
|
|
8981
9548
|
modelLoadTimeoutMs = _c === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _c,
|
|
8982
9549
|
_d = _a.scoreThreshold,
|
|
8983
9550
|
scoreThreshold = _d === void 0 ? defaultDocumentDetectionScoreThreshold : _d,
|
|
8984
|
-
onModelError = _a.onModelError
|
|
8985
|
-
videoRef = _a.videoRef;
|
|
9551
|
+
onModelError = _a.onModelError;
|
|
8986
9552
|
var _e = React.useState(false),
|
|
8987
9553
|
ready = _e[0],
|
|
8988
9554
|
setReady = _e[1];
|
|
@@ -8992,6 +9558,7 @@
|
|
|
8992
9558
|
var _g = React.useState(null),
|
|
8993
9559
|
modelError = _g[0],
|
|
8994
9560
|
setModelError = _g[1];
|
|
9561
|
+
var videoRef = React.useContext(CameraStateContext).videoRef;
|
|
8995
9562
|
React.useEffect(function loadModel() {
|
|
8996
9563
|
var _this = this;
|
|
8997
9564
|
setReady(false);
|
|
@@ -9247,597 +9814,57 @@
|
|
|
9247
9814
|
var frameId = React.useRef(0);
|
|
9248
9815
|
React.useEffect(function runFrameLoop() {
|
|
9249
9816
|
if (!running) return;
|
|
9250
|
-
var timer;
|
|
9251
|
-
var currentLoopId = loopId.current;
|
|
9252
|
-
function renderPrediction() {
|
|
9253
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
9254
|
-
var start, timeRunning, took, amountToThrottle;
|
|
9255
|
-
var _a, _b;
|
|
9256
|
-
return __generator(this, function (_c) {
|
|
9257
|
-
switch (_c.label) {
|
|
9258
|
-
case 0:
|
|
9259
|
-
if (currentLoopId !== loopId.current) return [2 /*return*/];
|
|
9260
|
-
start = new Date().getTime();
|
|
9261
|
-
timeRunning = start - ((_b = (_a = startedAtRef.current) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0);
|
|
9262
|
-
return [4 /*yield*/, fn(frameId.current, timeRunning)];
|
|
9263
|
-
case 1:
|
|
9264
|
-
_c.sent();
|
|
9265
|
-
took = new Date().getTime() - start;
|
|
9266
|
-
amountToThrottle = Math.max((throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0) - took, 0);
|
|
9267
|
-
timer = setTimeout(function () {
|
|
9268
|
-
frameId.current = requestAnimationFrame(renderPrediction);
|
|
9269
|
-
}, amountToThrottle);
|
|
9270
|
-
return [2 /*return*/];
|
|
9271
|
-
}
|
|
9272
|
-
});
|
|
9273
|
-
});
|
|
9274
|
-
}
|
|
9275
|
-
renderPrediction().then();
|
|
9276
|
-
return function () {
|
|
9277
|
-
loopId.current += 1;
|
|
9278
|
-
frameId.current && cancelAnimationFrame(frameId.current);
|
|
9279
|
-
timer && clearTimeout(timer);
|
|
9280
|
-
};
|
|
9281
|
-
}, [fn, running, throttleMs]);
|
|
9282
|
-
var start = React.useCallback(function () {
|
|
9283
|
-
startedAtRef.current = new Date();
|
|
9284
|
-
setRunning(true);
|
|
9285
|
-
}, []);
|
|
9286
|
-
var stop = React.useCallback(function () {
|
|
9287
|
-
loopId.current += 1; // force the loop to stop immediately.
|
|
9288
|
-
setRunning(false);
|
|
9289
|
-
startedAtRef.current = null;
|
|
9290
|
-
}, []);
|
|
9291
|
-
React.useEffect(function startAutomatically() {
|
|
9292
|
-
if (autoStart) start();
|
|
9293
|
-
return function () {
|
|
9294
|
-
stop();
|
|
9295
|
-
};
|
|
9296
|
-
}, [autoStart, start, stop]);
|
|
9297
|
-
return {
|
|
9298
|
-
start: start,
|
|
9299
|
-
stop: stop
|
|
9300
|
-
};
|
|
9301
|
-
}
|
|
9302
|
-
|
|
9303
|
-
var createStoreImpl = function createStoreImpl(createState) {
|
|
9304
|
-
var state;
|
|
9305
|
-
var listeners = /* @__PURE__ */new Set();
|
|
9306
|
-
var setState = function setState(partial, replace) {
|
|
9307
|
-
var nextState = typeof partial === "function" ? partial(state) : partial;
|
|
9308
|
-
if (!Object.is(nextState, state)) {
|
|
9309
|
-
var previousState = state;
|
|
9310
|
-
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
9311
|
-
listeners.forEach(function (listener) {
|
|
9312
|
-
return listener(state, previousState);
|
|
9313
|
-
});
|
|
9314
|
-
}
|
|
9315
|
-
};
|
|
9316
|
-
var getState = function getState() {
|
|
9317
|
-
return state;
|
|
9318
|
-
};
|
|
9319
|
-
var getInitialState = function getInitialState() {
|
|
9320
|
-
return initialState;
|
|
9321
|
-
};
|
|
9322
|
-
var subscribe = function subscribe(listener) {
|
|
9323
|
-
listeners.add(listener);
|
|
9324
|
-
return function () {
|
|
9325
|
-
return listeners["delete"](listener);
|
|
9326
|
-
};
|
|
9327
|
-
};
|
|
9328
|
-
var api = {
|
|
9329
|
-
setState: setState,
|
|
9330
|
-
getState: getState,
|
|
9331
|
-
getInitialState: getInitialState,
|
|
9332
|
-
subscribe: subscribe
|
|
9333
|
-
};
|
|
9334
|
-
var initialState = state = createState(setState, getState, api);
|
|
9335
|
-
return api;
|
|
9336
|
-
};
|
|
9337
|
-
var createStore = function createStore(createState) {
|
|
9338
|
-
return createState ? createStoreImpl(createState) : createStoreImpl;
|
|
9339
|
-
};
|
|
9340
|
-
|
|
9341
|
-
var identity = function identity(arg) {
|
|
9342
|
-
return arg;
|
|
9343
|
-
};
|
|
9344
|
-
function useStore(api, selector) {
|
|
9345
|
-
if (selector === void 0) {
|
|
9346
|
-
selector = identity;
|
|
9347
|
-
}
|
|
9348
|
-
var slice = React.useSyncExternalStore(api.subscribe, function () {
|
|
9349
|
-
return selector(api.getState());
|
|
9350
|
-
}, function () {
|
|
9351
|
-
return selector(api.getInitialState());
|
|
9352
|
-
});
|
|
9353
|
-
React.useDebugValue(slice);
|
|
9354
|
-
return slice;
|
|
9355
|
-
}
|
|
9356
|
-
|
|
9357
|
-
function listAvailableCameras(facingMode_1) {
|
|
9358
|
-
return __awaiter(this, arguments, void 0, function (facingMode, requestMicAccess) {
|
|
9359
|
-
var cameraEnumerationStream, videoDevices;
|
|
9360
|
-
if (requestMicAccess === void 0) {
|
|
9361
|
-
requestMicAccess = false;
|
|
9362
|
-
}
|
|
9363
|
-
return __generator(this, function (_a) {
|
|
9364
|
-
switch (_a.label) {
|
|
9365
|
-
case 0:
|
|
9366
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
9367
|
-
video: {
|
|
9368
|
-
facingMode: {
|
|
9369
|
-
exact: facingMode
|
|
9370
|
-
}
|
|
9371
|
-
},
|
|
9372
|
-
audio: requestMicAccess
|
|
9373
|
-
})
|
|
9374
|
-
// This lists all available cameras attached to the user's device.
|
|
9375
|
-
];
|
|
9376
|
-
case 1:
|
|
9377
|
-
cameraEnumerationStream = _a.sent();
|
|
9378
|
-
return [4 /*yield*/, navigator.mediaDevices.enumerateDevices()];
|
|
9379
|
-
case 2:
|
|
9380
|
-
videoDevices = _a.sent().filter(function (_a) {
|
|
9381
|
-
var kind = _a.kind;
|
|
9382
|
-
return kind === 'videoinput';
|
|
9383
|
-
});
|
|
9384
|
-
// Release the access to the user's camera that we obtained for enumeration purposes.
|
|
9385
|
-
cameraEnumerationStream.getVideoTracks().forEach(function (track) {
|
|
9386
|
-
track.enabled = false;
|
|
9387
|
-
track.stop();
|
|
9388
|
-
});
|
|
9389
|
-
cameraEnumerationStream = null;
|
|
9390
|
-
return [2 /*return*/, videoDevices];
|
|
9391
|
-
}
|
|
9392
|
-
});
|
|
9393
|
-
});
|
|
9394
|
-
}
|
|
9395
|
-
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) {
|
|
9396
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
9397
|
-
});
|
|
9398
|
-
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) {
|
|
9399
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
9400
|
-
});
|
|
9401
|
-
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) {
|
|
9402
|
-
return s.toLocaleLowerCase().split(' ').join('');
|
|
9403
|
-
});
|
|
9404
|
-
var cameraLabelMatches = function cameraLabelMatches(labelOrDevice, labelSetOrLabel) {
|
|
9405
|
-
var label = labelOrDevice instanceof MediaDeviceInfo ? getDeviceLabel(labelOrDevice) : labelOrDevice;
|
|
9406
|
-
var labelSet = typeof labelSetOrLabel === 'string' ? [labelSetOrLabel] : labelSetOrLabel;
|
|
9407
|
-
return labelSet.some(function (l) {
|
|
9408
|
-
return label.includes(l);
|
|
9409
|
-
});
|
|
9410
|
-
};
|
|
9411
|
-
var getDeviceLabel = function getDeviceLabel(deviceInfo) {
|
|
9412
|
-
return deviceInfo.label.toLocaleLowerCase().split(' ').join('');
|
|
9413
|
-
};
|
|
9414
|
-
var currentCamera;
|
|
9415
|
-
function obtainCameraAccess(stream, deviceLabel, video) {
|
|
9416
|
-
releaseCameraAccess();
|
|
9417
|
-
log('obtaining camera access...');
|
|
9418
|
-
var _a = stream.getVideoTracks()[0].getSettings(),
|
|
9419
|
-
width = _a.width,
|
|
9420
|
-
height = _a.height;
|
|
9421
|
-
log('camera dimensions', width, height);
|
|
9422
|
-
var label = deviceLabel.toLocaleLowerCase().split(' ').join('');
|
|
9423
|
-
log('camera label', label);
|
|
9424
|
-
var isRearFacing = cameraLabelMatches(label, __spreadArray(__spreadArray(__spreadArray([], rearCameraLabels, true), backUltraWideCameraLabels, true), ['iphone'], false));
|
|
9425
|
-
log('is rear facing?', isRearFacing);
|
|
9426
|
-
var release = function release() {
|
|
9427
|
-
stream.getTracks().forEach(function (track) {
|
|
9428
|
-
track.enabled = false;
|
|
9429
|
-
track.stop();
|
|
9430
|
-
});
|
|
9431
|
-
if (video) {
|
|
9432
|
-
video.pause();
|
|
9433
|
-
video.srcObject = null;
|
|
9434
|
-
video.src = '';
|
|
9435
|
-
}
|
|
9436
|
-
};
|
|
9437
|
-
width || (width = 0);
|
|
9438
|
-
height || (height = 0);
|
|
9439
|
-
currentCamera = {
|
|
9440
|
-
label: deviceLabel,
|
|
9441
|
-
stream: stream,
|
|
9442
|
-
width: width,
|
|
9443
|
-
height: height,
|
|
9444
|
-
isRearFacing: isRearFacing,
|
|
9445
|
-
release: release
|
|
9446
|
-
};
|
|
9447
|
-
log('camera access granted');
|
|
9448
|
-
if (video) video.srcObject = stream;
|
|
9449
|
-
log('video source initialized');
|
|
9450
|
-
return currentCamera;
|
|
9451
|
-
}
|
|
9452
|
-
function releaseCameraAccess() {
|
|
9453
|
-
if (!currentCamera) return;
|
|
9454
|
-
log('releasing camera access...');
|
|
9455
|
-
currentCamera.release();
|
|
9456
|
-
currentCamera = undefined;
|
|
9457
|
-
}
|
|
9458
|
-
|
|
9459
|
-
var initialState$5 = {
|
|
9460
|
-
videoRef: {
|
|
9461
|
-
current: null
|
|
9462
|
-
},
|
|
9463
|
-
videoLoaded: false,
|
|
9464
|
-
videoStream: null,
|
|
9465
|
-
videoDevice: null,
|
|
9466
|
-
isRearFacing: false,
|
|
9467
|
-
camera: null,
|
|
9468
|
-
cameraReady: false,
|
|
9469
|
-
cameraAccessDenied: false,
|
|
9470
|
-
iphoneContinuityCameraAvailable: false,
|
|
9471
|
-
iphoneContinuityCameraDenied: false,
|
|
9472
|
-
preferIphoneContinuityCamera: true,
|
|
9473
|
-
audioStream: null,
|
|
9474
|
-
microphoneReady: false,
|
|
9475
|
-
microphoneAccessDenied: false
|
|
9476
|
-
};
|
|
9477
|
-
var createCameraStore = function createCameraStore(config) {
|
|
9478
|
-
var store = createStore(function (set, get) {
|
|
9479
|
-
return _assign(_assign(_assign({}, initialState$5), config), {
|
|
9480
|
-
reset: function reset() {
|
|
9481
|
-
return set(_assign(_assign({}, initialState$5), config));
|
|
9482
|
-
},
|
|
9483
|
-
setConfig: function setConfig(config) {
|
|
9484
|
-
return set(config);
|
|
9485
|
-
},
|
|
9486
|
-
onVideoMounted: function onVideoMounted() {
|
|
9487
|
-
return set({
|
|
9488
|
-
videoLoaded: true
|
|
9489
|
-
});
|
|
9490
|
-
},
|
|
9491
|
-
setIphoneContinuityCameraAllowed: function setIphoneContinuityCameraAllowed(value) {
|
|
9492
|
-
return set({
|
|
9493
|
-
preferIphoneContinuityCamera: value
|
|
9494
|
-
});
|
|
9495
|
-
},
|
|
9496
|
-
requestCameraAccess: function requestCameraAccess() {
|
|
9497
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
9498
|
-
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;
|
|
9499
|
-
var _b, _c, _d;
|
|
9500
|
-
return __generator(this, function (_e) {
|
|
9501
|
-
switch (_e.label) {
|
|
9502
|
-
case 0:
|
|
9503
|
-
_a = get(), videoRef = _a.videoRef, releaseCameraAccess = _a.releaseCameraAccess, preferFrontFacingCamera = _a.preferFrontFacingCamera, preferIphoneContinuityCamera = _a.preferIphoneContinuityCamera, iphoneContinuityCameraDenied = _a.iphoneContinuityCameraDenied;
|
|
9504
|
-
releaseCameraAccess();
|
|
9505
|
-
_e.label = 1;
|
|
9506
|
-
case 1:
|
|
9507
|
-
_e.trys.push([1, 11,, 12]);
|
|
9508
|
-
return [4 /*yield*/, listAvailableCameras()];
|
|
9509
|
-
case 2:
|
|
9510
|
-
availableCameras = _e.sent();
|
|
9511
|
-
selectedCamera = void 0;
|
|
9512
|
-
debug('availableCameras', availableCameras);
|
|
9513
|
-
platform_1 = getPlatform();
|
|
9514
|
-
debug('platformDetails', platform_1);
|
|
9515
|
-
if (!iphoneContinuityCameraDenied && (!(platform_1 === null || platform_1 === void 0 ? void 0 : platform_1.os) || platform_1.os.family === 'OS X')) {
|
|
9516
|
-
iphoneContinuityCamera = availableCameras.find(function (deviceInfo) {
|
|
9517
|
-
return cameraLabelMatches(deviceInfo, 'iphone');
|
|
9518
|
-
});
|
|
9519
|
-
set({
|
|
9520
|
-
iphoneContinuityCameraAvailable: !!iphoneContinuityCamera
|
|
9521
|
-
});
|
|
9522
|
-
if (iphoneContinuityCamera && preferIphoneContinuityCamera) {
|
|
9523
|
-
selectedCamera = iphoneContinuityCamera;
|
|
9524
|
-
}
|
|
9525
|
-
} 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) {
|
|
9526
|
-
return c.label.startsWith('camera2 ');
|
|
9527
|
-
})) {
|
|
9528
|
-
availableCameras = availableCameras.sort(function (a, b) {
|
|
9529
|
-
return a.label.toLowerCase().localeCompare(b.label.toLowerCase());
|
|
9530
|
-
});
|
|
9531
|
-
debug('cameras have been sorted', availableCameras);
|
|
9532
|
-
}
|
|
9533
|
-
if (preferFrontFacingCamera) {
|
|
9534
|
-
selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
9535
|
-
return cameraLabelMatches(deviceInfo, frontCameraLabels);
|
|
9536
|
-
});
|
|
9537
|
-
}
|
|
9538
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
9539
|
-
return cameraLabelMatches(deviceInfo, 'backtriplecamera');
|
|
9540
|
-
}));
|
|
9541
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
9542
|
-
return cameraLabelMatches(deviceInfo, 'backdualcamera');
|
|
9543
|
-
}));
|
|
9544
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
9545
|
-
return cameraLabelMatches(deviceInfo, rearCameraLabels) && !cameraLabelMatches(deviceInfo, backUltraWideCameraLabels);
|
|
9546
|
-
}));
|
|
9547
|
-
selectedCamera || (selectedCamera = availableCameras.find(function (deviceInfo) {
|
|
9548
|
-
return cameraLabelMatches(deviceInfo, rearCameraLabels);
|
|
9549
|
-
}));
|
|
9550
|
-
// on iOS, the front facing camera always is at the first position in the list, so we skip it if all else fails.
|
|
9551
|
-
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) {
|
|
9552
|
-
selectedCamera || (selectedCamera = availableCameras[1]);
|
|
9553
|
-
}
|
|
9554
|
-
selectedCamera || (selectedCamera = availableCameras[0]);
|
|
9555
|
-
debug('selectedCamera', selectedCamera);
|
|
9556
|
-
set({
|
|
9557
|
-
videoDevice: selectedCamera
|
|
9558
|
-
});
|
|
9559
|
-
constraints = {
|
|
9560
|
-
audio: false,
|
|
9561
|
-
video: {
|
|
9562
|
-
deviceId: {
|
|
9563
|
-
exact: selectedCamera.deviceId
|
|
9564
|
-
},
|
|
9565
|
-
width: {
|
|
9566
|
-
ideal: config.maxVideoWidth
|
|
9567
|
-
},
|
|
9568
|
-
aspectRatio: 1.777777778,
|
|
9569
|
-
frameRate: {}
|
|
9570
|
-
}
|
|
9571
|
-
};
|
|
9572
|
-
if (config.maxFps) {
|
|
9573
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
9574
|
-
// @ts-ignore
|
|
9575
|
-
constraints.video.frameRate = {
|
|
9576
|
-
max: config.maxFps
|
|
9577
|
-
};
|
|
9578
|
-
}
|
|
9579
|
-
stream_1 = null;
|
|
9580
|
-
_e.label = 3;
|
|
9581
|
-
case 3:
|
|
9582
|
-
_e.trys.push([3, 5,, 6]);
|
|
9583
|
-
debug('obtaining camera access with constraints', constraints);
|
|
9584
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia(constraints)];
|
|
9585
|
-
case 4:
|
|
9586
|
-
stream_1 = _e.sent();
|
|
9587
|
-
return [3 /*break*/, 6];
|
|
9588
|
-
case 5:
|
|
9589
|
-
e_1 = _e.sent();
|
|
9590
|
-
if (e_1.name === 'NotAllowedError') {
|
|
9591
|
-
if (preferIphoneContinuityCamera) {
|
|
9592
|
-
set({
|
|
9593
|
-
iphoneContinuityCameraAvailable: false,
|
|
9594
|
-
iphoneContinuityCameraDenied: true
|
|
9595
|
-
});
|
|
9596
|
-
} else {
|
|
9597
|
-
set({
|
|
9598
|
-
cameraAccessDenied: true
|
|
9599
|
-
});
|
|
9600
|
-
}
|
|
9601
|
-
return [2 /*return*/];
|
|
9602
|
-
}
|
|
9603
|
-
return [3 /*break*/, 6];
|
|
9604
|
-
case 6:
|
|
9605
|
-
if (!!stream_1) return [3 /*break*/, 10];
|
|
9606
|
-
_e.label = 7;
|
|
9607
|
-
case 7:
|
|
9608
|
-
_e.trys.push([7, 9,, 10]);
|
|
9609
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
9610
|
-
audio: false,
|
|
9611
|
-
video: true
|
|
9612
|
-
})];
|
|
9613
|
-
case 8:
|
|
9614
|
-
stream_1 = _e.sent();
|
|
9615
|
-
debug('opened stream with no width and height constraints');
|
|
9616
|
-
return [3 /*break*/, 10];
|
|
9617
|
-
case 9:
|
|
9618
|
-
_e.sent();
|
|
9619
|
-
debug('cannot open stream at all');
|
|
9620
|
-
return [3 /*break*/, 10];
|
|
9621
|
-
case 10:
|
|
9622
|
-
if (!stream_1) {
|
|
9623
|
-
error('failed to open camera');
|
|
9624
|
-
throw new Error('failed to open camera');
|
|
9625
|
-
}
|
|
9626
|
-
debug('camera access granted with constraints', constraints);
|
|
9627
|
-
iphoneContinuityCameraAvailable_1 = get().iphoneContinuityCameraAvailable;
|
|
9628
|
-
handleStreamEnded_1 = function handleStreamEnded_1() {
|
|
9629
|
-
if (iphoneContinuityCameraAvailable_1 && preferIphoneContinuityCamera) {
|
|
9630
|
-
debug('someone unplugged the continuity camera');
|
|
9631
|
-
set({
|
|
9632
|
-
videoStream: null,
|
|
9633
|
-
videoDevice: null,
|
|
9634
|
-
cameraReady: false,
|
|
9635
|
-
iphoneContinuityCameraAvailable: false,
|
|
9636
|
-
iphoneContinuityCameraDenied: true
|
|
9637
|
-
});
|
|
9638
|
-
get().requestCameraAccess();
|
|
9639
|
-
} else {
|
|
9640
|
-
debug('someone unplugged the webcam');
|
|
9641
|
-
releaseCameraAccess();
|
|
9642
|
-
set({
|
|
9643
|
-
videoStream: null,
|
|
9644
|
-
videoDevice: null,
|
|
9645
|
-
videoLoaded: false,
|
|
9646
|
-
cameraReady: false,
|
|
9647
|
-
cameraAccessDenied: true
|
|
9648
|
-
});
|
|
9649
|
-
}
|
|
9650
|
-
};
|
|
9651
|
-
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', handleStreamEnded_1);
|
|
9652
|
-
videoTrack_1 = stream_1.getVideoTracks()[0];
|
|
9653
|
-
videoTrack_1.onended = handleStreamEnded_1;
|
|
9654
|
-
camera_1 = obtainCameraAccess(stream_1, selectedCamera.label, videoRef.current);
|
|
9655
|
-
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
9656
|
-
// when the camera access is being requested. This delay is a workaround for that.
|
|
9657
|
-
setTimeout(function () {
|
|
9658
|
-
videoTrack_1.onmute = handleStreamEnded_1;
|
|
9659
|
-
set({
|
|
9660
|
-
camera: camera_1,
|
|
9661
|
-
cameraReady: true,
|
|
9662
|
-
cameraAccessDenied: false,
|
|
9663
|
-
isRearFacing: camera_1.isRearFacing,
|
|
9664
|
-
videoStream: stream_1
|
|
9665
|
-
});
|
|
9666
|
-
}, 500);
|
|
9667
|
-
return [3 /*break*/, 12];
|
|
9668
|
-
case 11:
|
|
9669
|
-
e_3 = _e.sent();
|
|
9670
|
-
if (e_3.name === 'NotAllowedError') {
|
|
9671
|
-
error('camera access has been blocked by the user', e_3);
|
|
9672
|
-
set({
|
|
9673
|
-
cameraAccessDenied: true
|
|
9674
|
-
});
|
|
9675
|
-
} else {
|
|
9676
|
-
error('camera access encountered some other error', e_3);
|
|
9677
|
-
throw e_3;
|
|
9678
|
-
}
|
|
9679
|
-
return [3 /*break*/, 12];
|
|
9680
|
-
case 12:
|
|
9681
|
-
return [2 /*return*/];
|
|
9682
|
-
}
|
|
9683
|
-
});
|
|
9684
|
-
});
|
|
9685
|
-
},
|
|
9686
|
-
releaseCameraAccess: function releaseCameraAccess() {
|
|
9687
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
9688
|
-
var camera;
|
|
9689
|
-
return __generator(this, function (_a) {
|
|
9690
|
-
camera = get().camera;
|
|
9691
|
-
if (!camera) return [2 /*return*/];
|
|
9692
|
-
camera.release();
|
|
9693
|
-
set({
|
|
9694
|
-
camera: null,
|
|
9695
|
-
cameraReady: false,
|
|
9696
|
-
cameraAccessDenied: false
|
|
9697
|
-
});
|
|
9698
|
-
return [2 /*return*/];
|
|
9699
|
-
});
|
|
9700
|
-
});
|
|
9701
|
-
},
|
|
9702
|
-
requestMicrophoneAccess: function requestMicrophoneAccess() {
|
|
9703
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
9704
|
-
var stream_2;
|
|
9705
|
-
return __generator(this, function (_a) {
|
|
9706
|
-
switch (_a.label) {
|
|
9707
|
-
case 0:
|
|
9708
|
-
get().releaseMicrophoneAccess();
|
|
9709
|
-
_a.label = 1;
|
|
9710
|
-
case 1:
|
|
9711
|
-
_a.trys.push([1, 3,, 4]);
|
|
9712
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
9713
|
-
audio: true,
|
|
9714
|
-
video: false
|
|
9715
|
-
})
|
|
9716
|
-
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
9717
|
-
// when the camera access is being requested. This delay is a workaround for that.
|
|
9718
|
-
];
|
|
9719
|
-
case 2:
|
|
9720
|
-
stream_2 = _a.sent();
|
|
9721
|
-
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
9722
|
-
// when the camera access is being requested. This delay is a workaround for that.
|
|
9723
|
-
setTimeout(function () {
|
|
9724
|
-
set({
|
|
9725
|
-
audioStream: stream_2,
|
|
9726
|
-
microphoneReady: true,
|
|
9727
|
-
microphoneAccessDenied: false
|
|
9728
|
-
});
|
|
9729
|
-
stream_2.getAudioTracks().forEach(function (track) {
|
|
9730
|
-
track.onended = function () {
|
|
9731
|
-
return set({
|
|
9732
|
-
microphoneReady: false,
|
|
9733
|
-
microphoneAccessDenied: true
|
|
9734
|
-
});
|
|
9735
|
-
};
|
|
9736
|
-
track.onmute = function () {
|
|
9737
|
-
return set({
|
|
9738
|
-
microphoneReady: false,
|
|
9739
|
-
microphoneAccessDenied: true
|
|
9740
|
-
});
|
|
9741
|
-
};
|
|
9742
|
-
});
|
|
9743
|
-
}, 500);
|
|
9744
|
-
return [3 /*break*/, 4];
|
|
9745
|
-
case 3:
|
|
9746
|
-
_a.sent();
|
|
9747
|
-
set({
|
|
9748
|
-
microphoneAccessDenied: true
|
|
9749
|
-
});
|
|
9750
|
-
return [3 /*break*/, 4];
|
|
9751
|
-
case 4:
|
|
9752
|
-
return [2 /*return*/];
|
|
9753
|
-
}
|
|
9754
|
-
});
|
|
9755
|
-
});
|
|
9756
|
-
},
|
|
9757
|
-
releaseMicrophoneAccess: function releaseMicrophoneAccess() {
|
|
9758
|
-
var _a;
|
|
9759
|
-
var audioStream = get().audioStream;
|
|
9760
|
-
(_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
|
|
9761
|
-
audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks().forEach(function (track) {
|
|
9762
|
-
var _a;
|
|
9763
|
-
(_a = track.stop) === null || _a === void 0 ? void 0 : _a.call(track);
|
|
9764
|
-
});
|
|
9765
|
-
set({
|
|
9766
|
-
audioStream: null,
|
|
9767
|
-
microphoneReady: false,
|
|
9768
|
-
microphoneAccessDenied: false
|
|
9817
|
+
var timer;
|
|
9818
|
+
var currentLoopId = loopId.current;
|
|
9819
|
+
function renderPrediction() {
|
|
9820
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
9821
|
+
var start, timeRunning, took, amountToThrottle;
|
|
9822
|
+
var _a, _b;
|
|
9823
|
+
return __generator(this, function (_c) {
|
|
9824
|
+
switch (_c.label) {
|
|
9825
|
+
case 0:
|
|
9826
|
+
if (currentLoopId !== loopId.current) return [2 /*return*/];
|
|
9827
|
+
start = new Date().getTime();
|
|
9828
|
+
timeRunning = start - ((_b = (_a = startedAtRef.current) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0);
|
|
9829
|
+
return [4 /*yield*/, fn(frameId.current, timeRunning)];
|
|
9830
|
+
case 1:
|
|
9831
|
+
_c.sent();
|
|
9832
|
+
took = new Date().getTime() - start;
|
|
9833
|
+
amountToThrottle = Math.max((throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0) - took, 0);
|
|
9834
|
+
timer = setTimeout(function () {
|
|
9835
|
+
frameId.current = requestAnimationFrame(renderPrediction);
|
|
9836
|
+
}, amountToThrottle);
|
|
9837
|
+
return [2 /*return*/];
|
|
9838
|
+
}
|
|
9769
9839
|
});
|
|
9770
|
-
}
|
|
9771
|
-
});
|
|
9772
|
-
});
|
|
9773
|
-
if (config.requestAccessAutomatically) {
|
|
9774
|
-
void store.getState().requestCameraAccess();
|
|
9775
|
-
}
|
|
9776
|
-
if (config.requireMicrophoneAccess) {
|
|
9777
|
-
void store.getState().requestMicrophoneAccess();
|
|
9778
|
-
}
|
|
9779
|
-
return _assign(_assign({}, store), {
|
|
9780
|
-
destroy: function destroy() {
|
|
9781
|
-
store.getState().releaseCameraAccess();
|
|
9782
|
-
store.getState().releaseMicrophoneAccess();
|
|
9783
|
-
}
|
|
9784
|
-
});
|
|
9785
|
-
};
|
|
9786
|
-
var CameraStoreContext = /*#__PURE__*/React.createContext(undefined);
|
|
9787
|
-
function CameraStoreProvider(_a) {
|
|
9788
|
-
var children = _a.children,
|
|
9789
|
-
_b = _a.requestAccessAutomatically,
|
|
9790
|
-
requestAccessAutomatically = _b === void 0 ? true : _b,
|
|
9791
|
-
_c = _a.preferIphoneContinuityCamera,
|
|
9792
|
-
preferIphoneContinuityCamera = _c === void 0 ? true : _c,
|
|
9793
|
-
_d = _a.preferFrontFacingCamera,
|
|
9794
|
-
preferFrontFacingCamera = _d === void 0 ? false : _d,
|
|
9795
|
-
_e = _a.maxVideoWidth,
|
|
9796
|
-
maxVideoWidth = _e === void 0 ? 1920 : _e,
|
|
9797
|
-
maxFps = _a.maxFps,
|
|
9798
|
-
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
9799
|
-
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
|
|
9800
|
-
_f = _a.requireMicrophoneAccess,
|
|
9801
|
-
requireMicrophoneAccess = _f === void 0 ? false : _f;
|
|
9802
|
-
var videoRef = React.useRef(null);
|
|
9803
|
-
var store = React.useRef();
|
|
9804
|
-
store.current || (store.current = createCameraStore({
|
|
9805
|
-
videoRef: videoRef,
|
|
9806
|
-
requestAccessAutomatically: requestAccessAutomatically,
|
|
9807
|
-
preferIphoneContinuityCamera: preferIphoneContinuityCamera,
|
|
9808
|
-
preferFrontFacingCamera: preferFrontFacingCamera,
|
|
9809
|
-
maxVideoWidth: maxVideoWidth,
|
|
9810
|
-
maxFps: maxFps,
|
|
9811
|
-
onCameraAccessDenied: onCameraAccessDenied,
|
|
9812
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
9813
|
-
requireMicrophoneAccess: requireMicrophoneAccess
|
|
9814
|
-
}));
|
|
9815
|
-
React.useEffect(function () {
|
|
9816
|
-
var _a, _b, _c;
|
|
9817
|
-
var state = (_a = store.current) === null || _a === void 0 ? void 0 : _a.getState();
|
|
9818
|
-
if (!state) return;
|
|
9819
|
-
if (preferIphoneContinuityCamera !== (state === null || state === void 0 ? void 0 : state.preferIphoneContinuityCamera) || preferFrontFacingCamera !== (state === null || state === void 0 ? void 0 : state.preferFrontFacingCamera)) {
|
|
9820
|
-
(_b = store.current) === null || _b === void 0 ? void 0 : _b.setState({
|
|
9821
|
-
preferIphoneContinuityCamera: preferIphoneContinuityCamera,
|
|
9822
|
-
preferFrontFacingCamera: preferFrontFacingCamera
|
|
9823
9840
|
});
|
|
9824
|
-
(_c = store.current) === null || _c === void 0 ? void 0 : _c.getState().requestCameraAccess();
|
|
9825
9841
|
}
|
|
9826
|
-
|
|
9827
|
-
React.useEffect(function () {
|
|
9842
|
+
renderPrediction().then();
|
|
9828
9843
|
return function () {
|
|
9829
|
-
|
|
9830
|
-
|
|
9844
|
+
loopId.current += 1;
|
|
9845
|
+
frameId.current && cancelAnimationFrame(frameId.current);
|
|
9846
|
+
timer && clearTimeout(timer);
|
|
9831
9847
|
};
|
|
9848
|
+
}, [fn, running, throttleMs]);
|
|
9849
|
+
var start = React.useCallback(function () {
|
|
9850
|
+
startedAtRef.current = new Date();
|
|
9851
|
+
setRunning(true);
|
|
9832
9852
|
}, []);
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9853
|
+
var stop = React.useCallback(function () {
|
|
9854
|
+
loopId.current += 1; // force the loop to stop immediately.
|
|
9855
|
+
setRunning(false);
|
|
9856
|
+
startedAtRef.current = null;
|
|
9857
|
+
}, []);
|
|
9858
|
+
React.useEffect(function startAutomatically() {
|
|
9859
|
+
if (autoStart) start();
|
|
9860
|
+
return function () {
|
|
9861
|
+
stop();
|
|
9862
|
+
};
|
|
9863
|
+
}, [autoStart, start, stop]);
|
|
9864
|
+
return {
|
|
9865
|
+
start: start,
|
|
9866
|
+
stop: stop
|
|
9867
|
+
};
|
|
9841
9868
|
}
|
|
9842
9869
|
|
|
9843
9870
|
var DocumentDetectionModelContext = /*#__PURE__*/React.createContext({
|
|
@@ -9885,7 +9912,7 @@
|
|
|
9885
9912
|
_g = _a.documentDetectionModelLoadTimeoutMs,
|
|
9886
9913
|
documentDetectionModelLoadTimeoutMs = _g === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _g,
|
|
9887
9914
|
onDocumentDetectionModelError = _a.onDocumentDetectionModelError;
|
|
9888
|
-
var _h =
|
|
9915
|
+
var _h = React.useContext(CameraStateContext),
|
|
9889
9916
|
videoRef = _h.videoRef,
|
|
9890
9917
|
videoLoaded = _h.videoLoaded,
|
|
9891
9918
|
cameraReady = _h.cameraReady;
|
|
@@ -9908,8 +9935,7 @@
|
|
|
9908
9935
|
modelPath: documentDetectionModelPath,
|
|
9909
9936
|
modelLoadTimeoutMs: documentDetectionModelLoadTimeoutMs,
|
|
9910
9937
|
scoreThreshold: documentDetectionModelScoreThreshold,
|
|
9911
|
-
onModelError: onDocumentDetectionModelError
|
|
9912
|
-
videoRef: videoRef
|
|
9938
|
+
onModelError: onDocumentDetectionModelError
|
|
9913
9939
|
}),
|
|
9914
9940
|
ready = _o.ready,
|
|
9915
9941
|
modelDownloadProgress = _o.modelDownloadProgress,
|
|
@@ -10026,12 +10052,10 @@
|
|
|
10026
10052
|
var _e = React.useState({}),
|
|
10027
10053
|
focusThresholds = _e[0],
|
|
10028
10054
|
setFocusThresholds = _e[1];
|
|
10029
|
-
var videoRef = useCameraStore().videoRef;
|
|
10030
10055
|
var _f = useLoadFocusModel({
|
|
10031
10056
|
modelPath: focusModelPath,
|
|
10032
10057
|
modelLoadTimeoutMs: focusModelLoadTimeoutMs,
|
|
10033
|
-
onModelError: onFocusModelError
|
|
10034
|
-
videoRef: videoRef
|
|
10058
|
+
onModelError: onFocusModelError
|
|
10035
10059
|
}),
|
|
10036
10060
|
ready = _f.ready,
|
|
10037
10061
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
@@ -11471,9 +11495,9 @@
|
|
|
11471
11495
|
return e;
|
|
11472
11496
|
}
|
|
11473
11497
|
|
|
11474
|
-
function _createForOfIteratorHelperLoose
|
|
11475
|
-
function _unsupportedIterableToArray
|
|
11476
|
-
function _arrayLikeToArray
|
|
11498
|
+
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11499
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11500
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11477
11501
|
var consoleLogger = {
|
|
11478
11502
|
type: 'logger',
|
|
11479
11503
|
log: function log(args) {
|
|
@@ -12320,7 +12344,7 @@
|
|
|
12320
12344
|
}
|
|
12321
12345
|
if (!useOptionsReplaceForData) {
|
|
12322
12346
|
data = _extends({}, data);
|
|
12323
|
-
for (var _iterator = _createForOfIteratorHelperLoose
|
|
12347
|
+
for (var _iterator = _createForOfIteratorHelperLoose(optionsKeys), _step; !(_step = _iterator()).done;) {
|
|
12324
12348
|
var key = _step.value;
|
|
12325
12349
|
delete data[key];
|
|
12326
12350
|
}
|
|
@@ -14026,33 +14050,31 @@
|
|
|
14026
14050
|
var templateObject_1$D, templateObject_2$w, templateObject_3$o, templateObject_4$i, templateObject_5$b;
|
|
14027
14051
|
|
|
14028
14052
|
var IdCapture = function IdCapture(_a) {
|
|
14029
|
-
var _b, _c, _d, _e, _f, _g, _h;
|
|
14053
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
14030
14054
|
var requiredDocumentType = _a.requiredDocumentType,
|
|
14031
|
-
|
|
14032
|
-
thresholds =
|
|
14055
|
+
_k = _a.thresholds,
|
|
14056
|
+
thresholds = _k === void 0 ? defaultIdCaptureThresholds : _k,
|
|
14033
14057
|
guidanceMessage = _a.guidanceMessage,
|
|
14034
14058
|
guidanceSatisfied = _a.guidanceSatisfied,
|
|
14035
14059
|
onCapture = _a.onCapture,
|
|
14036
|
-
|
|
14037
|
-
classNames =
|
|
14038
|
-
|
|
14039
|
-
colors =
|
|
14040
|
-
|
|
14041
|
-
rawVerbiage =
|
|
14042
|
-
|
|
14043
|
-
debugMode =
|
|
14044
|
-
var
|
|
14045
|
-
ref =
|
|
14046
|
-
|
|
14047
|
-
width =
|
|
14048
|
-
|
|
14049
|
-
height =
|
|
14050
|
-
var
|
|
14051
|
-
state =
|
|
14052
|
-
dispatch =
|
|
14053
|
-
var
|
|
14054
|
-
camera = _t.camera,
|
|
14055
|
-
isRearFacing = _t.isRearFacing;
|
|
14060
|
+
_l = _a.classNames,
|
|
14061
|
+
classNames = _l === void 0 ? {} : _l,
|
|
14062
|
+
_m = _a.colors,
|
|
14063
|
+
colors = _m === void 0 ? {} : _m,
|
|
14064
|
+
_o = _a.verbiage,
|
|
14065
|
+
rawVerbiage = _o === void 0 ? {} : _o,
|
|
14066
|
+
_p = _a.debugMode,
|
|
14067
|
+
debugMode = _p === void 0 ? false : _p;
|
|
14068
|
+
var _q = useResizeObserver(),
|
|
14069
|
+
ref = _q.ref,
|
|
14070
|
+
_r = _q.width,
|
|
14071
|
+
width = _r === void 0 ? 1 : _r,
|
|
14072
|
+
_s = _q.height,
|
|
14073
|
+
height = _s === void 0 ? 1 : _s;
|
|
14074
|
+
var _t = useIdCaptureState(),
|
|
14075
|
+
state = _t[0],
|
|
14076
|
+
dispatch = _t[1];
|
|
14077
|
+
var cameraRef = React.useContext(CameraStateContext).cameraRef;
|
|
14056
14078
|
var _u = React.useContext(IdCaptureModelsContext),
|
|
14057
14079
|
modelsReady = _u.ready,
|
|
14058
14080
|
setThresholds = _u.setThresholds,
|
|
@@ -14164,16 +14186,17 @@
|
|
|
14164
14186
|
classNames: classNames.overrideWrongDocumentTypeGuidanceDialog,
|
|
14165
14187
|
verbiage: rawVerbiage.overrideWrongDocumentTypeGuidanceDialog
|
|
14166
14188
|
}))), debugMode && ( /*#__PURE__*/React.createElement(DebugBoundingBoxOverlay, {
|
|
14167
|
-
"$flipX": !isRearFacing,
|
|
14189
|
+
"$flipX": !((_j = cameraRef.current) === null || _j === void 0 ? void 0 : _j.isRearFacing),
|
|
14168
14190
|
scaling: debugScalingDetails
|
|
14169
14191
|
}, state.detectedObjects.map(function (obj, i) {
|
|
14192
|
+
var _a;
|
|
14170
14193
|
return /*#__PURE__*/React.createElement(IdCaptureDetectedObjectDebugBox, {
|
|
14171
14194
|
key: i,
|
|
14172
14195
|
obj: obj,
|
|
14173
14196
|
scaling: debugScalingDetails,
|
|
14174
|
-
flipX: !isRearFacing
|
|
14197
|
+
flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing)
|
|
14175
14198
|
});
|
|
14176
|
-
}))), debugMode && ( /*#__PURE__*/React.createElement(DebugStatsPane, null,
|
|
14199
|
+
}))), debugMode && ( /*#__PURE__*/React.createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React.createElement(React.Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React.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.createElement("br", null), modelsReady ? ( /*#__PURE__*/React.createElement(React.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React.createElement(React.Fragment, null, "\u274C Models not ready")))));
|
|
14177
14200
|
};
|
|
14178
14201
|
var timeSince = function timeSince(t) {
|
|
14179
14202
|
if (!t) return 0;
|
|
@@ -14190,9 +14213,7 @@
|
|
|
14190
14213
|
colors = _e === void 0 ? {} : _e,
|
|
14191
14214
|
_f = _a.verbiage,
|
|
14192
14215
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
14193
|
-
var requestCameraAccess =
|
|
14194
|
-
return state.requestCameraAccess;
|
|
14195
|
-
});
|
|
14216
|
+
var requestCameraAccess = React.useContext(CameraStateContext).requestCameraAccess;
|
|
14196
14217
|
assets.imageUrl || (assets.imageUrl = DEFAULT_CDN_URL + '/camera-disable-icon.png');
|
|
14197
14218
|
var verbiage = useTranslations(rawVerbiage, {
|
|
14198
14219
|
headingText: 'Your camera permission is disabled',
|
|
@@ -14840,7 +14861,7 @@
|
|
|
14840
14861
|
var _o = React.useContext(IdCaptureModelsContext),
|
|
14841
14862
|
modelsReady = _o.ready,
|
|
14842
14863
|
modelDownloadProgress = _o.modelDownloadProgress;
|
|
14843
|
-
var _p =
|
|
14864
|
+
var _p = React.useContext(CameraStateContext),
|
|
14844
14865
|
cameraReady = _p.cameraReady,
|
|
14845
14866
|
cameraAccessDenied = _p.cameraAccessDenied,
|
|
14846
14867
|
iphoneContinuityCameraAvailable = _p.iphoneContinuityCameraAvailable,
|
|
@@ -15018,71 +15039,6 @@
|
|
|
15018
15039
|
});
|
|
15019
15040
|
var templateObject_1$y, templateObject_2$t, templateObject_3$l, templateObject_4$f, templateObject_5$a, templateObject_6$8, templateObject_7$5, templateObject_8$2, templateObject_9$2, templateObject_10$1, templateObject_11$1, templateObject_12$1, templateObject_13$1, templateObject_14$1, templateObject_15$1, templateObject_16, templateObject_17, templateObject_18;
|
|
15020
15041
|
|
|
15021
|
-
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15022
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
15023
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15024
|
-
var isIterable = function isIterable(obj) {
|
|
15025
|
-
return Symbol.iterator in obj;
|
|
15026
|
-
};
|
|
15027
|
-
var compareMapLike = function compareMapLike(iterableA, iterableB) {
|
|
15028
|
-
var mapA = iterableA instanceof Map ? iterableA : new Map(iterableA);
|
|
15029
|
-
var mapB = iterableB instanceof Map ? iterableB : new Map(iterableB);
|
|
15030
|
-
if (mapA.size !== mapB.size) return false;
|
|
15031
|
-
for (var _iterator = _createForOfIteratorHelperLoose(mapA), _step; !(_step = _iterator()).done;) {
|
|
15032
|
-
var _step$value = _step.value,
|
|
15033
|
-
key = _step$value[0],
|
|
15034
|
-
value = _step$value[1];
|
|
15035
|
-
if (!Object.is(value, mapB.get(key))) {
|
|
15036
|
-
return false;
|
|
15037
|
-
}
|
|
15038
|
-
}
|
|
15039
|
-
return true;
|
|
15040
|
-
};
|
|
15041
|
-
function shallow(objA, objB) {
|
|
15042
|
-
if (Object.is(objA, objB)) {
|
|
15043
|
-
return true;
|
|
15044
|
-
}
|
|
15045
|
-
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
15046
|
-
return false;
|
|
15047
|
-
}
|
|
15048
|
-
if (isIterable(objA) && isIterable(objB)) {
|
|
15049
|
-
var iteratorA = objA[Symbol.iterator]();
|
|
15050
|
-
var iteratorB = objB[Symbol.iterator]();
|
|
15051
|
-
var nextA = iteratorA.next();
|
|
15052
|
-
var nextB = iteratorB.next();
|
|
15053
|
-
if (Array.isArray(nextA.value) && Array.isArray(nextB.value) && nextA.value.length === 2 && nextB.value.length === 2) {
|
|
15054
|
-
return compareMapLike(objA, objB);
|
|
15055
|
-
}
|
|
15056
|
-
while (!nextA.done && !nextB.done) {
|
|
15057
|
-
if (!Object.is(nextA.value, nextB.value)) {
|
|
15058
|
-
return false;
|
|
15059
|
-
}
|
|
15060
|
-
nextA = iteratorA.next();
|
|
15061
|
-
nextB = iteratorB.next();
|
|
15062
|
-
}
|
|
15063
|
-
return !!nextA.done && !!nextB.done;
|
|
15064
|
-
}
|
|
15065
|
-
var keysA = Object.keys(objA);
|
|
15066
|
-
if (keysA.length !== Object.keys(objB).length) {
|
|
15067
|
-
return false;
|
|
15068
|
-
}
|
|
15069
|
-
for (var _i = 0, _keysA = keysA; _i < _keysA.length; _i++) {
|
|
15070
|
-
var keyA = _keysA[_i];
|
|
15071
|
-
if (!Object.hasOwn(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {
|
|
15072
|
-
return false;
|
|
15073
|
-
}
|
|
15074
|
-
}
|
|
15075
|
-
return true;
|
|
15076
|
-
}
|
|
15077
|
-
|
|
15078
|
-
function useShallow(selector) {
|
|
15079
|
-
var prev = React.useRef();
|
|
15080
|
-
return function (state) {
|
|
15081
|
-
var next = selector(state);
|
|
15082
|
-
return shallow(prev.current, next) ? prev.current : prev.current = next;
|
|
15083
|
-
};
|
|
15084
|
-
}
|
|
15085
|
-
|
|
15086
15042
|
var ContinuityCameraCheckboxContainer = styled.div(templateObject_1$x || (templateObject_1$x = __makeTemplateObject(["\n margin-top: 15px;\n margin-bottom: 15px;\n"], ["\n margin-top: 15px;\n margin-bottom: 15px;\n"])));
|
|
15087
15043
|
var ContinuityCameraCheckbox = styled.input(templateObject_2$s || (templateObject_2$s = __makeTemplateObject(["\n margin-right: 8px;\n"], ["\n margin-right: 8px;\n"])));
|
|
15088
15044
|
var IdCaptureLoadingOverlayLegacy = function IdCaptureLoadingOverlayLegacy(_a) {
|
|
@@ -15103,14 +15059,7 @@
|
|
|
15103
15059
|
var _l = React.useContext(IdCaptureModelsContext),
|
|
15104
15060
|
modelsReady = _l.ready,
|
|
15105
15061
|
modelDownloadProgress = _l.modelDownloadProgress;
|
|
15106
|
-
var _m =
|
|
15107
|
-
return {
|
|
15108
|
-
cameraReady: state.cameraReady,
|
|
15109
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
15110
|
-
iphoneContinuityCameraAvailable: state.iphoneContinuityCameraAvailable,
|
|
15111
|
-
setIphoneContinuityCameraAllowed: state.setIphoneContinuityCameraAllowed
|
|
15112
|
-
};
|
|
15113
|
-
})),
|
|
15062
|
+
var _m = React.useContext(CameraStateContext),
|
|
15114
15063
|
cameraReady = _m.cameraReady,
|
|
15115
15064
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
15116
15065
|
iphoneContinuityCameraAvailable = _m.iphoneContinuityCameraAvailable,
|
|
@@ -15656,24 +15605,23 @@
|
|
|
15656
15605
|
}
|
|
15657
15606
|
|
|
15658
15607
|
var IdVideoCaptureFlipIdPrompt = function IdVideoCaptureFlipIdPrompt(_a) {
|
|
15659
|
-
var _b
|
|
15660
|
-
|
|
15661
|
-
|
|
15662
|
-
|
|
15608
|
+
var _b;
|
|
15609
|
+
var _c = _a.idCaptureGuideImages,
|
|
15610
|
+
idCaptureGuideImages = _c === void 0 ? defaultIdCaptureGuideImages : _c,
|
|
15611
|
+
_d = _a.classNames,
|
|
15612
|
+
classNames = _d === void 0 ? {} : _d,
|
|
15663
15613
|
borderWidth = _a.borderWidth,
|
|
15664
15614
|
borderColor = _a.borderColor,
|
|
15665
15615
|
borderRadius = _a.borderRadius,
|
|
15666
15616
|
imageStyle = _a.imageStyle;
|
|
15667
|
-
var
|
|
15668
|
-
|
|
15669
|
-
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
rotationAngle = _e[0],
|
|
15676
|
-
setRotationAngle = _e[1];
|
|
15617
|
+
var cameraRef = React.useContext(CameraStateContext).cameraRef;
|
|
15618
|
+
var isMirrored = !((_b = cameraRef.current) === null || _b === void 0 ? void 0 : _b.isRearFacing);
|
|
15619
|
+
var _e = React.useState(1),
|
|
15620
|
+
transitionTime = _e[0],
|
|
15621
|
+
setTransitionTime = _e[1];
|
|
15622
|
+
var _f = React.useState(0),
|
|
15623
|
+
rotationAngle = _f[0],
|
|
15624
|
+
setRotationAngle = _f[1];
|
|
15677
15625
|
var frontTransforms = ["rotateY(".concat(rotationAngle, "deg)")];
|
|
15678
15626
|
if (isMirrored) frontTransforms.push('scaleX(-1)');
|
|
15679
15627
|
var backTransforms = ["rotateY(".concat(180 - rotationAngle, "deg)")];
|
|
@@ -16197,30 +16145,29 @@
|
|
|
16197
16145
|
var templateObject_1$r, templateObject_2$n;
|
|
16198
16146
|
|
|
16199
16147
|
function IdCaptureGuides(_a) {
|
|
16200
|
-
var _b
|
|
16201
|
-
|
|
16202
|
-
|
|
16203
|
-
|
|
16204
|
-
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
16212
|
-
|
|
16213
|
-
|
|
16214
|
-
|
|
16215
|
-
|
|
16216
|
-
|
|
16217
|
-
|
|
16218
|
-
|
|
16219
|
-
|
|
16148
|
+
var _b, _c;
|
|
16149
|
+
var _d = _a.guideType,
|
|
16150
|
+
guideType = _d === void 0 ? 'fit' : _d,
|
|
16151
|
+
_e = _a.status,
|
|
16152
|
+
status = _e === void 0 ? 'ready' : _e,
|
|
16153
|
+
_f = _a.progress,
|
|
16154
|
+
progress = _f === void 0 ? 0 : _f,
|
|
16155
|
+
_g = _a.portraitGuidesOnMobile,
|
|
16156
|
+
portraitGuidesOnMobile = _g === void 0 ? true : _g,
|
|
16157
|
+
_h = _a.requestedAction,
|
|
16158
|
+
requestedAction = _h === void 0 ? 'SHOW_ID_FRONT' : _h,
|
|
16159
|
+
_j = _a.isBackToFront,
|
|
16160
|
+
isBackToFront = _j === void 0 ? false : _j,
|
|
16161
|
+
_k = _a.images,
|
|
16162
|
+
images = _k === void 0 ? defaultIdCaptureGuideImages : _k,
|
|
16163
|
+
_l = _a.classNames,
|
|
16164
|
+
classNames = _l === void 0 ? {} : _l,
|
|
16165
|
+
_m = _a.colors,
|
|
16166
|
+
colors = _m === void 0 ? {} : _m,
|
|
16167
|
+
_o = _a.verbiage,
|
|
16168
|
+
rawVerbiage = _o === void 0 ? {} : _o;
|
|
16220
16169
|
var state = useIdCaptureState()[0];
|
|
16221
|
-
var
|
|
16222
|
-
return state.isRearFacing;
|
|
16223
|
-
});
|
|
16170
|
+
var cameraRef = React.useContext(CameraStateContext).cameraRef;
|
|
16224
16171
|
var verbiage = useTranslations(rawVerbiage, {
|
|
16225
16172
|
instructionText: 'Scan the front of ID',
|
|
16226
16173
|
capturingText: 'Capturing...',
|
|
@@ -16232,7 +16179,7 @@
|
|
|
16232
16179
|
status: status,
|
|
16233
16180
|
progress: progress,
|
|
16234
16181
|
instruction: state.captureFailed ? verbiage.captureFailedText : state.capturing ? verbiage === null || verbiage === void 0 ? void 0 : verbiage.capturingText : verbiage.instructionText,
|
|
16235
|
-
isMirrored: !isRearFacing,
|
|
16182
|
+
isMirrored: !((_b = cameraRef.current) === null || _b === void 0 ? void 0 : _b.isRearFacing),
|
|
16236
16183
|
borderColor: state.isGoodFrame ? colors.guideBoxSatisfiedColor : colors.guideBoxUnsatisfiedColor,
|
|
16237
16184
|
imageVisible: requestedAction === 'FLIP_ID' || !state.idCardFrontDetectionThresholdMet || !state.documentInBounds || state.documentTooClose
|
|
16238
16185
|
})), guideType === 'fit' && ( /*#__PURE__*/React.createElement(IdCaptureFitGuide, {
|
|
@@ -16242,7 +16189,7 @@
|
|
|
16242
16189
|
status: status,
|
|
16243
16190
|
progress: progress,
|
|
16244
16191
|
instruction: state.captureFailed ? verbiage.captureFailedText : state.capturing ? verbiage === null || verbiage === void 0 ? void 0 : verbiage.capturingText : verbiage.instructionText,
|
|
16245
|
-
isMirrored: !isRearFacing,
|
|
16192
|
+
isMirrored: !((_c = cameraRef.current) === null || _c === void 0 ? void 0 : _c.isRearFacing),
|
|
16246
16193
|
isBackToFront: isBackToFront,
|
|
16247
16194
|
portraitGuidesOnMobile: portraitGuidesOnMobile,
|
|
16248
16195
|
borderColor: state.isGoodFrame ? colors.guideBoxSatisfiedColor : colors.guideBoxUnsatisfiedColor,
|
|
@@ -16341,6 +16288,48 @@
|
|
|
16341
16288
|
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"])));
|
|
16342
16289
|
var templateObject_1$q, templateObject_2$m, templateObject_3$h, templateObject_4$b;
|
|
16343
16290
|
|
|
16291
|
+
var CameraVideoTag = function CameraVideoTag(_a) {
|
|
16292
|
+
var _b;
|
|
16293
|
+
var className = _a.className;
|
|
16294
|
+
var _c = React.useContext(CameraStateContext),
|
|
16295
|
+
videoRef = _c.videoRef,
|
|
16296
|
+
setVideoLoaded = _c.setVideoLoaded,
|
|
16297
|
+
onVideoUnmounted = _c.onVideoUnmounted,
|
|
16298
|
+
cameraRef = _c.cameraRef;
|
|
16299
|
+
React.useEffect(function notifyCameraProviderOfUnmount() {
|
|
16300
|
+
var videoElement = videoRef.current;
|
|
16301
|
+
if (!videoElement) return;
|
|
16302
|
+
return function () {
|
|
16303
|
+
onVideoUnmounted(videoElement);
|
|
16304
|
+
};
|
|
16305
|
+
}, [onVideoUnmounted, videoRef]);
|
|
16306
|
+
React.useEffect(function setVideoLoadedToFalseOnMount() {
|
|
16307
|
+
setVideoLoaded(false);
|
|
16308
|
+
}, [setVideoLoaded]);
|
|
16309
|
+
React.useEffect(function attachCameraStreamToVideoTagWhenReady() {
|
|
16310
|
+
var _a;
|
|
16311
|
+
if (videoRef.current && ((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.stream)) {
|
|
16312
|
+
videoRef.current.srcObject = cameraRef.current.stream;
|
|
16313
|
+
}
|
|
16314
|
+
}, [cameraRef, videoRef]);
|
|
16315
|
+
var onLoadedData = React.useCallback(function () {
|
|
16316
|
+
setVideoLoaded(true);
|
|
16317
|
+
}, [setVideoLoaded]);
|
|
16318
|
+
return /*#__PURE__*/React.createElement(FullscreenVideoTag, {
|
|
16319
|
+
className: className,
|
|
16320
|
+
autoPlay: true,
|
|
16321
|
+
playsInline: true,
|
|
16322
|
+
muted: true,
|
|
16323
|
+
ref: videoRef,
|
|
16324
|
+
onLoadedData: onLoadedData,
|
|
16325
|
+
"$isRearFacing": (_b = cameraRef.current) === null || _b === void 0 ? void 0 : _b.isRearFacing
|
|
16326
|
+
});
|
|
16327
|
+
};
|
|
16328
|
+
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) {
|
|
16329
|
+
return props.$isRearFacing ? '' : 'scaleX(-1)';
|
|
16330
|
+
});
|
|
16331
|
+
var templateObject_1$p;
|
|
16332
|
+
|
|
16344
16333
|
var documentCaptureInitialState = {
|
|
16345
16334
|
documents: [],
|
|
16346
16335
|
currentDocumentIndex: 0,
|
|
@@ -16459,8 +16448,8 @@
|
|
|
16459
16448
|
var _c = React.useReducer(documentCaptureStateReducer, documentCaptureInitialState),
|
|
16460
16449
|
state = _c[0],
|
|
16461
16450
|
dispatch = _c[1];
|
|
16462
|
-
var _d =
|
|
16463
|
-
|
|
16451
|
+
var _d = React.useContext(CameraStateContext),
|
|
16452
|
+
cameraRef = _d.cameraRef,
|
|
16464
16453
|
videoRef = _d.videoRef;
|
|
16465
16454
|
var uploadDocument = React.useContext(SubmissionContext).uploadDocument;
|
|
16466
16455
|
var uploadCapturedDocument = React.useCallback(function (content, filetype) {
|
|
@@ -16551,7 +16540,8 @@
|
|
|
16551
16540
|
}, [onResize]);
|
|
16552
16541
|
var videoTag = videoRef.current;
|
|
16553
16542
|
React.useEffect(function () {
|
|
16554
|
-
if (!state.capturing
|
|
16543
|
+
if (!state.capturing) return;
|
|
16544
|
+
if (!cameraRef.current) return;
|
|
16555
16545
|
function onComplete(content) {
|
|
16556
16546
|
if (!content) return;
|
|
16557
16547
|
var contentUrl = URL.createObjectURL(content);
|
|
@@ -16564,7 +16554,7 @@
|
|
|
16564
16554
|
});
|
|
16565
16555
|
}
|
|
16566
16556
|
if (typeof ImageCapture !== 'undefined') {
|
|
16567
|
-
var tracks =
|
|
16557
|
+
var tracks = cameraRef.current.stream.getTracks();
|
|
16568
16558
|
var videoCameraTrack = tracks.find(function (track) {
|
|
16569
16559
|
return track.kind === 'video';
|
|
16570
16560
|
});
|
|
@@ -16579,7 +16569,7 @@
|
|
|
16579
16569
|
drawToCanvas(canvas, videoTag);
|
|
16580
16570
|
canvas.toBlob(onComplete);
|
|
16581
16571
|
}
|
|
16582
|
-
}, [state.capturing,
|
|
16572
|
+
}, [cameraRef, state.capturing, videoTag]);
|
|
16583
16573
|
var stateWithActions = React.useMemo(function () {
|
|
16584
16574
|
return _assign(_assign({}, state), {
|
|
16585
16575
|
uploadCapturedDocument: uploadCapturedDocument
|
|
@@ -16694,85 +16684,52 @@
|
|
|
16694
16684
|
ref: canvasRef
|
|
16695
16685
|
}));
|
|
16696
16686
|
};
|
|
16697
|
-
var CanvasWrapper = styled.div(templateObject_1$
|
|
16687
|
+
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) {
|
|
16698
16688
|
return props.$maskColor;
|
|
16699
16689
|
});
|
|
16700
16690
|
var Canvas = styled.canvas(templateObject_2$l || (templateObject_2$l = __makeTemplateObject(["\n display: block;\n"], ["\n display: block;\n"])));
|
|
16701
|
-
var templateObject_1$
|
|
16691
|
+
var templateObject_1$o, templateObject_2$l;
|
|
16702
16692
|
|
|
16703
|
-
var CameraFeedWrapper = styled.div(templateObject_1$
|
|
16693
|
+
var CameraFeedWrapper = styled.div(templateObject_1$n || (templateObject_1$n = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (props) {
|
|
16704
16694
|
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;") : "";
|
|
16705
16695
|
});
|
|
16706
|
-
var templateObject_1$o;
|
|
16707
|
-
|
|
16708
|
-
var CameraVideoTag = function CameraVideoTag(props) {
|
|
16709
|
-
var _a = useCameraStore(useShallow(function (store) {
|
|
16710
|
-
return {
|
|
16711
|
-
videoRef: store.videoRef,
|
|
16712
|
-
videoStream: store.videoStream,
|
|
16713
|
-
onVideoMounted: store.onVideoMounted,
|
|
16714
|
-
isRearFacing: store.isRearFacing
|
|
16715
|
-
};
|
|
16716
|
-
})),
|
|
16717
|
-
videoRef = _a.videoRef,
|
|
16718
|
-
videoStream = _a.videoStream,
|
|
16719
|
-
onVideoMounted = _a.onVideoMounted,
|
|
16720
|
-
isRearFacing = _a.isRearFacing;
|
|
16721
|
-
React.useEffect(function attachCameraStreamToVideoTagWhenReady() {
|
|
16722
|
-
if (videoRef.current && videoStream) {
|
|
16723
|
-
debug('attaching camera stream to video tag');
|
|
16724
|
-
videoRef.current.srcObject = videoStream;
|
|
16725
|
-
}
|
|
16726
|
-
}, [videoStream, videoRef]);
|
|
16727
|
-
return /*#__PURE__*/React.createElement(FullscreenVideoTag, _assign({
|
|
16728
|
-
autoPlay: true,
|
|
16729
|
-
playsInline: true,
|
|
16730
|
-
muted: true,
|
|
16731
|
-
ref: videoRef,
|
|
16732
|
-
onLoadedData: onVideoMounted,
|
|
16733
|
-
"$isRearFacing": isRearFacing
|
|
16734
|
-
}, props));
|
|
16735
|
-
};
|
|
16736
|
-
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) {
|
|
16737
|
-
return props.$isRearFacing ? '' : 'scaleX(-1)';
|
|
16738
|
-
});
|
|
16739
16696
|
var templateObject_1$n;
|
|
16740
16697
|
|
|
16741
16698
|
var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
|
|
16742
|
-
var _b, _c, _d, _e, _f;
|
|
16699
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
16743
16700
|
var onCaptureClicked = _a.onCaptureClicked,
|
|
16744
|
-
|
|
16745
|
-
classNames =
|
|
16746
|
-
|
|
16747
|
-
rawVerbiage =
|
|
16748
|
-
var
|
|
16749
|
-
|
|
16750
|
-
documents =
|
|
16751
|
-
currentDocumentIndex =
|
|
16752
|
-
rectX =
|
|
16753
|
-
rectY =
|
|
16754
|
-
rectWidth =
|
|
16755
|
-
rectHeight =
|
|
16756
|
-
rectOffsetTop =
|
|
16757
|
-
capturing =
|
|
16758
|
-
uploadCapturedDocument =
|
|
16759
|
-
dispatch =
|
|
16760
|
-
var
|
|
16761
|
-
title =
|
|
16762
|
-
aspectRatio =
|
|
16763
|
-
cameraFeedMode =
|
|
16764
|
-
instructions =
|
|
16765
|
-
contentUrl =
|
|
16766
|
-
content =
|
|
16767
|
-
uploadState =
|
|
16768
|
-
var
|
|
16769
|
-
|
|
16770
|
-
cameraReady =
|
|
16771
|
-
cameraAccessDenied =
|
|
16772
|
-
requestCameraAccess =
|
|
16773
|
-
var
|
|
16774
|
-
cameraAccessRequested =
|
|
16775
|
-
setCameraAccessRequested =
|
|
16701
|
+
_j = _a.classNames,
|
|
16702
|
+
classNames = _j === void 0 ? {} : _j,
|
|
16703
|
+
_k = _a.verbiage,
|
|
16704
|
+
rawVerbiage = _k === void 0 ? {} : _k;
|
|
16705
|
+
var _l = useDocumentCaptureState(),
|
|
16706
|
+
_m = _l[0],
|
|
16707
|
+
documents = _m.documents,
|
|
16708
|
+
currentDocumentIndex = _m.currentDocumentIndex,
|
|
16709
|
+
rectX = _m.rectX,
|
|
16710
|
+
rectY = _m.rectY,
|
|
16711
|
+
rectWidth = _m.rectWidth,
|
|
16712
|
+
rectHeight = _m.rectHeight,
|
|
16713
|
+
rectOffsetTop = _m.rectOffsetTop,
|
|
16714
|
+
capturing = _m.capturing,
|
|
16715
|
+
uploadCapturedDocument = _m.uploadCapturedDocument,
|
|
16716
|
+
dispatch = _l[1];
|
|
16717
|
+
var _o = (_b = documents[currentDocumentIndex]) !== null && _b !== void 0 ? _b : {},
|
|
16718
|
+
title = _o.title,
|
|
16719
|
+
aspectRatio = _o.aspectRatio,
|
|
16720
|
+
cameraFeedMode = _o.cameraFeedMode,
|
|
16721
|
+
instructions = _o.instructions,
|
|
16722
|
+
contentUrl = _o.contentUrl,
|
|
16723
|
+
content = _o.content,
|
|
16724
|
+
uploadState = _o.uploadState;
|
|
16725
|
+
var _p = React.useContext(CameraStateContext),
|
|
16726
|
+
cameraRef = _p.cameraRef,
|
|
16727
|
+
cameraReady = _p.cameraReady,
|
|
16728
|
+
cameraAccessDenied = _p.cameraAccessDenied,
|
|
16729
|
+
requestCameraAccess = _p.requestCameraAccess;
|
|
16730
|
+
var _q = React.useState(false),
|
|
16731
|
+
cameraAccessRequested = _q[0],
|
|
16732
|
+
setCameraAccessRequested = _q[1];
|
|
16776
16733
|
var cameraAccessNeeded =
|
|
16777
16734
|
// we should force the browser to ask for camera access if...
|
|
16778
16735
|
uploadState === 'not_started' &&
|
|
@@ -16781,14 +16738,14 @@
|
|
|
16781
16738
|
// and the user hasn't passed a media blob for the current document...
|
|
16782
16739
|
!cameraAccessRequested &&
|
|
16783
16740
|
// and we haven't already tried to force a camera request...
|
|
16784
|
-
!(
|
|
16741
|
+
!((_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.
|
|
16785
16742
|
React.useEffect(function requestCameraAccessIfNeeded() {
|
|
16786
16743
|
if (!cameraAccessNeeded) return;
|
|
16787
16744
|
setCameraAccessRequested(true);
|
|
16788
16745
|
requestCameraAccess();
|
|
16789
16746
|
}, [cameraAccessNeeded, requestCameraAccess]);
|
|
16790
16747
|
var theme = styled.useTheme();
|
|
16791
|
-
var maskColor = (
|
|
16748
|
+
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)";
|
|
16792
16749
|
var verbiage = useTranslations(rawVerbiage, {
|
|
16793
16750
|
headingText: title,
|
|
16794
16751
|
loadingBtnText: 'Camera initializing...',
|
|
@@ -16821,7 +16778,7 @@
|
|
|
16821
16778
|
});
|
|
16822
16779
|
}
|
|
16823
16780
|
return /*#__PURE__*/React.createElement(PageContainer, {
|
|
16824
|
-
className: "flex ".concat((
|
|
16781
|
+
className: "flex ".concat((_h = classNames.container) !== null && _h !== void 0 ? _h : '')
|
|
16825
16782
|
}, /*#__PURE__*/React.createElement(CameraFeedWrapper, {
|
|
16826
16783
|
className: classNames.cameraFeedWrapper,
|
|
16827
16784
|
"$mode": cameraFeedMode !== null && cameraFeedMode !== void 0 ? cameraFeedMode : 'snapToGuides',
|
|
@@ -17246,7 +17203,7 @@
|
|
|
17246
17203
|
var _3 = useIdCaptureState(),
|
|
17247
17204
|
state = _3[0],
|
|
17248
17205
|
dispatch = _3[1];
|
|
17249
|
-
var _4 =
|
|
17206
|
+
var _4 = React.useContext(CameraStateContext),
|
|
17250
17207
|
cameraAccessDenied = _4.cameraAccessDenied,
|
|
17251
17208
|
requestCameraAccess = _4.requestCameraAccess,
|
|
17252
17209
|
releaseCameraAccess = _4.releaseCameraAccess;
|
|
@@ -17371,7 +17328,7 @@
|
|
|
17371
17328
|
type: 'resetWizard'
|
|
17372
17329
|
});
|
|
17373
17330
|
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
17374
|
-
|
|
17331
|
+
requestCameraAccess();
|
|
17375
17332
|
}, [dispatch, onExitCapture, releaseCameraAccess, requestCameraAccess]);
|
|
17376
17333
|
React.useEffect(function () {
|
|
17377
17334
|
if (submissionStatus !== SubmissionStatus.READY) {
|
|
@@ -18194,13 +18151,7 @@
|
|
|
18194
18151
|
modelLoadTimeoutMs = _c === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _c,
|
|
18195
18152
|
_d = _a.requireVerticalFaceCentering,
|
|
18196
18153
|
requireVerticalFaceCentering = _d === void 0 ? true : _d;
|
|
18197
|
-
var _e =
|
|
18198
|
-
return {
|
|
18199
|
-
videoRef: state.videoRef,
|
|
18200
|
-
videoLoaded: state.videoLoaded,
|
|
18201
|
-
cameraReady: state.cameraReady
|
|
18202
|
-
};
|
|
18203
|
-
})),
|
|
18154
|
+
var _e = React.useContext(CameraStateContext),
|
|
18204
18155
|
videoRef = _e.videoRef,
|
|
18205
18156
|
videoLoaded = _e.videoLoaded,
|
|
18206
18157
|
cameraReady = _e.cameraReady;
|
|
@@ -18208,8 +18159,7 @@
|
|
|
18208
18159
|
var onPredictionHandler = React.useRef();
|
|
18209
18160
|
var _f = useLoadFaceDetector({
|
|
18210
18161
|
onModelError: onModelError,
|
|
18211
|
-
modelLoadTimeoutMs: modelLoadTimeoutMs
|
|
18212
|
-
videoRef: videoRef
|
|
18162
|
+
modelLoadTimeoutMs: modelLoadTimeoutMs
|
|
18213
18163
|
}),
|
|
18214
18164
|
ready = _f.ready,
|
|
18215
18165
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
@@ -18542,14 +18492,8 @@
|
|
|
18542
18492
|
prediction = _t.prediction,
|
|
18543
18493
|
dispatch = _s[1];
|
|
18544
18494
|
var lastPredictionCanvas = React.useRef(null);
|
|
18545
|
-
var _u =
|
|
18546
|
-
|
|
18547
|
-
camera: state.camera,
|
|
18548
|
-
cameraReady: state.cameraReady,
|
|
18549
|
-
videoRef: state.videoRef
|
|
18550
|
-
};
|
|
18551
|
-
})),
|
|
18552
|
-
camera = _u.camera,
|
|
18495
|
+
var _u = React.useContext(CameraStateContext),
|
|
18496
|
+
cameraRef = _u.cameraRef,
|
|
18553
18497
|
videoRef = _u.videoRef;
|
|
18554
18498
|
var _v = React.useContext(SelfieGuidanceModelsContext),
|
|
18555
18499
|
onPredictionMade = _v.onPredictionMade,
|
|
@@ -18639,7 +18583,7 @@
|
|
|
18639
18583
|
face: prediction.face,
|
|
18640
18584
|
scaling: debugScalingDetails,
|
|
18641
18585
|
color: satisfied ? 'green' : 'red'
|
|
18642
|
-
}))), debugMode && ( /*#__PURE__*/React.createElement(DebugStatsPane, null,
|
|
18586
|
+
}))), debugMode && ( /*#__PURE__*/React.createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React.createElement(React.Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React.createElement("br", null), !(prediction === null || prediction === void 0 ? void 0 : prediction.faceNotCentered) ? '✅' : '❌', " Face Centered", /*#__PURE__*/React.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.createElement("br", null), !(prediction === null || prediction === void 0 ? void 0 : prediction.faceLookingAway) ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React.createElement("br", null), !(prediction === null || prediction === void 0 ? void 0 : prediction.faceIsStable) ? '✅' : '❌', " Face Is Stable", /*#__PURE__*/React.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.createElement(ExitCaptureButton, {
|
|
18643
18587
|
onClick: onExit,
|
|
18644
18588
|
className: classNames.exitCaptureBtn
|
|
18645
18589
|
}));
|
|
@@ -19095,9 +19039,7 @@
|
|
|
19095
19039
|
colors = _e === void 0 ? {} : _e,
|
|
19096
19040
|
_f = _a.verbiage,
|
|
19097
19041
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
19098
|
-
var requestMicrophoneAccess =
|
|
19099
|
-
return state.requestMicrophoneAccess;
|
|
19100
|
-
});
|
|
19042
|
+
var requestMicrophoneAccess = React.useContext(CameraStateContext).requestMicrophoneAccess;
|
|
19101
19043
|
assets.imageUrl || (assets.imageUrl = DEFAULT_CDN_URL + '/microphone-disable-icon.svg');
|
|
19102
19044
|
var verbiage = useTranslations(rawVerbiage, {
|
|
19103
19045
|
headingText: 'Your microphone permission is disabled',
|
|
@@ -19145,13 +19087,7 @@
|
|
|
19145
19087
|
colors = _e === void 0 ? {} : _e,
|
|
19146
19088
|
_f = _a.verbiage,
|
|
19147
19089
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
19148
|
-
var _g =
|
|
19149
|
-
return {
|
|
19150
|
-
cameraReady: state.cameraReady,
|
|
19151
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
19152
|
-
microphoneAccessDenied: state.microphoneAccessDenied
|
|
19153
|
-
};
|
|
19154
|
-
})),
|
|
19090
|
+
var _g = React.useContext(CameraStateContext),
|
|
19155
19091
|
cameraReady = _g.cameraReady,
|
|
19156
19092
|
cameraAccessDenied = _g.cameraAccessDenied,
|
|
19157
19093
|
microphoneAccessDenied = _g.microphoneAccessDenied;
|
|
@@ -19238,13 +19174,7 @@
|
|
|
19238
19174
|
colors = _e === void 0 ? {} : _e,
|
|
19239
19175
|
_f = _a.verbiage,
|
|
19240
19176
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
19241
|
-
var _g =
|
|
19242
|
-
return {
|
|
19243
|
-
cameraReady: state.cameraReady,
|
|
19244
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
19245
|
-
microphoneAccessDenied: state.microphoneAccessDenied
|
|
19246
|
-
};
|
|
19247
|
-
})),
|
|
19177
|
+
var _g = React.useContext(CameraStateContext),
|
|
19248
19178
|
cameraReady = _g.cameraReady,
|
|
19249
19179
|
cameraAccessDenied = _g.cameraAccessDenied,
|
|
19250
19180
|
microphoneAccessDenied = _g.microphoneAccessDenied;
|
|
@@ -19461,13 +19391,7 @@
|
|
|
19461
19391
|
livenessCheckRequest = _t.livenessCheckRequest,
|
|
19462
19392
|
setSelfieImage = _t.setSelfieImage,
|
|
19463
19393
|
logSelfieCaptureAttempt = _t.logSelfieCaptureAttempt;
|
|
19464
|
-
var _u =
|
|
19465
|
-
return {
|
|
19466
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
19467
|
-
requestCameraAccess: state.requestCameraAccess,
|
|
19468
|
-
releaseCameraAccess: state.releaseCameraAccess
|
|
19469
|
-
};
|
|
19470
|
-
})),
|
|
19394
|
+
var _u = React.useContext(CameraStateContext),
|
|
19471
19395
|
cameraAccessDenied = _u.cameraAccessDenied,
|
|
19472
19396
|
requestCameraAccess = _u.requestCameraAccess,
|
|
19473
19397
|
releaseCameraAccess = _u.releaseCameraAccess;
|
|
@@ -20956,10 +20880,10 @@
|
|
|
20956
20880
|
setSignatureVideoUrl = _e[1];
|
|
20957
20881
|
var signatureRecorder = React.useRef(null);
|
|
20958
20882
|
var recordedChunks = React.useRef([]);
|
|
20959
|
-
var _f =
|
|
20960
|
-
|
|
20883
|
+
var _f = React.useContext(CameraStateContext),
|
|
20884
|
+
cameraRef = _f.cameraRef,
|
|
20961
20885
|
videoRef = _f.videoRef;
|
|
20962
|
-
var _g = useVideoRecorder(
|
|
20886
|
+
var _g = useVideoRecorder(cameraRef.current),
|
|
20963
20887
|
isRecordingVideo = _g.isRecordingVideo,
|
|
20964
20888
|
startRecordingVideo = _g.startRecordingVideo,
|
|
20965
20889
|
stopRecordingVideo = _g.stopRecordingVideo,
|
|
@@ -21027,8 +20951,8 @@
|
|
|
21027
20951
|
var animationFrame = React.useRef(0);
|
|
21028
20952
|
React.useEffect(function () {
|
|
21029
20953
|
var _a;
|
|
21030
|
-
if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !
|
|
21031
|
-
var _b = [
|
|
20954
|
+
if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !cameraRef.current || !isRecording || !isRecordingVideo) return;
|
|
20955
|
+
var _b = [cameraRef.current.width, cameraRef.current.height],
|
|
21032
20956
|
w = _b[0],
|
|
21033
20957
|
h = _b[1];
|
|
21034
20958
|
var isPortrait = typeof window !== 'undefined' && window.innerWidth < window.innerHeight;
|
|
@@ -21061,7 +20985,7 @@
|
|
|
21061
20985
|
return function () {
|
|
21062
20986
|
cancelAnimationFrame(animationFrame.current);
|
|
21063
20987
|
};
|
|
21064
|
-
}, [
|
|
20988
|
+
}, [cameraRef, isRecording, isRecordingVideo, videoRef]);
|
|
21065
20989
|
var onAcceptClicked = React.useCallback(function () {
|
|
21066
20990
|
return __awaiter(_this, void 0, void 0, function () {
|
|
21067
20991
|
var imageUrl;
|
|
@@ -21190,29 +21114,27 @@
|
|
|
21190
21114
|
var templateObject_1$9, templateObject_2$8, templateObject_3$8, templateObject_4$3, templateObject_5$2, templateObject_6$2, templateObject_7$1;
|
|
21191
21115
|
|
|
21192
21116
|
var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
21193
|
-
var _b;
|
|
21117
|
+
var _b, _c, _d;
|
|
21194
21118
|
var onVideoCaptured = _a.onVideoCaptured,
|
|
21195
21119
|
onFaceNotDetected = _a.onFaceNotDetected,
|
|
21196
21120
|
onExit = _a.onExit,
|
|
21197
21121
|
guidesComponent = _a.guidesComponent,
|
|
21198
|
-
|
|
21199
|
-
classNames =
|
|
21200
|
-
|
|
21201
|
-
colors =
|
|
21202
|
-
|
|
21203
|
-
rawVerbiage =
|
|
21204
|
-
|
|
21205
|
-
debugMode =
|
|
21206
|
-
var
|
|
21207
|
-
return state.camera;
|
|
21208
|
-
});
|
|
21122
|
+
_e = _a.classNames,
|
|
21123
|
+
classNames = _e === void 0 ? {} : _e,
|
|
21124
|
+
_f = _a.colors,
|
|
21125
|
+
colors = _f === void 0 ? {} : _f,
|
|
21126
|
+
_g = _a.verbiage,
|
|
21127
|
+
rawVerbiage = _g === void 0 ? {} : _g,
|
|
21128
|
+
_h = _a.debugMode,
|
|
21129
|
+
debugMode = _h === void 0 ? false : _h;
|
|
21130
|
+
var cameraRef = React.useContext(CameraStateContext).cameraRef;
|
|
21209
21131
|
var onPredictionMade = React.useContext(SelfieGuidanceModelsContext).onPredictionMade;
|
|
21210
|
-
var
|
|
21211
|
-
signatureData =
|
|
21212
|
-
signatureDataUrl =
|
|
21213
|
-
signatureVideoData =
|
|
21214
|
-
startRecording =
|
|
21215
|
-
stopRecording =
|
|
21132
|
+
var _j = useVideoSignatureContext(),
|
|
21133
|
+
signatureData = _j.signatureData,
|
|
21134
|
+
signatureDataUrl = _j.signatureDataUrl,
|
|
21135
|
+
signatureVideoData = _j.signatureVideoData,
|
|
21136
|
+
startRecording = _j.startRecording,
|
|
21137
|
+
stopRecording = _j.stopRecording;
|
|
21216
21138
|
React.useEffect(function () {
|
|
21217
21139
|
startRecording();
|
|
21218
21140
|
return function () {
|
|
@@ -21229,9 +21151,9 @@
|
|
|
21229
21151
|
onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(signatureVideoData, signatureData, signatureDataUrl);
|
|
21230
21152
|
}
|
|
21231
21153
|
}, [onVideoCaptured, signatureData, signatureDataUrl, signatureVideoData]);
|
|
21232
|
-
var
|
|
21233
|
-
numFramesWithoutFaces =
|
|
21234
|
-
setNumFramesWithoutFaces =
|
|
21154
|
+
var _k = React.useState(0),
|
|
21155
|
+
numFramesWithoutFaces = _k[0],
|
|
21156
|
+
setNumFramesWithoutFaces = _k[1];
|
|
21235
21157
|
React.useEffect(function () {
|
|
21236
21158
|
onPredictionMade(function (_a) {
|
|
21237
21159
|
var face = _a.face;
|
|
@@ -21258,7 +21180,7 @@
|
|
|
21258
21180
|
}, verbiage.guidanceMessageText))), /*#__PURE__*/React.createElement(GuidesComponent, {
|
|
21259
21181
|
classNames: classNames.videoSignatureGuidesClassNames,
|
|
21260
21182
|
status: "success"
|
|
21261
|
-
}), debugMode && ( /*#__PURE__*/React.createElement(DebugStatsPane, null, "Video: ",
|
|
21183
|
+
}), debugMode && ( /*#__PURE__*/React.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.createElement(ExitCaptureButton, {
|
|
21262
21184
|
onClick: onExit,
|
|
21263
21185
|
className: classNames.exitCaptureBtn
|
|
21264
21186
|
}));
|
|
@@ -21352,13 +21274,7 @@
|
|
|
21352
21274
|
setSignatureData = _l.setSignatureData,
|
|
21353
21275
|
setSignatureVideoUrl = _l.setSignatureVideoUrl,
|
|
21354
21276
|
logSelfieCaptureAttempt = _l.logSelfieCaptureAttempt;
|
|
21355
|
-
var _m =
|
|
21356
|
-
return {
|
|
21357
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
21358
|
-
requestCameraAccess: state.requestCameraAccess,
|
|
21359
|
-
releaseCameraAccess: state.releaseCameraAccess
|
|
21360
|
-
};
|
|
21361
|
-
})),
|
|
21277
|
+
var _m = React.useContext(CameraStateContext),
|
|
21362
21278
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
21363
21279
|
requestCameraAccess = _m.requestCameraAccess,
|
|
21364
21280
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
@@ -21518,29 +21434,27 @@
|
|
|
21518
21434
|
};
|
|
21519
21435
|
|
|
21520
21436
|
var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
21521
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
21522
|
-
var
|
|
21523
|
-
requestedAction =
|
|
21524
|
-
|
|
21525
|
-
satisfied =
|
|
21526
|
-
|
|
21527
|
-
faceGuideStatus =
|
|
21437
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
21438
|
+
var _0 = _a.requestedAction,
|
|
21439
|
+
requestedAction = _0 === void 0 ? 'SHOW_ID_FRONT' : _0,
|
|
21440
|
+
_1 = _a.satisfied,
|
|
21441
|
+
satisfied = _1 === void 0 ? false : _1,
|
|
21442
|
+
_2 = _a.faceGuideStatus,
|
|
21443
|
+
faceGuideStatus = _2 === void 0 ? 'success' : _2,
|
|
21528
21444
|
faceGuideBorderWidth = _a.faceGuideBorderWidth,
|
|
21529
21445
|
faceGuideBorderColor = _a.faceGuideBorderColor,
|
|
21530
|
-
|
|
21531
|
-
idCardGuideStatus =
|
|
21446
|
+
_3 = _a.idCardGuideStatus,
|
|
21447
|
+
idCardGuideStatus = _3 === void 0 ? 'ready' : _3,
|
|
21532
21448
|
idCardGuideBorderWidth = _a.idCardGuideBorderWidth,
|
|
21533
21449
|
idCardGuideBorderColor = _a.idCardGuideBorderColor,
|
|
21534
21450
|
idCardCaptureProgress = _a.idCardCaptureProgress,
|
|
21535
|
-
|
|
21536
|
-
userSuppliedImages =
|
|
21537
|
-
|
|
21538
|
-
classNames =
|
|
21539
|
-
|
|
21540
|
-
rawVerbiage =
|
|
21541
|
-
var
|
|
21542
|
-
return state.isRearFacing;
|
|
21543
|
-
});
|
|
21451
|
+
_4 = _a.idCardCaptureGuideImages,
|
|
21452
|
+
userSuppliedImages = _4 === void 0 ? defaultIdCaptureGuideImages : _4,
|
|
21453
|
+
_5 = _a.classNames,
|
|
21454
|
+
classNames = _5 === void 0 ? {} : _5,
|
|
21455
|
+
_6 = _a.verbiage,
|
|
21456
|
+
rawVerbiage = _6 === void 0 ? {} : _6;
|
|
21457
|
+
var cameraRef = React.useContext(CameraStateContext).cameraRef;
|
|
21544
21458
|
var verbiage = useTranslations(rawVerbiage, {
|
|
21545
21459
|
idFrontInstructionText: 'Display the front of your ID card...',
|
|
21546
21460
|
idBackInstructionText: 'Display the back of your ID card...',
|
|
@@ -21553,17 +21467,17 @@
|
|
|
21553
21467
|
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';
|
|
21554
21468
|
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;
|
|
21555
21469
|
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';
|
|
21556
|
-
var
|
|
21557
|
-
idCardGuideRef =
|
|
21558
|
-
|
|
21559
|
-
idCardGuideWidth =
|
|
21560
|
-
|
|
21561
|
-
idCardGuideHeight =
|
|
21470
|
+
var _7 = useResizeObserver(),
|
|
21471
|
+
idCardGuideRef = _7.ref,
|
|
21472
|
+
_8 = _7.width,
|
|
21473
|
+
idCardGuideWidth = _8 === void 0 ? 0 : _8,
|
|
21474
|
+
_9 = _7.height,
|
|
21475
|
+
idCardGuideHeight = _9 === void 0 ? 0 : _9;
|
|
21562
21476
|
var idCaptureGuideImages = useGuideImages(userSuppliedImages);
|
|
21563
21477
|
var idCaptureGuideImagesByUrl = useGuideImagesByUrl(idCaptureGuideImages);
|
|
21564
|
-
var
|
|
21565
|
-
aspectRatio =
|
|
21566
|
-
setAspectRatio =
|
|
21478
|
+
var _10 = React.useState(undefined),
|
|
21479
|
+
aspectRatio = _10[0],
|
|
21480
|
+
setAspectRatio = _10[1];
|
|
21567
21481
|
var onImageLoaded = React.useCallback(function (e) {
|
|
21568
21482
|
var _a, _b, _c, _d;
|
|
21569
21483
|
var img = e.currentTarget;
|
|
@@ -21610,7 +21524,7 @@
|
|
|
21610
21524
|
}, /*#__PURE__*/React.createElement(IdCardGuideImage, {
|
|
21611
21525
|
alt: "",
|
|
21612
21526
|
className: classNames.idCardGuideImage,
|
|
21613
|
-
"$isMirrored": !isRearFacing,
|
|
21527
|
+
"$isMirrored": !((_v = cameraRef.current) === null || _v === void 0 ? void 0 : _v.isRearFacing),
|
|
21614
21528
|
style: idCardImageStyle,
|
|
21615
21529
|
src: requestedAction === 'SHOW_ID_BACK' ? idCaptureGuideImages.landscape.SHOW_ID_BACK.url : idCaptureGuideImages.landscape.SHOW_ID_FRONT.url,
|
|
21616
21530
|
onLoad: onImageLoaded
|
|
@@ -21624,8 +21538,8 @@
|
|
|
21624
21538
|
className: classNames.idCardGuideInstructionsContainer
|
|
21625
21539
|
}, /*#__PURE__*/React.createElement(IdCardGuideInstructions, {
|
|
21626
21540
|
className: classNames.idCardGuideInstructions,
|
|
21627
|
-
"$textColor": (
|
|
21628
|
-
"$background": (
|
|
21541
|
+
"$textColor": (_x = (_w = theme.idVideoCapture) === null || _w === void 0 ? void 0 : _w.idCardGuides) === null || _x === void 0 ? void 0 : _x.instructionsTextColor,
|
|
21542
|
+
"$background": (_z = (_y = theme.idVideoCapture) === null || _y === void 0 ? void 0 : _y.idCardGuides) === null || _z === void 0 ? void 0 : _z.instructionsBackgroundColor
|
|
21629
21543
|
}, instructionText))))));
|
|
21630
21544
|
};
|
|
21631
21545
|
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) {
|
|
@@ -21770,100 +21684,99 @@
|
|
|
21770
21684
|
flipShortcutThreshold: 0.7
|
|
21771
21685
|
};
|
|
21772
21686
|
var IdVideoCapture = function IdVideoCapture(_a) {
|
|
21773
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
21687
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
21774
21688
|
var onComplete = _a.onComplete,
|
|
21775
21689
|
onIdFrontImageCaptured = _a.onIdFrontImageCaptured,
|
|
21776
21690
|
onIdBackImageCaptured = _a.onIdBackImageCaptured,
|
|
21777
21691
|
onFaceNotDetected = _a.onFaceNotDetected,
|
|
21778
21692
|
onRecordingFailed = _a.onRecordingFailed,
|
|
21779
21693
|
onExitCapture = _a.onExitCapture,
|
|
21780
|
-
|
|
21781
|
-
idCaptureModelsEnabled =
|
|
21782
|
-
|
|
21783
|
-
idCardCaptureGuideImages =
|
|
21784
|
-
|
|
21785
|
-
idCardFrontDelay =
|
|
21786
|
-
|
|
21787
|
-
videoIdCaptureThresholds =
|
|
21788
|
-
|
|
21789
|
-
skipShowIdCardBack =
|
|
21790
|
-
|
|
21791
|
-
captureCountdownSeconds =
|
|
21694
|
+
_x = _a.idCaptureModelsEnabled,
|
|
21695
|
+
idCaptureModelsEnabled = _x === void 0 ? true : _x,
|
|
21696
|
+
_y = _a.idCardCaptureGuideImages,
|
|
21697
|
+
idCardCaptureGuideImages = _y === void 0 ? defaultIdCaptureGuideImages : _y,
|
|
21698
|
+
_z = _a.idCardFrontDelay,
|
|
21699
|
+
idCardFrontDelay = _z === void 0 ? 1000 : _z,
|
|
21700
|
+
_0 = _a.videoIdCaptureThresholds,
|
|
21701
|
+
videoIdCaptureThresholds = _0 === void 0 ? defaultVideoIdCaptureThresholds : _0,
|
|
21702
|
+
_1 = _a.skipShowIdCardBack,
|
|
21703
|
+
skipShowIdCardBack = _1 === void 0 ? false : _1,
|
|
21704
|
+
_2 = _a.captureCountdownSeconds,
|
|
21705
|
+
captureCountdownSeconds = _2 === void 0 ? 3 : _2,
|
|
21792
21706
|
readTextPrompt = _a.readTextPrompt,
|
|
21793
|
-
|
|
21794
|
-
readTextTimeoutDurationMs =
|
|
21795
|
-
|
|
21796
|
-
readTextMinReadingMs =
|
|
21797
|
-
|
|
21798
|
-
disableFaceDetectionWhileAudioCapture =
|
|
21799
|
-
|
|
21800
|
-
disableFaceDetectionWhileAudioCaptureMsDelay =
|
|
21801
|
-
|
|
21802
|
-
mergeAVStreams =
|
|
21803
|
-
|
|
21804
|
-
classNames =
|
|
21805
|
-
|
|
21806
|
-
colors =
|
|
21807
|
-
|
|
21808
|
-
rawVerbiage =
|
|
21809
|
-
|
|
21810
|
-
debugMode =
|
|
21811
|
-
var
|
|
21812
|
-
ref =
|
|
21813
|
-
|
|
21814
|
-
width =
|
|
21815
|
-
|
|
21816
|
-
height =
|
|
21817
|
-
var
|
|
21818
|
-
|
|
21819
|
-
videoRef =
|
|
21820
|
-
videoLoaded =
|
|
21821
|
-
cameraReady =
|
|
21822
|
-
microphoneReady =
|
|
21823
|
-
audioStream =
|
|
21824
|
-
|
|
21825
|
-
|
|
21826
|
-
|
|
21827
|
-
|
|
21828
|
-
|
|
21829
|
-
|
|
21830
|
-
|
|
21831
|
-
|
|
21832
|
-
|
|
21833
|
-
|
|
21834
|
-
|
|
21835
|
-
|
|
21836
|
-
|
|
21837
|
-
|
|
21838
|
-
|
|
21839
|
-
|
|
21840
|
-
|
|
21841
|
-
|
|
21842
|
-
|
|
21843
|
-
|
|
21844
|
-
|
|
21845
|
-
|
|
21846
|
-
|
|
21847
|
-
|
|
21848
|
-
|
|
21849
|
-
|
|
21850
|
-
|
|
21851
|
-
|
|
21852
|
-
|
|
21853
|
-
|
|
21854
|
-
|
|
21855
|
-
|
|
21856
|
-
|
|
21857
|
-
|
|
21858
|
-
|
|
21859
|
-
|
|
21860
|
-
|
|
21861
|
-
|
|
21862
|
-
audioUrl = _21.audioUrl;
|
|
21707
|
+
_3 = _a.readTextTimeoutDurationMs,
|
|
21708
|
+
readTextTimeoutDurationMs = _3 === void 0 ? 15000 : _3,
|
|
21709
|
+
_4 = _a.readTextMinReadingMs,
|
|
21710
|
+
readTextMinReadingMs = _4 === void 0 ? 10000 : _4,
|
|
21711
|
+
_5 = _a.disableFaceDetectionWhileAudioCapture,
|
|
21712
|
+
disableFaceDetectionWhileAudioCapture = _5 === void 0 ? false : _5,
|
|
21713
|
+
_6 = _a.disableFaceDetectionWhileAudioCaptureMsDelay,
|
|
21714
|
+
disableFaceDetectionWhileAudioCaptureMsDelay = _6 === void 0 ? 2000 : _6,
|
|
21715
|
+
_7 = _a.mergeAVStreams,
|
|
21716
|
+
mergeAVStreams = _7 === void 0 ? false : _7,
|
|
21717
|
+
_8 = _a.classNames,
|
|
21718
|
+
classNames = _8 === void 0 ? {} : _8,
|
|
21719
|
+
_9 = _a.colors,
|
|
21720
|
+
colors = _9 === void 0 ? {} : _9,
|
|
21721
|
+
_10 = _a.verbiage,
|
|
21722
|
+
rawVerbiage = _10 === void 0 ? {} : _10,
|
|
21723
|
+
_11 = _a.debugMode,
|
|
21724
|
+
debugMode = _11 === void 0 ? false : _11;
|
|
21725
|
+
var _12 = useResizeObserver(),
|
|
21726
|
+
ref = _12.ref,
|
|
21727
|
+
_13 = _12.width,
|
|
21728
|
+
width = _13 === void 0 ? 1 : _13,
|
|
21729
|
+
_14 = _12.height,
|
|
21730
|
+
height = _14 === void 0 ? 1 : _14;
|
|
21731
|
+
var _15 = React.useContext(CameraStateContext),
|
|
21732
|
+
cameraRef = _15.cameraRef,
|
|
21733
|
+
videoRef = _15.videoRef,
|
|
21734
|
+
videoLoaded = _15.videoLoaded,
|
|
21735
|
+
cameraReady = _15.cameraReady,
|
|
21736
|
+
microphoneReady = _15.microphoneReady,
|
|
21737
|
+
audioStream = _15.audioStream,
|
|
21738
|
+
setVideoLoaded = _15.setVideoLoaded;
|
|
21739
|
+
var _16 = React.useState([]),
|
|
21740
|
+
detectedObjects = _16[0],
|
|
21741
|
+
setDetectedObjects = _16[1];
|
|
21742
|
+
var _17 = React.useState(null),
|
|
21743
|
+
face = _17[0],
|
|
21744
|
+
setFace = _17[1];
|
|
21745
|
+
var _18 = React.useContext(IdCaptureModelsContext),
|
|
21746
|
+
idModelsReady = _18.ready,
|
|
21747
|
+
startIdModels = _18.start,
|
|
21748
|
+
stopIdModels = _18.stop,
|
|
21749
|
+
onIdPredictionMade = _18.onPredictionMade,
|
|
21750
|
+
setThresholds = _18.setThresholds,
|
|
21751
|
+
setDocumentDetectionBoundaries = _18.setDocumentDetectionBoundaries,
|
|
21752
|
+
bestFrameDetails = _18.bestFrameDetails,
|
|
21753
|
+
resetBestFrame = _18.resetBestFrame,
|
|
21754
|
+
idModelError = _18.modelError;
|
|
21755
|
+
var _19 = React.useState(null),
|
|
21756
|
+
videoStartsAt = _19[0],
|
|
21757
|
+
setVideoStartsAt = _19[1];
|
|
21758
|
+
var _20 = React.useContext(SubmissionContext),
|
|
21759
|
+
setIdCaptureVideoAudioStartsAt = _20.setIdCaptureVideoAudioStartsAt,
|
|
21760
|
+
setExpectedAudioText = _20.setExpectedAudioText;
|
|
21761
|
+
var _21 = React.useContext(SelfieGuidanceModelsContext),
|
|
21762
|
+
startSelfieGuidance = _21.start,
|
|
21763
|
+
stopSelfieGuidance = _21.stop,
|
|
21764
|
+
onSelfiePredictionMade = _21.onPredictionMade,
|
|
21765
|
+
selfieModelError = _21.error;
|
|
21766
|
+
var _22 = useVideoRecorder(cameraRef.current, audioStream, mergeAVStreams),
|
|
21767
|
+
isRecordingVideo = _22.isRecordingVideo,
|
|
21768
|
+
startRecordingVideo = _22.startRecordingVideo,
|
|
21769
|
+
startRecordingAudio = _22.startRecordingAudio,
|
|
21770
|
+
stopRecordingVideo = _22.stopRecordingVideo,
|
|
21771
|
+
stopRecordingAudio = _22.stopRecordingAudio,
|
|
21772
|
+
videoRecordingUnintentionallyStopped = _22.videoRecordingUnintentionallyStopped,
|
|
21773
|
+
audioRecordingUnintentionallyStopped = _22.audioRecordingUnintentionallyStopped,
|
|
21774
|
+
videoUrl = _22.videoUrl,
|
|
21775
|
+
audioUrl = _22.audioUrl;
|
|
21863
21776
|
var countdownTimeoutRef = React.useRef(undefined);
|
|
21864
|
-
var
|
|
21865
|
-
countdownRemaining =
|
|
21866
|
-
setCountdownRemaining =
|
|
21777
|
+
var _23 = React.useState(-1),
|
|
21778
|
+
countdownRemaining = _23[0],
|
|
21779
|
+
setCountdownRemaining = _23[1];
|
|
21867
21780
|
React.useEffect(function () {
|
|
21868
21781
|
if (!isRecordingVideo && !videoUrl) {
|
|
21869
21782
|
startRecordingVideo();
|
|
@@ -21874,18 +21787,18 @@
|
|
|
21874
21787
|
var needsAudio = !!readTextPrompt && !mergeAVStreams;
|
|
21875
21788
|
var audioReady = !needsAudio || audioUrl;
|
|
21876
21789
|
if (videoUrl && audioReady) {
|
|
21877
|
-
|
|
21790
|
+
setVideoLoaded(false);
|
|
21878
21791
|
onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl, audioUrl);
|
|
21879
21792
|
}
|
|
21880
|
-
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt,
|
|
21793
|
+
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, setVideoLoaded, startRecordingVideo, videoUrl]);
|
|
21881
21794
|
React.useEffect(function () {
|
|
21882
21795
|
if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped) {
|
|
21883
21796
|
onRecordingFailed === null || onRecordingFailed === void 0 ? void 0 : onRecordingFailed();
|
|
21884
21797
|
}
|
|
21885
21798
|
}, [audioRecordingUnintentionallyStopped, onRecordingFailed, videoRecordingUnintentionallyStopped]);
|
|
21886
|
-
var
|
|
21887
|
-
requestedAction =
|
|
21888
|
-
setRequestedAction =
|
|
21799
|
+
var _24 = React.useState('SHOW_ID_FRONT'),
|
|
21800
|
+
requestedAction = _24[0],
|
|
21801
|
+
setRequestedAction = _24[1];
|
|
21889
21802
|
var shouldRunIdModels = idCaptureModelsEnabled && videoLoaded && cameraReady && idModelsReady && !idModelError && requestedAction !== 'READ_TEXT' && (!readTextPrompt || microphoneReady);
|
|
21890
21803
|
React.useEffect(function startModelsWhenCapturing() {
|
|
21891
21804
|
if (!shouldRunIdModels) return;
|
|
@@ -21905,18 +21818,18 @@
|
|
|
21905
21818
|
bottom: 1
|
|
21906
21819
|
});
|
|
21907
21820
|
}, [setDocumentDetectionBoundaries]);
|
|
21908
|
-
var
|
|
21909
|
-
currentDetectionScore =
|
|
21910
|
-
setCurrentDetectionScore =
|
|
21911
|
-
var
|
|
21912
|
-
currentDetectedDocumentType =
|
|
21913
|
-
setCurrentDetectedDocumentType =
|
|
21914
|
-
var _26 = React.useState(0),
|
|
21915
|
-
currentFocusScore = _26[0],
|
|
21916
|
-
setCurrentFocusScore = _26[1];
|
|
21821
|
+
var _25 = React.useState(0),
|
|
21822
|
+
currentDetectionScore = _25[0],
|
|
21823
|
+
setCurrentDetectionScore = _25[1];
|
|
21824
|
+
var _26 = React.useState('none'),
|
|
21825
|
+
currentDetectedDocumentType = _26[0],
|
|
21826
|
+
setCurrentDetectedDocumentType = _26[1];
|
|
21917
21827
|
var _27 = React.useState(0),
|
|
21918
|
-
|
|
21919
|
-
|
|
21828
|
+
currentFocusScore = _27[0],
|
|
21829
|
+
setCurrentFocusScore = _27[1];
|
|
21830
|
+
var _28 = React.useState(0),
|
|
21831
|
+
goodFramesCount = _28[0],
|
|
21832
|
+
setGoodFramesCount = _28[1];
|
|
21920
21833
|
var goodFramesThreshold = requestedAction === 'SHOW_ID_FRONT' ? videoIdCaptureThresholds.goodFrames.idCardFront : videoIdCaptureThresholds.goodFrames.idCardBack;
|
|
21921
21834
|
var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
|
|
21922
21835
|
React.useEffect(function () {
|
|
@@ -21937,9 +21850,9 @@
|
|
|
21937
21850
|
} : 0);
|
|
21938
21851
|
});
|
|
21939
21852
|
}, [idCaptureModelsEnabled, onIdPredictionMade, idModelError, requestedAction, videoIdCaptureThresholds.flipShortcutThreshold]);
|
|
21940
|
-
var
|
|
21941
|
-
idFrontCaptureStartedAt =
|
|
21942
|
-
setFirstGoodFrameTime =
|
|
21853
|
+
var _29 = React.useState(null),
|
|
21854
|
+
idFrontCaptureStartedAt = _29[0],
|
|
21855
|
+
setFirstGoodFrameTime = _29[1];
|
|
21943
21856
|
React.useEffect(function () {
|
|
21944
21857
|
if (goodFramesCount === 1) setFirstGoodFrameTime(new Date().getTime());
|
|
21945
21858
|
}, [goodFramesCount]);
|
|
@@ -21960,9 +21873,9 @@
|
|
|
21960
21873
|
var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
|
|
21961
21874
|
var faceBox = face === null || face === void 0 ? void 0 : face.box;
|
|
21962
21875
|
var faceCentered = !faceBox || !frameWidth || faceBox.xMin > frameWidth * edgeBoundary && faceBox.yMin > frameHeight * edgeBoundary && faceBox.xMax < frameWidth * (1 - edgeBoundary) && faceBox.yMax < frameHeight * (1 - edgeBoundary);
|
|
21963
|
-
var
|
|
21964
|
-
countdownStartedAt =
|
|
21965
|
-
setCountdownStartedAt =
|
|
21876
|
+
var _30 = React.useState(),
|
|
21877
|
+
countdownStartedAt = _30[0],
|
|
21878
|
+
setCountdownStartedAt = _30[1];
|
|
21966
21879
|
var photoCanvas = React.useRef(null);
|
|
21967
21880
|
var frameLock = React.useRef(false);
|
|
21968
21881
|
var captureFrame = React.useCallback(function () {
|
|
@@ -22085,9 +21998,9 @@
|
|
|
22085
21998
|
stopSelfieGuidance();
|
|
22086
21999
|
};
|
|
22087
22000
|
}, [startSelfieGuidance, stopSelfieGuidance]);
|
|
22088
|
-
var
|
|
22089
|
-
numFramesWithoutFaces =
|
|
22090
|
-
setNumFramesWithoutFaces =
|
|
22001
|
+
var _31 = React.useState(0),
|
|
22002
|
+
numFramesWithoutFaces = _31[0],
|
|
22003
|
+
setNumFramesWithoutFaces = _31[1];
|
|
22091
22004
|
onSelfiePredictionMade(f(React.useCallback(function (_a) {
|
|
22092
22005
|
var face = _a.face;
|
|
22093
22006
|
if (selfieModelError) return;
|
|
@@ -22103,12 +22016,12 @@
|
|
|
22103
22016
|
}
|
|
22104
22017
|
}, [disableFaceDetectionWhileAudioCapture, disableFaceDetectionWhileAudioCaptureMsDelay, numFramesWithoutFaces, onFaceNotDetected, timeoutStartedAt]);
|
|
22105
22018
|
var theme = styled.useTheme();
|
|
22106
|
-
var
|
|
22019
|
+
var _32 = useTranslations(rawVerbiage, {
|
|
22107
22020
|
faceNotCenteredText: 'Please move your face to the center...',
|
|
22108
22021
|
captureBtnText: 'Capture'
|
|
22109
22022
|
}),
|
|
22110
|
-
captureBtnText =
|
|
22111
|
-
faceNotCenteredText =
|
|
22023
|
+
captureBtnText = _32.captureBtnText,
|
|
22024
|
+
faceNotCenteredText = _32.faceNotCenteredText;
|
|
22112
22025
|
var debugScalingDetails = useDebugScalingDetails({
|
|
22113
22026
|
enabled: debugMode,
|
|
22114
22027
|
pageWidth: width,
|
|
@@ -22144,14 +22057,15 @@
|
|
|
22144
22057
|
faceGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor,
|
|
22145
22058
|
idCardGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor
|
|
22146
22059
|
}), debugMode && capturingId && ( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ObjectDetectionDebugOverlayDiv, {
|
|
22147
|
-
"$flipX": !isRearFacing
|
|
22060
|
+
"$flipX": !((_l = cameraRef.current) === null || _l === void 0 ? void 0 : _l.isRearFacing)
|
|
22148
22061
|
}, detectedObjects.map(function (obj, i) {
|
|
22062
|
+
var _a;
|
|
22149
22063
|
return /*#__PURE__*/React.createElement(IdCaptureDetectedObjectDebugBox, {
|
|
22150
22064
|
key: i,
|
|
22151
22065
|
obj: obj,
|
|
22152
22066
|
scaling: debugScalingDetails,
|
|
22153
22067
|
color: "blue",
|
|
22154
|
-
flipX: !isRearFacing
|
|
22068
|
+
flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing)
|
|
22155
22069
|
});
|
|
22156
22070
|
})), /*#__PURE__*/React.createElement(DebugBoundingBoxOverlay, null, face && ( /*#__PURE__*/React.createElement(SelfieCaptureFaceDebugBox, {
|
|
22157
22071
|
face: face,
|
|
@@ -22160,9 +22074,9 @@
|
|
|
22160
22074
|
className: classNames.guidanceMessageContainer
|
|
22161
22075
|
}, /*#__PURE__*/React.createElement(GuidanceMessage, {
|
|
22162
22076
|
className: classNames.guidanceMessage,
|
|
22163
|
-
"$background": (
|
|
22164
|
-
"$textColor": (
|
|
22165
|
-
}, guidanceText))), debugMode && ( /*#__PURE__*/React.createElement(DebugStatsPane, null,
|
|
22077
|
+
"$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',
|
|
22078
|
+
"$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'
|
|
22079
|
+
}, guidanceText))), debugMode && ( /*#__PURE__*/React.createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React.createElement(React.Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React.createElement("br", null), isRecordingVideo ? '✅ Recording' : '❌ Not recording', /*#__PURE__*/React.createElement("br", null), goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', goodFramesCount, "/", goodFramesThreshold, /*#__PURE__*/React.createElement("br", null), "Document Type: ", currentDetectedDocumentType, /*#__PURE__*/React.createElement("br", null), "Detection Score: ", currentDetectionScore, /*#__PURE__*/React.createElement("br", null), "Focus Score: ", currentFocusScore, /*#__PURE__*/React.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.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.createElement(CountdownContainer, {
|
|
22166
22080
|
className: classNames.countdownContainer
|
|
22167
22081
|
}, /*#__PURE__*/React.createElement(Countdown, {
|
|
22168
22082
|
className: classNames.countdown
|
|
@@ -22459,14 +22373,16 @@
|
|
|
22459
22373
|
className: "flex"
|
|
22460
22374
|
}, /*#__PURE__*/React.createElement(Spinner$1, null));
|
|
22461
22375
|
}
|
|
22462
|
-
return /*#__PURE__*/React.createElement(
|
|
22463
|
-
|
|
22376
|
+
return /*#__PURE__*/React.createElement(CameraProvider, {
|
|
22377
|
+
key: "".concat(isCapturingId ? 'id' : 'selfie', "-camera-").concat(attempt),
|
|
22378
|
+
preferContinuityCamera: isCapturingId,
|
|
22464
22379
|
preferFrontFacingCamera: !isCapturingId,
|
|
22465
22380
|
requireMicrophoneAccess: !isCapturingId && !!readTextPrompt,
|
|
22466
22381
|
maxVideoWidth: isCapturingId ? 1920 : 1280,
|
|
22467
22382
|
maxFps: isCapturingId ? 60 : 30,
|
|
22468
22383
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
22469
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
22384
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
22385
|
+
debugMode: debugMode
|
|
22470
22386
|
}, /*#__PURE__*/React.createElement(IdCaptureModelsProvider, {
|
|
22471
22387
|
autoStart: false,
|
|
22472
22388
|
documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
|
|
@@ -22477,7 +22393,7 @@
|
|
|
22477
22393
|
autoStart: false,
|
|
22478
22394
|
onModelError: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onModelError,
|
|
22479
22395
|
modelLoadTimeoutMs: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.modelLoadTimeoutMs,
|
|
22480
|
-
requireVerticalFaceCentering:
|
|
22396
|
+
requireVerticalFaceCentering: captureState === 'CHECKING_LIVENESS'
|
|
22481
22397
|
}, /*#__PURE__*/React.createElement(PageContainer, {
|
|
22482
22398
|
className: "flex ".concat((_k = classNames.container) !== null && _k !== void 0 ? _k : '')
|
|
22483
22399
|
}, ['CHECKING_LIVENESS', 'CAPTURING_VIDEO'].includes(captureState) && /*#__PURE__*/React.createElement(CameraVideoTag, {
|
|
@@ -22592,15 +22508,17 @@
|
|
|
22592
22508
|
_o = _a.captureSignatureVideo,
|
|
22593
22509
|
captureSignatureVideo = _o === void 0 ? false : _o,
|
|
22594
22510
|
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
22595
|
-
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied
|
|
22596
|
-
|
|
22597
|
-
|
|
22598
|
-
|
|
22599
|
-
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
|
|
22511
|
+
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
|
|
22512
|
+
_p = _a.debugMode,
|
|
22513
|
+
debugMode = _p === void 0 ? false : _p;
|
|
22514
|
+
var _q = React.useContext(SubmissionContext),
|
|
22515
|
+
submit = _q.submit,
|
|
22516
|
+
submissionStatus = _q.submissionStatus,
|
|
22517
|
+
setSignatureData = _q.setSignatureData,
|
|
22518
|
+
setAdditionalDocuments = _q.setAdditionalDocuments;
|
|
22519
|
+
var _r = React.useState(0),
|
|
22520
|
+
checkIndex = _r[0],
|
|
22521
|
+
setCheckIndex = _r[1];
|
|
22604
22522
|
var checks = React.useMemo(function () {
|
|
22605
22523
|
var _a, _b;
|
|
22606
22524
|
var checks = __spreadArray([], userChecks, true);
|
|
@@ -22678,6 +22596,16 @@
|
|
|
22678
22596
|
return i + 1;
|
|
22679
22597
|
});
|
|
22680
22598
|
}, [onVideoSignatureCompleteProp]);
|
|
22599
|
+
var _s = React.useState(0),
|
|
22600
|
+
videoSignatureAttempts = _s[0],
|
|
22601
|
+
setVideoSignatureAttempts = _s[1];
|
|
22602
|
+
var onVideoSignatureRetryProp = videoSignatureCaptureProps.onRetryClicked;
|
|
22603
|
+
var onVideoSignatureRetry = React.useCallback(function () {
|
|
22604
|
+
onVideoSignatureRetryProp === null || onVideoSignatureRetryProp === void 0 ? void 0 : onVideoSignatureRetryProp();
|
|
22605
|
+
setVideoSignatureAttempts(function (n) {
|
|
22606
|
+
return n + 1;
|
|
22607
|
+
});
|
|
22608
|
+
}, [onVideoSignatureRetryProp]);
|
|
22681
22609
|
var onAdditionalDocumentCaptureCompleteProp = additionalDocumentCaptureProps === null || additionalDocumentCaptureProps === void 0 ? void 0 : additionalDocumentCaptureProps.onComplete;
|
|
22682
22610
|
var onAdditionalDocumentCaptureComplete = React.useCallback(function (uploadedDocuments) {
|
|
22683
22611
|
setAdditionalDocuments(uploadedDocuments);
|
|
@@ -22706,9 +22634,11 @@
|
|
|
22706
22634
|
}
|
|
22707
22635
|
switch (checks[checkIndex]) {
|
|
22708
22636
|
case 'IdCapture':
|
|
22709
|
-
return /*#__PURE__*/React.createElement(
|
|
22637
|
+
return /*#__PURE__*/React.createElement(CameraProvider, {
|
|
22638
|
+
key: "IdCaptureCamera",
|
|
22710
22639
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
22711
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
22640
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
22641
|
+
debugMode: debugMode
|
|
22712
22642
|
}, /*#__PURE__*/React.createElement(IdCaptureModelsProvider, {
|
|
22713
22643
|
autoStart: false,
|
|
22714
22644
|
documentDetectionModelUrl: (_d = (_c = idCaptureProps.assets) === null || _c === void 0 ? void 0 : _c.documentDetectionModelUrl) !== null && _d !== void 0 ? _d : '',
|
|
@@ -22725,11 +22655,13 @@
|
|
|
22725
22655
|
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
22726
22656
|
}));
|
|
22727
22657
|
case 'FaceLiveness':
|
|
22728
|
-
return /*#__PURE__*/React.createElement(
|
|
22658
|
+
return /*#__PURE__*/React.createElement(CameraProvider, {
|
|
22659
|
+
key: "FaceLivenessCamera",
|
|
22729
22660
|
preferFrontFacingCamera: true,
|
|
22730
|
-
|
|
22661
|
+
preferContinuityCamera: false,
|
|
22731
22662
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
22732
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
22663
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
22664
|
+
debugMode: debugMode
|
|
22733
22665
|
}, /*#__PURE__*/React.createElement(SelfieGuidanceModelsProvider, {
|
|
22734
22666
|
autoStart: false,
|
|
22735
22667
|
onModelError: faceLivenessProps.onModelError,
|
|
@@ -22742,13 +22674,15 @@
|
|
|
22742
22674
|
onAccept: onSignatureCaptureSuccess
|
|
22743
22675
|
}));
|
|
22744
22676
|
case 'VideoSignatureCapture':
|
|
22745
|
-
return /*#__PURE__*/React.createElement(
|
|
22746
|
-
|
|
22677
|
+
return /*#__PURE__*/React.createElement(CameraProvider, {
|
|
22678
|
+
key: "SignatureKycCamera-".concat(videoSignatureAttempts),
|
|
22679
|
+
preferContinuityCamera: false,
|
|
22747
22680
|
preferFrontFacingCamera: true,
|
|
22748
22681
|
maxVideoWidth: 1280,
|
|
22749
22682
|
maxFps: 30,
|
|
22750
22683
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
22751
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
22684
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
22685
|
+
debugMode: debugMode
|
|
22752
22686
|
}, /*#__PURE__*/React.createElement(SelfieGuidanceModelsProvider, {
|
|
22753
22687
|
autoStart: false,
|
|
22754
22688
|
throttleMs: 250,
|
|
@@ -22756,7 +22690,8 @@
|
|
|
22756
22690
|
modelLoadTimeoutMs: videoSignatureCaptureProps.modelLoadTimeoutMs,
|
|
22757
22691
|
requireVerticalFaceCentering: false
|
|
22758
22692
|
}, /*#__PURE__*/React.createElement(VideoSignatureWizard, _assign({}, videoSignatureCaptureProps, {
|
|
22759
|
-
onComplete: onVideoSignatureComplete
|
|
22693
|
+
onComplete: onVideoSignatureComplete,
|
|
22694
|
+
onRetryClicked: onVideoSignatureRetry
|
|
22760
22695
|
}))));
|
|
22761
22696
|
case 'AdditionalDocumentCapture':
|
|
22762
22697
|
return /*#__PURE__*/React.createElement(AdditionalDocumentCaptureWizard, _assign({}, additionalDocumentCaptureProps, {
|
|
@@ -23207,7 +23142,8 @@
|
|
|
23207
23142
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
23208
23143
|
captureSignature: captureSignature,
|
|
23209
23144
|
captureSignatureVideo: captureSignatureVideo,
|
|
23210
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
23145
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
23146
|
+
debugMode: debugMode
|
|
23211
23147
|
}))));
|
|
23212
23148
|
};
|
|
23213
23149
|
|
|
@@ -23313,7 +23249,8 @@
|
|
|
23313
23249
|
return ['FaceLiveness'];
|
|
23314
23250
|
}, []),
|
|
23315
23251
|
faceLivenessProps: faceLivenessProps,
|
|
23316
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
23252
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
23253
|
+
debugMode: debugMode
|
|
23317
23254
|
}))));
|
|
23318
23255
|
};
|
|
23319
23256
|
|
|
@@ -23546,7 +23483,8 @@
|
|
|
23546
23483
|
additionalDocumentCaptureProps: additionalDocumentCaptureProps,
|
|
23547
23484
|
captureSignature: captureSignature,
|
|
23548
23485
|
captureSignatureVideo: captureSignatureVideo,
|
|
23549
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
23486
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
23487
|
+
debugMode: debugMode
|
|
23550
23488
|
}))));
|
|
23551
23489
|
};
|
|
23552
23490
|
|
|
@@ -23801,7 +23739,8 @@
|
|
|
23801
23739
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
23802
23740
|
captureSignature: captureSignature,
|
|
23803
23741
|
captureSignatureVideo: captureSignatureVideo,
|
|
23804
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
23742
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
23743
|
+
debugMode: debugMode
|
|
23805
23744
|
}))));
|
|
23806
23745
|
};
|
|
23807
23746
|
|
|
@@ -24133,7 +24072,7 @@
|
|
|
24133
24072
|
var _l = React.useState('LOADING'),
|
|
24134
24073
|
captureState = _l[0],
|
|
24135
24074
|
setCaptureState = _l[1];
|
|
24136
|
-
var _m =
|
|
24075
|
+
var _m = React.useContext(CameraStateContext),
|
|
24137
24076
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
24138
24077
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
24139
24078
|
var _o = React.useContext(SelfieGuidanceModelsContext),
|
|
@@ -24339,9 +24278,10 @@
|
|
|
24339
24278
|
onSubmit: onSubmit,
|
|
24340
24279
|
geolocationEnabled: geolocationEnabled,
|
|
24341
24280
|
geolocationRequired: geolocationRequired
|
|
24342
|
-
}, /*#__PURE__*/React.createElement(
|
|
24281
|
+
}, /*#__PURE__*/React.createElement(CameraProvider, {
|
|
24343
24282
|
preferFrontFacingCamera: true,
|
|
24344
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
24283
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
24284
|
+
debugMode: debugMode
|
|
24345
24285
|
}, /*#__PURE__*/React.createElement(SelfieGuidanceModelsProvider, {
|
|
24346
24286
|
autoStart: false,
|
|
24347
24287
|
onModelError: onModelError,
|
|
@@ -24690,7 +24630,7 @@
|
|
|
24690
24630
|
var _l = React.useState('LOADING'),
|
|
24691
24631
|
captureState = _l[0],
|
|
24692
24632
|
setCaptureState = _l[1];
|
|
24693
|
-
var _m =
|
|
24633
|
+
var _m = React.useContext(CameraStateContext),
|
|
24694
24634
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
24695
24635
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
24696
24636
|
var _o = React.useContext(SelfieGuidanceModelsContext),
|
|
@@ -24894,9 +24834,10 @@
|
|
|
24894
24834
|
onSubmit: onSubmit,
|
|
24895
24835
|
geolocationEnabled: geolocationEnabled,
|
|
24896
24836
|
geolocationRequired: geolocationRequired
|
|
24897
|
-
}, /*#__PURE__*/React.createElement(
|
|
24837
|
+
}, /*#__PURE__*/React.createElement(CameraProvider, {
|
|
24898
24838
|
preferFrontFacingCamera: true,
|
|
24899
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
24839
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
24840
|
+
debugMode: debugMode
|
|
24900
24841
|
}, /*#__PURE__*/React.createElement(SelfieGuidanceModelsProvider, {
|
|
24901
24842
|
autoStart: false,
|
|
24902
24843
|
modelLoadTimeoutMs: modelLoadTimeoutMs,
|
|
@@ -25223,7 +25164,8 @@
|
|
|
25223
25164
|
captureSignature: captureSignature,
|
|
25224
25165
|
captureSignatureVideo: captureSignatureVideo,
|
|
25225
25166
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
25226
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
25167
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
25168
|
+
debugMode: debugMode
|
|
25227
25169
|
}))));
|
|
25228
25170
|
};
|
|
25229
25171
|
|
|
@@ -25380,7 +25322,8 @@
|
|
|
25380
25322
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
25381
25323
|
captureSignature: captureSignature,
|
|
25382
25324
|
captureSignatureVideo: captureSignatureVideo,
|
|
25383
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
25325
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
25326
|
+
debugMode: debugMode
|
|
25384
25327
|
}))));
|
|
25385
25328
|
};
|
|
25386
25329
|
|
|
@@ -25438,10 +25381,11 @@
|
|
|
25438
25381
|
onDocumentUploadFailed: onDocumentUploadFailed,
|
|
25439
25382
|
geolocationEnabled: geolocationEnabled,
|
|
25440
25383
|
geolocationRequired: geolocationRequired
|
|
25441
|
-
}, /*#__PURE__*/React.createElement(
|
|
25384
|
+
}, /*#__PURE__*/React.createElement(CameraProvider, {
|
|
25442
25385
|
requestAccessAutomatically: false,
|
|
25443
|
-
|
|
25444
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
25386
|
+
preferContinuityCamera: true,
|
|
25387
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
25388
|
+
debugMode: debugMode
|
|
25445
25389
|
}, /*#__PURE__*/React.createElement(DocumentCaptureWizard, {
|
|
25446
25390
|
onSuccess: onComplete,
|
|
25447
25391
|
onExitCapture: onExitCapture,
|