idmission-web-sdk 2.2.46 → 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 +1301 -1242
- 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 +1301 -1242
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +1244 -1302
- 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 +2 -3
- 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
|
}
|
|
@@ -7985,59 +8588,23 @@
|
|
|
7985
8588
|
visionRuntimePreloading = true;
|
|
7986
8589
|
url = "".concat(visionTasksBasePath, "/vision_wasm_internal.wasm");
|
|
7987
8590
|
document.addEventListener('idmission.preloadProgress', handleDownloadProgress);
|
|
7988
|
-
_a.label = 1;
|
|
7989
|
-
case 1:
|
|
7990
|
-
_a.trys.push([1,, 3, 4]);
|
|
7991
|
-
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);
|
|
8591
|
+
_a.label = 1;
|
|
8592
|
+
case 1:
|
|
8593
|
+
_a.trys.push([1,, 3, 4]);
|
|
8594
|
+
return [4 /*yield*/, preloadDependency(url)];
|
|
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);
|
|
@@ -9250,598 +9817,54 @@
|
|
|
9250
9817
|
var timer;
|
|
9251
9818
|
var currentLoopId = loopId.current;
|
|
9252
9819
|
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, 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
|
-
handleStreamEnded_1 = function handleStreamEnded_1() {
|
|
9628
|
-
if (preferIphoneContinuityCamera && get().iphoneContinuityCameraAvailable) {
|
|
9629
|
-
debug('someone unplugged the continuity camera');
|
|
9630
|
-
set({
|
|
9631
|
-
videoStream: null,
|
|
9632
|
-
videoDevice: null,
|
|
9633
|
-
cameraReady: false,
|
|
9634
|
-
iphoneContinuityCameraAvailable: false,
|
|
9635
|
-
iphoneContinuityCameraDenied: true
|
|
9636
|
-
});
|
|
9637
|
-
get().requestCameraAccess();
|
|
9638
|
-
} else {
|
|
9639
|
-
debug('someone unplugged the webcam');
|
|
9640
|
-
releaseCameraAccess();
|
|
9641
|
-
set({
|
|
9642
|
-
videoStream: null,
|
|
9643
|
-
videoDevice: null,
|
|
9644
|
-
videoLoaded: false,
|
|
9645
|
-
cameraReady: false,
|
|
9646
|
-
cameraAccessDenied: true
|
|
9647
|
-
});
|
|
9648
|
-
}
|
|
9649
|
-
};
|
|
9650
|
-
(_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('ended', handleStreamEnded_1);
|
|
9651
|
-
videoTrack_1 = stream_1.getVideoTracks()[0];
|
|
9652
|
-
videoTrack_1.onended = handleStreamEnded_1;
|
|
9653
|
-
camera_1 = obtainCameraAccess(stream_1, selectedCamera.label, videoRef.current);
|
|
9654
|
-
setTimeout(function () {
|
|
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
|
-
videoTrack_1.onmute = handleStreamEnded_1;
|
|
9658
|
-
set({
|
|
9659
|
-
camera: camera_1,
|
|
9660
|
-
cameraReady: true,
|
|
9661
|
-
cameraAccessDenied: false,
|
|
9662
|
-
isRearFacing: camera_1.isRearFacing,
|
|
9663
|
-
videoStream: stream_1
|
|
9664
|
-
});
|
|
9665
|
-
}, 500);
|
|
9666
|
-
return [3 /*break*/, 12];
|
|
9667
|
-
case 11:
|
|
9668
|
-
e_3 = _e.sent();
|
|
9669
|
-
if (e_3.name === 'NotAllowedError') {
|
|
9670
|
-
error('camera access has been blocked by the user', e_3);
|
|
9671
|
-
set({
|
|
9672
|
-
cameraAccessDenied: true
|
|
9673
|
-
});
|
|
9674
|
-
} else {
|
|
9675
|
-
error('camera access encountered some other error', e_3);
|
|
9676
|
-
throw e_3;
|
|
9677
|
-
}
|
|
9678
|
-
return [3 /*break*/, 12];
|
|
9679
|
-
case 12:
|
|
9680
|
-
return [2 /*return*/];
|
|
9681
|
-
}
|
|
9682
|
-
});
|
|
9683
|
-
});
|
|
9684
|
-
},
|
|
9685
|
-
releaseCameraAccess: function releaseCameraAccess() {
|
|
9686
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
9687
|
-
var camera;
|
|
9688
|
-
return __generator(this, function (_a) {
|
|
9689
|
-
camera = get().camera;
|
|
9690
|
-
if (!camera) return [2 /*return*/];
|
|
9691
|
-
camera.release();
|
|
9692
|
-
set({
|
|
9693
|
-
camera: null,
|
|
9694
|
-
cameraReady: false,
|
|
9695
|
-
cameraAccessDenied: false
|
|
9696
|
-
});
|
|
9697
|
-
return [2 /*return*/];
|
|
9698
|
-
});
|
|
9699
|
-
});
|
|
9700
|
-
},
|
|
9701
|
-
requestMicrophoneAccess: function requestMicrophoneAccess() {
|
|
9702
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
9703
|
-
var stream_2;
|
|
9704
|
-
return __generator(this, function (_a) {
|
|
9705
|
-
switch (_a.label) {
|
|
9706
|
-
case 0:
|
|
9707
|
-
get().releaseMicrophoneAccess();
|
|
9708
|
-
_a.label = 1;
|
|
9709
|
-
case 1:
|
|
9710
|
-
_a.trys.push([1, 3,, 4]);
|
|
9711
|
-
return [4 /*yield*/, navigator.mediaDevices.getUserMedia({
|
|
9712
|
-
audio: true,
|
|
9713
|
-
video: false
|
|
9714
|
-
})
|
|
9715
|
-
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
9716
|
-
// when the camera access is being requested. This delay is a workaround for that.
|
|
9717
|
-
];
|
|
9718
|
-
case 2:
|
|
9719
|
-
stream_2 = _a.sent();
|
|
9720
|
-
// iOS 17 has a strange behavior where the video track flickers between muted and unmuted
|
|
9721
|
-
// when the camera access is being requested. This delay is a workaround for that.
|
|
9722
|
-
setTimeout(function () {
|
|
9723
|
-
set({
|
|
9724
|
-
audioStream: stream_2,
|
|
9725
|
-
microphoneReady: true,
|
|
9726
|
-
microphoneAccessDenied: false
|
|
9727
|
-
});
|
|
9728
|
-
var track = stream_2.getAudioTracks()[0];
|
|
9729
|
-
track.onended = function () {
|
|
9730
|
-
return set({
|
|
9731
|
-
microphoneReady: false,
|
|
9732
|
-
microphoneAccessDenied: true
|
|
9733
|
-
});
|
|
9734
|
-
};
|
|
9735
|
-
track.onmute = function () {
|
|
9736
|
-
return set({
|
|
9737
|
-
microphoneReady: false,
|
|
9738
|
-
microphoneAccessDenied: true
|
|
9739
|
-
});
|
|
9740
|
-
};
|
|
9741
|
-
}, 500);
|
|
9742
|
-
return [3 /*break*/, 4];
|
|
9743
|
-
case 3:
|
|
9744
|
-
_a.sent();
|
|
9745
|
-
set({
|
|
9746
|
-
microphoneAccessDenied: true
|
|
9747
|
-
});
|
|
9748
|
-
return [3 /*break*/, 4];
|
|
9749
|
-
case 4:
|
|
9750
|
-
return [2 /*return*/];
|
|
9751
|
-
}
|
|
9752
|
-
});
|
|
9753
|
-
});
|
|
9754
|
-
},
|
|
9755
|
-
releaseMicrophoneAccess: function releaseMicrophoneAccess() {
|
|
9756
|
-
var _a;
|
|
9757
|
-
var audioStream = get().audioStream;
|
|
9758
|
-
(_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.stop) === null || _a === void 0 ? void 0 : _a.call(audioStream);
|
|
9759
|
-
audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks().forEach(function (track) {
|
|
9760
|
-
var _a;
|
|
9761
|
-
(_a = track.stop) === null || _a === void 0 ? void 0 : _a.call(track);
|
|
9762
|
-
});
|
|
9763
|
-
set({
|
|
9764
|
-
audioStream: null,
|
|
9765
|
-
microphoneReady: false,
|
|
9766
|
-
microphoneAccessDenied: false
|
|
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
|
+
}
|
|
9767
9839
|
});
|
|
9768
|
-
}
|
|
9769
|
-
});
|
|
9770
|
-
});
|
|
9771
|
-
if (config.requestAccessAutomatically) {
|
|
9772
|
-
void store.getState().requestCameraAccess();
|
|
9773
|
-
}
|
|
9774
|
-
return _assign(_assign({}, store), {
|
|
9775
|
-
destroy: function destroy() {
|
|
9776
|
-
store.getState().releaseCameraAccess();
|
|
9777
|
-
store.getState().releaseMicrophoneAccess();
|
|
9778
|
-
}
|
|
9779
|
-
});
|
|
9780
|
-
};
|
|
9781
|
-
var CameraStoreContext = /*#__PURE__*/React.createContext(undefined);
|
|
9782
|
-
function CameraStoreProvider(_a) {
|
|
9783
|
-
var children = _a.children,
|
|
9784
|
-
_b = _a.requestAccessAutomatically,
|
|
9785
|
-
requestAccessAutomatically = _b === void 0 ? true : _b,
|
|
9786
|
-
_c = _a.preferIphoneContinuityCamera,
|
|
9787
|
-
preferIphoneContinuityCamera = _c === void 0 ? true : _c,
|
|
9788
|
-
_d = _a.preferFrontFacingCamera,
|
|
9789
|
-
preferFrontFacingCamera = _d === void 0 ? false : _d,
|
|
9790
|
-
_e = _a.maxVideoWidth,
|
|
9791
|
-
maxVideoWidth = _e === void 0 ? 1920 : _e,
|
|
9792
|
-
maxFps = _a.maxFps,
|
|
9793
|
-
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
9794
|
-
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
|
|
9795
|
-
_f = _a.requireMicrophoneAccess,
|
|
9796
|
-
requireMicrophoneAccess = _f === void 0 ? false : _f;
|
|
9797
|
-
var videoRef = React.useRef(null);
|
|
9798
|
-
var store = React.useRef();
|
|
9799
|
-
store.current || (store.current = createCameraStore({
|
|
9800
|
-
videoRef: videoRef,
|
|
9801
|
-
requestAccessAutomatically: requestAccessAutomatically,
|
|
9802
|
-
preferIphoneContinuityCamera: preferIphoneContinuityCamera,
|
|
9803
|
-
preferFrontFacingCamera: preferFrontFacingCamera,
|
|
9804
|
-
maxVideoWidth: maxVideoWidth,
|
|
9805
|
-
maxFps: maxFps,
|
|
9806
|
-
onCameraAccessDenied: onCameraAccessDenied,
|
|
9807
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
9808
|
-
requireMicrophoneAccess: requireMicrophoneAccess
|
|
9809
|
-
}));
|
|
9810
|
-
React.useEffect(function () {
|
|
9811
|
-
var _a, _b, _c;
|
|
9812
|
-
var state = (_a = store.current) === null || _a === void 0 ? void 0 : _a.getState();
|
|
9813
|
-
if (!state) return;
|
|
9814
|
-
if (preferIphoneContinuityCamera !== (state === null || state === void 0 ? void 0 : state.preferIphoneContinuityCamera) || preferFrontFacingCamera !== (state === null || state === void 0 ? void 0 : state.preferFrontFacingCamera)) {
|
|
9815
|
-
(_b = store.current) === null || _b === void 0 ? void 0 : _b.setState({
|
|
9816
|
-
preferIphoneContinuityCamera: preferIphoneContinuityCamera,
|
|
9817
|
-
preferFrontFacingCamera: preferFrontFacingCamera
|
|
9818
9840
|
});
|
|
9819
|
-
(_c = store.current) === null || _c === void 0 ? void 0 : _c.getState().requestCameraAccess();
|
|
9820
9841
|
}
|
|
9821
|
-
|
|
9822
|
-
React.useEffect(function () {
|
|
9823
|
-
var _a;
|
|
9824
|
-
if (!requireMicrophoneAccess) return;
|
|
9825
|
-
(_a = store.current) === null || _a === void 0 ? void 0 : _a.getState().requestMicrophoneAccess();
|
|
9842
|
+
renderPrediction().then();
|
|
9826
9843
|
return function () {
|
|
9827
|
-
|
|
9828
|
-
|
|
9844
|
+
loopId.current += 1;
|
|
9845
|
+
frameId.current && cancelAnimationFrame(frameId.current);
|
|
9846
|
+
timer && clearTimeout(timer);
|
|
9829
9847
|
};
|
|
9830
|
-
}, [
|
|
9831
|
-
React.
|
|
9848
|
+
}, [fn, running, throttleMs]);
|
|
9849
|
+
var start = React.useCallback(function () {
|
|
9850
|
+
startedAtRef.current = new Date();
|
|
9851
|
+
setRunning(true);
|
|
9852
|
+
}, []);
|
|
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();
|
|
9832
9860
|
return function () {
|
|
9833
|
-
|
|
9834
|
-
return (_a = store.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
9861
|
+
stop();
|
|
9835
9862
|
};
|
|
9836
|
-
}, []);
|
|
9837
|
-
return
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
function useCameraStore(selector) {
|
|
9842
|
-
var store = React.useContext(CameraStoreContext);
|
|
9843
|
-
if (!store) throw new Error('useCameraStore cannot be used without Provider');
|
|
9844
|
-
return useStore(store, selector);
|
|
9863
|
+
}, [autoStart, start, stop]);
|
|
9864
|
+
return {
|
|
9865
|
+
start: start,
|
|
9866
|
+
stop: stop
|
|
9867
|
+
};
|
|
9845
9868
|
}
|
|
9846
9869
|
|
|
9847
9870
|
var DocumentDetectionModelContext = /*#__PURE__*/React.createContext({
|
|
@@ -9889,7 +9912,7 @@
|
|
|
9889
9912
|
_g = _a.documentDetectionModelLoadTimeoutMs,
|
|
9890
9913
|
documentDetectionModelLoadTimeoutMs = _g === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _g,
|
|
9891
9914
|
onDocumentDetectionModelError = _a.onDocumentDetectionModelError;
|
|
9892
|
-
var _h =
|
|
9915
|
+
var _h = React.useContext(CameraStateContext),
|
|
9893
9916
|
videoRef = _h.videoRef,
|
|
9894
9917
|
videoLoaded = _h.videoLoaded,
|
|
9895
9918
|
cameraReady = _h.cameraReady;
|
|
@@ -9912,8 +9935,7 @@
|
|
|
9912
9935
|
modelPath: documentDetectionModelPath,
|
|
9913
9936
|
modelLoadTimeoutMs: documentDetectionModelLoadTimeoutMs,
|
|
9914
9937
|
scoreThreshold: documentDetectionModelScoreThreshold,
|
|
9915
|
-
onModelError: onDocumentDetectionModelError
|
|
9916
|
-
videoRef: videoRef
|
|
9938
|
+
onModelError: onDocumentDetectionModelError
|
|
9917
9939
|
}),
|
|
9918
9940
|
ready = _o.ready,
|
|
9919
9941
|
modelDownloadProgress = _o.modelDownloadProgress,
|
|
@@ -10030,12 +10052,10 @@
|
|
|
10030
10052
|
var _e = React.useState({}),
|
|
10031
10053
|
focusThresholds = _e[0],
|
|
10032
10054
|
setFocusThresholds = _e[1];
|
|
10033
|
-
var videoRef = useCameraStore().videoRef;
|
|
10034
10055
|
var _f = useLoadFocusModel({
|
|
10035
10056
|
modelPath: focusModelPath,
|
|
10036
10057
|
modelLoadTimeoutMs: focusModelLoadTimeoutMs,
|
|
10037
|
-
onModelError: onFocusModelError
|
|
10038
|
-
videoRef: videoRef
|
|
10058
|
+
onModelError: onFocusModelError
|
|
10039
10059
|
}),
|
|
10040
10060
|
ready = _f.ready,
|
|
10041
10061
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
@@ -11475,9 +11495,9 @@
|
|
|
11475
11495
|
return e;
|
|
11476
11496
|
}
|
|
11477
11497
|
|
|
11478
|
-
function _createForOfIteratorHelperLoose
|
|
11479
|
-
function _unsupportedIterableToArray
|
|
11480
|
-
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; }
|
|
11481
11501
|
var consoleLogger = {
|
|
11482
11502
|
type: 'logger',
|
|
11483
11503
|
log: function log(args) {
|
|
@@ -12324,7 +12344,7 @@
|
|
|
12324
12344
|
}
|
|
12325
12345
|
if (!useOptionsReplaceForData) {
|
|
12326
12346
|
data = _extends({}, data);
|
|
12327
|
-
for (var _iterator = _createForOfIteratorHelperLoose
|
|
12347
|
+
for (var _iterator = _createForOfIteratorHelperLoose(optionsKeys), _step; !(_step = _iterator()).done;) {
|
|
12328
12348
|
var key = _step.value;
|
|
12329
12349
|
delete data[key];
|
|
12330
12350
|
}
|
|
@@ -14030,33 +14050,31 @@
|
|
|
14030
14050
|
var templateObject_1$D, templateObject_2$w, templateObject_3$o, templateObject_4$i, templateObject_5$b;
|
|
14031
14051
|
|
|
14032
14052
|
var IdCapture = function IdCapture(_a) {
|
|
14033
|
-
var _b, _c, _d, _e, _f, _g, _h;
|
|
14053
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
14034
14054
|
var requiredDocumentType = _a.requiredDocumentType,
|
|
14035
|
-
|
|
14036
|
-
thresholds =
|
|
14055
|
+
_k = _a.thresholds,
|
|
14056
|
+
thresholds = _k === void 0 ? defaultIdCaptureThresholds : _k,
|
|
14037
14057
|
guidanceMessage = _a.guidanceMessage,
|
|
14038
14058
|
guidanceSatisfied = _a.guidanceSatisfied,
|
|
14039
14059
|
onCapture = _a.onCapture,
|
|
14040
|
-
|
|
14041
|
-
classNames =
|
|
14042
|
-
|
|
14043
|
-
colors =
|
|
14044
|
-
|
|
14045
|
-
rawVerbiage =
|
|
14046
|
-
|
|
14047
|
-
debugMode =
|
|
14048
|
-
var
|
|
14049
|
-
ref =
|
|
14050
|
-
|
|
14051
|
-
width =
|
|
14052
|
-
|
|
14053
|
-
height =
|
|
14054
|
-
var
|
|
14055
|
-
state =
|
|
14056
|
-
dispatch =
|
|
14057
|
-
var
|
|
14058
|
-
camera = _t.camera,
|
|
14059
|
-
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;
|
|
14060
14078
|
var _u = React.useContext(IdCaptureModelsContext),
|
|
14061
14079
|
modelsReady = _u.ready,
|
|
14062
14080
|
setThresholds = _u.setThresholds,
|
|
@@ -14168,16 +14186,17 @@
|
|
|
14168
14186
|
classNames: classNames.overrideWrongDocumentTypeGuidanceDialog,
|
|
14169
14187
|
verbiage: rawVerbiage.overrideWrongDocumentTypeGuidanceDialog
|
|
14170
14188
|
}))), debugMode && ( /*#__PURE__*/React.createElement(DebugBoundingBoxOverlay, {
|
|
14171
|
-
"$flipX": !isRearFacing,
|
|
14189
|
+
"$flipX": !((_j = cameraRef.current) === null || _j === void 0 ? void 0 : _j.isRearFacing),
|
|
14172
14190
|
scaling: debugScalingDetails
|
|
14173
14191
|
}, state.detectedObjects.map(function (obj, i) {
|
|
14192
|
+
var _a;
|
|
14174
14193
|
return /*#__PURE__*/React.createElement(IdCaptureDetectedObjectDebugBox, {
|
|
14175
14194
|
key: i,
|
|
14176
14195
|
obj: obj,
|
|
14177
14196
|
scaling: debugScalingDetails,
|
|
14178
|
-
flipX: !isRearFacing
|
|
14197
|
+
flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing)
|
|
14179
14198
|
});
|
|
14180
|
-
}))), 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")))));
|
|
14181
14200
|
};
|
|
14182
14201
|
var timeSince = function timeSince(t) {
|
|
14183
14202
|
if (!t) return 0;
|
|
@@ -14194,9 +14213,7 @@
|
|
|
14194
14213
|
colors = _e === void 0 ? {} : _e,
|
|
14195
14214
|
_f = _a.verbiage,
|
|
14196
14215
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
14197
|
-
var requestCameraAccess =
|
|
14198
|
-
return state.requestCameraAccess;
|
|
14199
|
-
});
|
|
14216
|
+
var requestCameraAccess = React.useContext(CameraStateContext).requestCameraAccess;
|
|
14200
14217
|
assets.imageUrl || (assets.imageUrl = DEFAULT_CDN_URL + '/camera-disable-icon.png');
|
|
14201
14218
|
var verbiage = useTranslations(rawVerbiage, {
|
|
14202
14219
|
headingText: 'Your camera permission is disabled',
|
|
@@ -14844,7 +14861,7 @@
|
|
|
14844
14861
|
var _o = React.useContext(IdCaptureModelsContext),
|
|
14845
14862
|
modelsReady = _o.ready,
|
|
14846
14863
|
modelDownloadProgress = _o.modelDownloadProgress;
|
|
14847
|
-
var _p =
|
|
14864
|
+
var _p = React.useContext(CameraStateContext),
|
|
14848
14865
|
cameraReady = _p.cameraReady,
|
|
14849
14866
|
cameraAccessDenied = _p.cameraAccessDenied,
|
|
14850
14867
|
iphoneContinuityCameraAvailable = _p.iphoneContinuityCameraAvailable,
|
|
@@ -15022,71 +15039,6 @@
|
|
|
15022
15039
|
});
|
|
15023
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;
|
|
15024
15041
|
|
|
15025
|
-
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."); }
|
|
15026
|
-
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; } }
|
|
15027
|
-
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; }
|
|
15028
|
-
var isIterable = function isIterable(obj) {
|
|
15029
|
-
return Symbol.iterator in obj;
|
|
15030
|
-
};
|
|
15031
|
-
var compareMapLike = function compareMapLike(iterableA, iterableB) {
|
|
15032
|
-
var mapA = iterableA instanceof Map ? iterableA : new Map(iterableA);
|
|
15033
|
-
var mapB = iterableB instanceof Map ? iterableB : new Map(iterableB);
|
|
15034
|
-
if (mapA.size !== mapB.size) return false;
|
|
15035
|
-
for (var _iterator = _createForOfIteratorHelperLoose(mapA), _step; !(_step = _iterator()).done;) {
|
|
15036
|
-
var _step$value = _step.value,
|
|
15037
|
-
key = _step$value[0],
|
|
15038
|
-
value = _step$value[1];
|
|
15039
|
-
if (!Object.is(value, mapB.get(key))) {
|
|
15040
|
-
return false;
|
|
15041
|
-
}
|
|
15042
|
-
}
|
|
15043
|
-
return true;
|
|
15044
|
-
};
|
|
15045
|
-
function shallow(objA, objB) {
|
|
15046
|
-
if (Object.is(objA, objB)) {
|
|
15047
|
-
return true;
|
|
15048
|
-
}
|
|
15049
|
-
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
15050
|
-
return false;
|
|
15051
|
-
}
|
|
15052
|
-
if (isIterable(objA) && isIterable(objB)) {
|
|
15053
|
-
var iteratorA = objA[Symbol.iterator]();
|
|
15054
|
-
var iteratorB = objB[Symbol.iterator]();
|
|
15055
|
-
var nextA = iteratorA.next();
|
|
15056
|
-
var nextB = iteratorB.next();
|
|
15057
|
-
if (Array.isArray(nextA.value) && Array.isArray(nextB.value) && nextA.value.length === 2 && nextB.value.length === 2) {
|
|
15058
|
-
return compareMapLike(objA, objB);
|
|
15059
|
-
}
|
|
15060
|
-
while (!nextA.done && !nextB.done) {
|
|
15061
|
-
if (!Object.is(nextA.value, nextB.value)) {
|
|
15062
|
-
return false;
|
|
15063
|
-
}
|
|
15064
|
-
nextA = iteratorA.next();
|
|
15065
|
-
nextB = iteratorB.next();
|
|
15066
|
-
}
|
|
15067
|
-
return !!nextA.done && !!nextB.done;
|
|
15068
|
-
}
|
|
15069
|
-
var keysA = Object.keys(objA);
|
|
15070
|
-
if (keysA.length !== Object.keys(objB).length) {
|
|
15071
|
-
return false;
|
|
15072
|
-
}
|
|
15073
|
-
for (var _i = 0, _keysA = keysA; _i < _keysA.length; _i++) {
|
|
15074
|
-
var keyA = _keysA[_i];
|
|
15075
|
-
if (!Object.hasOwn(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {
|
|
15076
|
-
return false;
|
|
15077
|
-
}
|
|
15078
|
-
}
|
|
15079
|
-
return true;
|
|
15080
|
-
}
|
|
15081
|
-
|
|
15082
|
-
function useShallow(selector) {
|
|
15083
|
-
var prev = React.useRef();
|
|
15084
|
-
return function (state) {
|
|
15085
|
-
var next = selector(state);
|
|
15086
|
-
return shallow(prev.current, next) ? prev.current : prev.current = next;
|
|
15087
|
-
};
|
|
15088
|
-
}
|
|
15089
|
-
|
|
15090
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"])));
|
|
15091
15043
|
var ContinuityCameraCheckbox = styled.input(templateObject_2$s || (templateObject_2$s = __makeTemplateObject(["\n margin-right: 8px;\n"], ["\n margin-right: 8px;\n"])));
|
|
15092
15044
|
var IdCaptureLoadingOverlayLegacy = function IdCaptureLoadingOverlayLegacy(_a) {
|
|
@@ -15107,14 +15059,7 @@
|
|
|
15107
15059
|
var _l = React.useContext(IdCaptureModelsContext),
|
|
15108
15060
|
modelsReady = _l.ready,
|
|
15109
15061
|
modelDownloadProgress = _l.modelDownloadProgress;
|
|
15110
|
-
var _m =
|
|
15111
|
-
return {
|
|
15112
|
-
cameraReady: state.cameraReady,
|
|
15113
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
15114
|
-
iphoneContinuityCameraAvailable: state.iphoneContinuityCameraAvailable,
|
|
15115
|
-
setIphoneContinuityCameraAllowed: state.setIphoneContinuityCameraAllowed
|
|
15116
|
-
};
|
|
15117
|
-
})),
|
|
15062
|
+
var _m = React.useContext(CameraStateContext),
|
|
15118
15063
|
cameraReady = _m.cameraReady,
|
|
15119
15064
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
15120
15065
|
iphoneContinuityCameraAvailable = _m.iphoneContinuityCameraAvailable,
|
|
@@ -15660,24 +15605,23 @@
|
|
|
15660
15605
|
}
|
|
15661
15606
|
|
|
15662
15607
|
var IdVideoCaptureFlipIdPrompt = function IdVideoCaptureFlipIdPrompt(_a) {
|
|
15663
|
-
var _b
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
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,
|
|
15667
15613
|
borderWidth = _a.borderWidth,
|
|
15668
15614
|
borderColor = _a.borderColor,
|
|
15669
15615
|
borderRadius = _a.borderRadius,
|
|
15670
15616
|
imageStyle = _a.imageStyle;
|
|
15671
|
-
var
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
|
|
15676
|
-
|
|
15677
|
-
|
|
15678
|
-
|
|
15679
|
-
rotationAngle = _e[0],
|
|
15680
|
-
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];
|
|
15681
15625
|
var frontTransforms = ["rotateY(".concat(rotationAngle, "deg)")];
|
|
15682
15626
|
if (isMirrored) frontTransforms.push('scaleX(-1)');
|
|
15683
15627
|
var backTransforms = ["rotateY(".concat(180 - rotationAngle, "deg)")];
|
|
@@ -16201,30 +16145,29 @@
|
|
|
16201
16145
|
var templateObject_1$r, templateObject_2$n;
|
|
16202
16146
|
|
|
16203
16147
|
function IdCaptureGuides(_a) {
|
|
16204
|
-
var _b
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
16212
|
-
|
|
16213
|
-
|
|
16214
|
-
|
|
16215
|
-
|
|
16216
|
-
|
|
16217
|
-
|
|
16218
|
-
|
|
16219
|
-
|
|
16220
|
-
|
|
16221
|
-
|
|
16222
|
-
|
|
16223
|
-
|
|
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;
|
|
16224
16169
|
var state = useIdCaptureState()[0];
|
|
16225
|
-
var
|
|
16226
|
-
return state.isRearFacing;
|
|
16227
|
-
});
|
|
16170
|
+
var cameraRef = React.useContext(CameraStateContext).cameraRef;
|
|
16228
16171
|
var verbiage = useTranslations(rawVerbiage, {
|
|
16229
16172
|
instructionText: 'Scan the front of ID',
|
|
16230
16173
|
capturingText: 'Capturing...',
|
|
@@ -16236,7 +16179,7 @@
|
|
|
16236
16179
|
status: status,
|
|
16237
16180
|
progress: progress,
|
|
16238
16181
|
instruction: state.captureFailed ? verbiage.captureFailedText : state.capturing ? verbiage === null || verbiage === void 0 ? void 0 : verbiage.capturingText : verbiage.instructionText,
|
|
16239
|
-
isMirrored: !isRearFacing,
|
|
16182
|
+
isMirrored: !((_b = cameraRef.current) === null || _b === void 0 ? void 0 : _b.isRearFacing),
|
|
16240
16183
|
borderColor: state.isGoodFrame ? colors.guideBoxSatisfiedColor : colors.guideBoxUnsatisfiedColor,
|
|
16241
16184
|
imageVisible: requestedAction === 'FLIP_ID' || !state.idCardFrontDetectionThresholdMet || !state.documentInBounds || state.documentTooClose
|
|
16242
16185
|
})), guideType === 'fit' && ( /*#__PURE__*/React.createElement(IdCaptureFitGuide, {
|
|
@@ -16246,7 +16189,7 @@
|
|
|
16246
16189
|
status: status,
|
|
16247
16190
|
progress: progress,
|
|
16248
16191
|
instruction: state.captureFailed ? verbiage.captureFailedText : state.capturing ? verbiage === null || verbiage === void 0 ? void 0 : verbiage.capturingText : verbiage.instructionText,
|
|
16249
|
-
isMirrored: !isRearFacing,
|
|
16192
|
+
isMirrored: !((_c = cameraRef.current) === null || _c === void 0 ? void 0 : _c.isRearFacing),
|
|
16250
16193
|
isBackToFront: isBackToFront,
|
|
16251
16194
|
portraitGuidesOnMobile: portraitGuidesOnMobile,
|
|
16252
16195
|
borderColor: state.isGoodFrame ? colors.guideBoxSatisfiedColor : colors.guideBoxUnsatisfiedColor,
|
|
@@ -16345,6 +16288,48 @@
|
|
|
16345
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"])));
|
|
16346
16289
|
var templateObject_1$q, templateObject_2$m, templateObject_3$h, templateObject_4$b;
|
|
16347
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
|
+
|
|
16348
16333
|
var documentCaptureInitialState = {
|
|
16349
16334
|
documents: [],
|
|
16350
16335
|
currentDocumentIndex: 0,
|
|
@@ -16463,8 +16448,8 @@
|
|
|
16463
16448
|
var _c = React.useReducer(documentCaptureStateReducer, documentCaptureInitialState),
|
|
16464
16449
|
state = _c[0],
|
|
16465
16450
|
dispatch = _c[1];
|
|
16466
|
-
var _d =
|
|
16467
|
-
|
|
16451
|
+
var _d = React.useContext(CameraStateContext),
|
|
16452
|
+
cameraRef = _d.cameraRef,
|
|
16468
16453
|
videoRef = _d.videoRef;
|
|
16469
16454
|
var uploadDocument = React.useContext(SubmissionContext).uploadDocument;
|
|
16470
16455
|
var uploadCapturedDocument = React.useCallback(function (content, filetype) {
|
|
@@ -16555,7 +16540,8 @@
|
|
|
16555
16540
|
}, [onResize]);
|
|
16556
16541
|
var videoTag = videoRef.current;
|
|
16557
16542
|
React.useEffect(function () {
|
|
16558
|
-
if (!state.capturing
|
|
16543
|
+
if (!state.capturing) return;
|
|
16544
|
+
if (!cameraRef.current) return;
|
|
16559
16545
|
function onComplete(content) {
|
|
16560
16546
|
if (!content) return;
|
|
16561
16547
|
var contentUrl = URL.createObjectURL(content);
|
|
@@ -16568,7 +16554,7 @@
|
|
|
16568
16554
|
});
|
|
16569
16555
|
}
|
|
16570
16556
|
if (typeof ImageCapture !== 'undefined') {
|
|
16571
|
-
var tracks =
|
|
16557
|
+
var tracks = cameraRef.current.stream.getTracks();
|
|
16572
16558
|
var videoCameraTrack = tracks.find(function (track) {
|
|
16573
16559
|
return track.kind === 'video';
|
|
16574
16560
|
});
|
|
@@ -16583,7 +16569,7 @@
|
|
|
16583
16569
|
drawToCanvas(canvas, videoTag);
|
|
16584
16570
|
canvas.toBlob(onComplete);
|
|
16585
16571
|
}
|
|
16586
|
-
}, [state.capturing,
|
|
16572
|
+
}, [cameraRef, state.capturing, videoTag]);
|
|
16587
16573
|
var stateWithActions = React.useMemo(function () {
|
|
16588
16574
|
return _assign(_assign({}, state), {
|
|
16589
16575
|
uploadCapturedDocument: uploadCapturedDocument
|
|
@@ -16698,85 +16684,52 @@
|
|
|
16698
16684
|
ref: canvasRef
|
|
16699
16685
|
}));
|
|
16700
16686
|
};
|
|
16701
|
-
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) {
|
|
16702
16688
|
return props.$maskColor;
|
|
16703
16689
|
});
|
|
16704
16690
|
var Canvas = styled.canvas(templateObject_2$l || (templateObject_2$l = __makeTemplateObject(["\n display: block;\n"], ["\n display: block;\n"])));
|
|
16705
|
-
var templateObject_1$
|
|
16691
|
+
var templateObject_1$o, templateObject_2$l;
|
|
16706
16692
|
|
|
16707
|
-
var CameraFeedWrapper = styled.div(templateObject_1$
|
|
16693
|
+
var CameraFeedWrapper = styled.div(templateObject_1$n || (templateObject_1$n = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (props) {
|
|
16708
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;") : "";
|
|
16709
16695
|
});
|
|
16710
|
-
var templateObject_1$o;
|
|
16711
|
-
|
|
16712
|
-
var CameraVideoTag = function CameraVideoTag(props) {
|
|
16713
|
-
var _a = useCameraStore(useShallow(function (store) {
|
|
16714
|
-
return {
|
|
16715
|
-
videoRef: store.videoRef,
|
|
16716
|
-
videoStream: store.videoStream,
|
|
16717
|
-
onVideoMounted: store.onVideoMounted,
|
|
16718
|
-
isRearFacing: store.isRearFacing
|
|
16719
|
-
};
|
|
16720
|
-
})),
|
|
16721
|
-
videoRef = _a.videoRef,
|
|
16722
|
-
videoStream = _a.videoStream,
|
|
16723
|
-
onVideoMounted = _a.onVideoMounted,
|
|
16724
|
-
isRearFacing = _a.isRearFacing;
|
|
16725
|
-
React.useEffect(function attachCameraStreamToVideoTagWhenReady() {
|
|
16726
|
-
if (videoRef.current && videoStream) {
|
|
16727
|
-
debug('attaching camera stream to video tag');
|
|
16728
|
-
videoRef.current.srcObject = videoStream;
|
|
16729
|
-
}
|
|
16730
|
-
}, [videoStream, videoRef]);
|
|
16731
|
-
return /*#__PURE__*/React.createElement(FullscreenVideoTag, _assign({
|
|
16732
|
-
autoPlay: true,
|
|
16733
|
-
playsInline: true,
|
|
16734
|
-
muted: true,
|
|
16735
|
-
ref: videoRef,
|
|
16736
|
-
onLoadedData: onVideoMounted,
|
|
16737
|
-
"$isRearFacing": isRearFacing
|
|
16738
|
-
}, props));
|
|
16739
|
-
};
|
|
16740
|
-
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) {
|
|
16741
|
-
return props.$isRearFacing ? '' : 'scaleX(-1)';
|
|
16742
|
-
});
|
|
16743
16696
|
var templateObject_1$n;
|
|
16744
16697
|
|
|
16745
16698
|
var DocumentCaptureScreen = function DocumentCaptureScreen(_a) {
|
|
16746
|
-
var _b, _c, _d, _e, _f;
|
|
16699
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
16747
16700
|
var onCaptureClicked = _a.onCaptureClicked,
|
|
16748
|
-
|
|
16749
|
-
classNames =
|
|
16750
|
-
|
|
16751
|
-
rawVerbiage =
|
|
16752
|
-
var
|
|
16753
|
-
|
|
16754
|
-
documents =
|
|
16755
|
-
currentDocumentIndex =
|
|
16756
|
-
rectX =
|
|
16757
|
-
rectY =
|
|
16758
|
-
rectWidth =
|
|
16759
|
-
rectHeight =
|
|
16760
|
-
rectOffsetTop =
|
|
16761
|
-
capturing =
|
|
16762
|
-
uploadCapturedDocument =
|
|
16763
|
-
dispatch =
|
|
16764
|
-
var
|
|
16765
|
-
title =
|
|
16766
|
-
aspectRatio =
|
|
16767
|
-
cameraFeedMode =
|
|
16768
|
-
instructions =
|
|
16769
|
-
contentUrl =
|
|
16770
|
-
content =
|
|
16771
|
-
uploadState =
|
|
16772
|
-
var
|
|
16773
|
-
|
|
16774
|
-
cameraReady =
|
|
16775
|
-
cameraAccessDenied =
|
|
16776
|
-
requestCameraAccess =
|
|
16777
|
-
var
|
|
16778
|
-
cameraAccessRequested =
|
|
16779
|
-
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];
|
|
16780
16733
|
var cameraAccessNeeded =
|
|
16781
16734
|
// we should force the browser to ask for camera access if...
|
|
16782
16735
|
uploadState === 'not_started' &&
|
|
@@ -16785,14 +16738,14 @@
|
|
|
16785
16738
|
// and the user hasn't passed a media blob for the current document...
|
|
16786
16739
|
!cameraAccessRequested &&
|
|
16787
16740
|
// and we haven't already tried to force a camera request...
|
|
16788
|
-
!(
|
|
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.
|
|
16789
16742
|
React.useEffect(function requestCameraAccessIfNeeded() {
|
|
16790
16743
|
if (!cameraAccessNeeded) return;
|
|
16791
16744
|
setCameraAccessRequested(true);
|
|
16792
16745
|
requestCameraAccess();
|
|
16793
16746
|
}, [cameraAccessNeeded, requestCameraAccess]);
|
|
16794
16747
|
var theme = styled.useTheme();
|
|
16795
|
-
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)";
|
|
16796
16749
|
var verbiage = useTranslations(rawVerbiage, {
|
|
16797
16750
|
headingText: title,
|
|
16798
16751
|
loadingBtnText: 'Camera initializing...',
|
|
@@ -16825,7 +16778,7 @@
|
|
|
16825
16778
|
});
|
|
16826
16779
|
}
|
|
16827
16780
|
return /*#__PURE__*/React.createElement(PageContainer, {
|
|
16828
|
-
className: "flex ".concat((
|
|
16781
|
+
className: "flex ".concat((_h = classNames.container) !== null && _h !== void 0 ? _h : '')
|
|
16829
16782
|
}, /*#__PURE__*/React.createElement(CameraFeedWrapper, {
|
|
16830
16783
|
className: classNames.cameraFeedWrapper,
|
|
16831
16784
|
"$mode": cameraFeedMode !== null && cameraFeedMode !== void 0 ? cameraFeedMode : 'snapToGuides',
|
|
@@ -17250,7 +17203,7 @@
|
|
|
17250
17203
|
var _3 = useIdCaptureState(),
|
|
17251
17204
|
state = _3[0],
|
|
17252
17205
|
dispatch = _3[1];
|
|
17253
|
-
var _4 =
|
|
17206
|
+
var _4 = React.useContext(CameraStateContext),
|
|
17254
17207
|
cameraAccessDenied = _4.cameraAccessDenied,
|
|
17255
17208
|
requestCameraAccess = _4.requestCameraAccess,
|
|
17256
17209
|
releaseCameraAccess = _4.releaseCameraAccess;
|
|
@@ -17375,7 +17328,7 @@
|
|
|
17375
17328
|
type: 'resetWizard'
|
|
17376
17329
|
});
|
|
17377
17330
|
onExitCapture === null || onExitCapture === void 0 ? void 0 : onExitCapture();
|
|
17378
|
-
|
|
17331
|
+
requestCameraAccess();
|
|
17379
17332
|
}, [dispatch, onExitCapture, releaseCameraAccess, requestCameraAccess]);
|
|
17380
17333
|
React.useEffect(function () {
|
|
17381
17334
|
if (submissionStatus !== SubmissionStatus.READY) {
|
|
@@ -18198,13 +18151,7 @@
|
|
|
18198
18151
|
modelLoadTimeoutMs = _c === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _c,
|
|
18199
18152
|
_d = _a.requireVerticalFaceCentering,
|
|
18200
18153
|
requireVerticalFaceCentering = _d === void 0 ? true : _d;
|
|
18201
|
-
var _e =
|
|
18202
|
-
return {
|
|
18203
|
-
videoRef: state.videoRef,
|
|
18204
|
-
videoLoaded: state.videoLoaded,
|
|
18205
|
-
cameraReady: state.cameraReady
|
|
18206
|
-
};
|
|
18207
|
-
})),
|
|
18154
|
+
var _e = React.useContext(CameraStateContext),
|
|
18208
18155
|
videoRef = _e.videoRef,
|
|
18209
18156
|
videoLoaded = _e.videoLoaded,
|
|
18210
18157
|
cameraReady = _e.cameraReady;
|
|
@@ -18212,8 +18159,7 @@
|
|
|
18212
18159
|
var onPredictionHandler = React.useRef();
|
|
18213
18160
|
var _f = useLoadFaceDetector({
|
|
18214
18161
|
onModelError: onModelError,
|
|
18215
|
-
modelLoadTimeoutMs: modelLoadTimeoutMs
|
|
18216
|
-
videoRef: videoRef
|
|
18162
|
+
modelLoadTimeoutMs: modelLoadTimeoutMs
|
|
18217
18163
|
}),
|
|
18218
18164
|
ready = _f.ready,
|
|
18219
18165
|
modelDownloadProgress = _f.modelDownloadProgress,
|
|
@@ -18546,14 +18492,8 @@
|
|
|
18546
18492
|
prediction = _t.prediction,
|
|
18547
18493
|
dispatch = _s[1];
|
|
18548
18494
|
var lastPredictionCanvas = React.useRef(null);
|
|
18549
|
-
var _u =
|
|
18550
|
-
|
|
18551
|
-
camera: state.camera,
|
|
18552
|
-
cameraReady: state.cameraReady,
|
|
18553
|
-
videoRef: state.videoRef
|
|
18554
|
-
};
|
|
18555
|
-
})),
|
|
18556
|
-
camera = _u.camera,
|
|
18495
|
+
var _u = React.useContext(CameraStateContext),
|
|
18496
|
+
cameraRef = _u.cameraRef,
|
|
18557
18497
|
videoRef = _u.videoRef;
|
|
18558
18498
|
var _v = React.useContext(SelfieGuidanceModelsContext),
|
|
18559
18499
|
onPredictionMade = _v.onPredictionMade,
|
|
@@ -18643,7 +18583,7 @@
|
|
|
18643
18583
|
face: prediction.face,
|
|
18644
18584
|
scaling: debugScalingDetails,
|
|
18645
18585
|
color: satisfied ? 'green' : 'red'
|
|
18646
|
-
}))), 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, {
|
|
18647
18587
|
onClick: onExit,
|
|
18648
18588
|
className: classNames.exitCaptureBtn
|
|
18649
18589
|
}));
|
|
@@ -19099,9 +19039,7 @@
|
|
|
19099
19039
|
colors = _e === void 0 ? {} : _e,
|
|
19100
19040
|
_f = _a.verbiage,
|
|
19101
19041
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
19102
|
-
var requestMicrophoneAccess =
|
|
19103
|
-
return state.requestMicrophoneAccess;
|
|
19104
|
-
});
|
|
19042
|
+
var requestMicrophoneAccess = React.useContext(CameraStateContext).requestMicrophoneAccess;
|
|
19105
19043
|
assets.imageUrl || (assets.imageUrl = DEFAULT_CDN_URL + '/microphone-disable-icon.svg');
|
|
19106
19044
|
var verbiage = useTranslations(rawVerbiage, {
|
|
19107
19045
|
headingText: 'Your microphone permission is disabled',
|
|
@@ -19149,13 +19087,7 @@
|
|
|
19149
19087
|
colors = _e === void 0 ? {} : _e,
|
|
19150
19088
|
_f = _a.verbiage,
|
|
19151
19089
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
19152
|
-
var _g =
|
|
19153
|
-
return {
|
|
19154
|
-
cameraReady: state.cameraReady,
|
|
19155
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
19156
|
-
microphoneAccessDenied: state.microphoneAccessDenied
|
|
19157
|
-
};
|
|
19158
|
-
})),
|
|
19090
|
+
var _g = React.useContext(CameraStateContext),
|
|
19159
19091
|
cameraReady = _g.cameraReady,
|
|
19160
19092
|
cameraAccessDenied = _g.cameraAccessDenied,
|
|
19161
19093
|
microphoneAccessDenied = _g.microphoneAccessDenied;
|
|
@@ -19242,13 +19174,7 @@
|
|
|
19242
19174
|
colors = _e === void 0 ? {} : _e,
|
|
19243
19175
|
_f = _a.verbiage,
|
|
19244
19176
|
rawVerbiage = _f === void 0 ? {} : _f;
|
|
19245
|
-
var _g =
|
|
19246
|
-
return {
|
|
19247
|
-
cameraReady: state.cameraReady,
|
|
19248
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
19249
|
-
microphoneAccessDenied: state.microphoneAccessDenied
|
|
19250
|
-
};
|
|
19251
|
-
})),
|
|
19177
|
+
var _g = React.useContext(CameraStateContext),
|
|
19252
19178
|
cameraReady = _g.cameraReady,
|
|
19253
19179
|
cameraAccessDenied = _g.cameraAccessDenied,
|
|
19254
19180
|
microphoneAccessDenied = _g.microphoneAccessDenied;
|
|
@@ -19465,13 +19391,7 @@
|
|
|
19465
19391
|
livenessCheckRequest = _t.livenessCheckRequest,
|
|
19466
19392
|
setSelfieImage = _t.setSelfieImage,
|
|
19467
19393
|
logSelfieCaptureAttempt = _t.logSelfieCaptureAttempt;
|
|
19468
|
-
var _u =
|
|
19469
|
-
return {
|
|
19470
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
19471
|
-
requestCameraAccess: state.requestCameraAccess,
|
|
19472
|
-
releaseCameraAccess: state.releaseCameraAccess
|
|
19473
|
-
};
|
|
19474
|
-
})),
|
|
19394
|
+
var _u = React.useContext(CameraStateContext),
|
|
19475
19395
|
cameraAccessDenied = _u.cameraAccessDenied,
|
|
19476
19396
|
requestCameraAccess = _u.requestCameraAccess,
|
|
19477
19397
|
releaseCameraAccess = _u.releaseCameraAccess;
|
|
@@ -20960,10 +20880,10 @@
|
|
|
20960
20880
|
setSignatureVideoUrl = _e[1];
|
|
20961
20881
|
var signatureRecorder = React.useRef(null);
|
|
20962
20882
|
var recordedChunks = React.useRef([]);
|
|
20963
|
-
var _f =
|
|
20964
|
-
|
|
20883
|
+
var _f = React.useContext(CameraStateContext),
|
|
20884
|
+
cameraRef = _f.cameraRef,
|
|
20965
20885
|
videoRef = _f.videoRef;
|
|
20966
|
-
var _g = useVideoRecorder(
|
|
20886
|
+
var _g = useVideoRecorder(cameraRef.current),
|
|
20967
20887
|
isRecordingVideo = _g.isRecordingVideo,
|
|
20968
20888
|
startRecordingVideo = _g.startRecordingVideo,
|
|
20969
20889
|
stopRecordingVideo = _g.stopRecordingVideo,
|
|
@@ -21031,8 +20951,8 @@
|
|
|
21031
20951
|
var animationFrame = React.useRef(0);
|
|
21032
20952
|
React.useEffect(function () {
|
|
21033
20953
|
var _a;
|
|
21034
|
-
if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !
|
|
21035
|
-
var _b = [
|
|
20954
|
+
if (!signaturePad.current || !videoRef.current || !outputCanvas.current || !cameraRef.current || !isRecording || !isRecordingVideo) return;
|
|
20955
|
+
var _b = [cameraRef.current.width, cameraRef.current.height],
|
|
21036
20956
|
w = _b[0],
|
|
21037
20957
|
h = _b[1];
|
|
21038
20958
|
var isPortrait = typeof window !== 'undefined' && window.innerWidth < window.innerHeight;
|
|
@@ -21065,7 +20985,7 @@
|
|
|
21065
20985
|
return function () {
|
|
21066
20986
|
cancelAnimationFrame(animationFrame.current);
|
|
21067
20987
|
};
|
|
21068
|
-
}, [
|
|
20988
|
+
}, [cameraRef, isRecording, isRecordingVideo, videoRef]);
|
|
21069
20989
|
var onAcceptClicked = React.useCallback(function () {
|
|
21070
20990
|
return __awaiter(_this, void 0, void 0, function () {
|
|
21071
20991
|
var imageUrl;
|
|
@@ -21194,29 +21114,27 @@
|
|
|
21194
21114
|
var templateObject_1$9, templateObject_2$8, templateObject_3$8, templateObject_4$3, templateObject_5$2, templateObject_6$2, templateObject_7$1;
|
|
21195
21115
|
|
|
21196
21116
|
var VideoSignatureCapture = function VideoSignatureCapture(_a) {
|
|
21197
|
-
var _b;
|
|
21117
|
+
var _b, _c, _d;
|
|
21198
21118
|
var onVideoCaptured = _a.onVideoCaptured,
|
|
21199
21119
|
onFaceNotDetected = _a.onFaceNotDetected,
|
|
21200
21120
|
onExit = _a.onExit,
|
|
21201
21121
|
guidesComponent = _a.guidesComponent,
|
|
21202
|
-
|
|
21203
|
-
classNames =
|
|
21204
|
-
|
|
21205
|
-
colors =
|
|
21206
|
-
|
|
21207
|
-
rawVerbiage =
|
|
21208
|
-
|
|
21209
|
-
debugMode =
|
|
21210
|
-
var
|
|
21211
|
-
return state.camera;
|
|
21212
|
-
});
|
|
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;
|
|
21213
21131
|
var onPredictionMade = React.useContext(SelfieGuidanceModelsContext).onPredictionMade;
|
|
21214
|
-
var
|
|
21215
|
-
signatureData =
|
|
21216
|
-
signatureDataUrl =
|
|
21217
|
-
signatureVideoData =
|
|
21218
|
-
startRecording =
|
|
21219
|
-
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;
|
|
21220
21138
|
React.useEffect(function () {
|
|
21221
21139
|
startRecording();
|
|
21222
21140
|
return function () {
|
|
@@ -21233,9 +21151,9 @@
|
|
|
21233
21151
|
onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(signatureVideoData, signatureData, signatureDataUrl);
|
|
21234
21152
|
}
|
|
21235
21153
|
}, [onVideoCaptured, signatureData, signatureDataUrl, signatureVideoData]);
|
|
21236
|
-
var
|
|
21237
|
-
numFramesWithoutFaces =
|
|
21238
|
-
setNumFramesWithoutFaces =
|
|
21154
|
+
var _k = React.useState(0),
|
|
21155
|
+
numFramesWithoutFaces = _k[0],
|
|
21156
|
+
setNumFramesWithoutFaces = _k[1];
|
|
21239
21157
|
React.useEffect(function () {
|
|
21240
21158
|
onPredictionMade(function (_a) {
|
|
21241
21159
|
var face = _a.face;
|
|
@@ -21262,7 +21180,7 @@
|
|
|
21262
21180
|
}, verbiage.guidanceMessageText))), /*#__PURE__*/React.createElement(GuidesComponent, {
|
|
21263
21181
|
classNames: classNames.videoSignatureGuidesClassNames,
|
|
21264
21182
|
status: "success"
|
|
21265
|
-
}), 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, {
|
|
21266
21184
|
onClick: onExit,
|
|
21267
21185
|
className: classNames.exitCaptureBtn
|
|
21268
21186
|
}));
|
|
@@ -21356,13 +21274,7 @@
|
|
|
21356
21274
|
setSignatureData = _l.setSignatureData,
|
|
21357
21275
|
setSignatureVideoUrl = _l.setSignatureVideoUrl,
|
|
21358
21276
|
logSelfieCaptureAttempt = _l.logSelfieCaptureAttempt;
|
|
21359
|
-
var _m =
|
|
21360
|
-
return {
|
|
21361
|
-
cameraAccessDenied: state.cameraAccessDenied,
|
|
21362
|
-
requestCameraAccess: state.requestCameraAccess,
|
|
21363
|
-
releaseCameraAccess: state.releaseCameraAccess
|
|
21364
|
-
};
|
|
21365
|
-
})),
|
|
21277
|
+
var _m = React.useContext(CameraStateContext),
|
|
21366
21278
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
21367
21279
|
requestCameraAccess = _m.requestCameraAccess,
|
|
21368
21280
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
@@ -21522,29 +21434,27 @@
|
|
|
21522
21434
|
};
|
|
21523
21435
|
|
|
21524
21436
|
var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
|
|
21525
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
21526
|
-
var
|
|
21527
|
-
requestedAction =
|
|
21528
|
-
|
|
21529
|
-
satisfied =
|
|
21530
|
-
|
|
21531
|
-
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,
|
|
21532
21444
|
faceGuideBorderWidth = _a.faceGuideBorderWidth,
|
|
21533
21445
|
faceGuideBorderColor = _a.faceGuideBorderColor,
|
|
21534
|
-
|
|
21535
|
-
idCardGuideStatus =
|
|
21446
|
+
_3 = _a.idCardGuideStatus,
|
|
21447
|
+
idCardGuideStatus = _3 === void 0 ? 'ready' : _3,
|
|
21536
21448
|
idCardGuideBorderWidth = _a.idCardGuideBorderWidth,
|
|
21537
21449
|
idCardGuideBorderColor = _a.idCardGuideBorderColor,
|
|
21538
21450
|
idCardCaptureProgress = _a.idCardCaptureProgress,
|
|
21539
|
-
|
|
21540
|
-
userSuppliedImages =
|
|
21541
|
-
|
|
21542
|
-
classNames =
|
|
21543
|
-
|
|
21544
|
-
rawVerbiage =
|
|
21545
|
-
var
|
|
21546
|
-
return state.isRearFacing;
|
|
21547
|
-
});
|
|
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;
|
|
21548
21458
|
var verbiage = useTranslations(rawVerbiage, {
|
|
21549
21459
|
idFrontInstructionText: 'Display the front of your ID card...',
|
|
21550
21460
|
idBackInstructionText: 'Display the back of your ID card...',
|
|
@@ -21557,17 +21467,17 @@
|
|
|
21557
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';
|
|
21558
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;
|
|
21559
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';
|
|
21560
|
-
var
|
|
21561
|
-
idCardGuideRef =
|
|
21562
|
-
|
|
21563
|
-
idCardGuideWidth =
|
|
21564
|
-
|
|
21565
|
-
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;
|
|
21566
21476
|
var idCaptureGuideImages = useGuideImages(userSuppliedImages);
|
|
21567
21477
|
var idCaptureGuideImagesByUrl = useGuideImagesByUrl(idCaptureGuideImages);
|
|
21568
|
-
var
|
|
21569
|
-
aspectRatio =
|
|
21570
|
-
setAspectRatio =
|
|
21478
|
+
var _10 = React.useState(undefined),
|
|
21479
|
+
aspectRatio = _10[0],
|
|
21480
|
+
setAspectRatio = _10[1];
|
|
21571
21481
|
var onImageLoaded = React.useCallback(function (e) {
|
|
21572
21482
|
var _a, _b, _c, _d;
|
|
21573
21483
|
var img = e.currentTarget;
|
|
@@ -21614,7 +21524,7 @@
|
|
|
21614
21524
|
}, /*#__PURE__*/React.createElement(IdCardGuideImage, {
|
|
21615
21525
|
alt: "",
|
|
21616
21526
|
className: classNames.idCardGuideImage,
|
|
21617
|
-
"$isMirrored": !isRearFacing,
|
|
21527
|
+
"$isMirrored": !((_v = cameraRef.current) === null || _v === void 0 ? void 0 : _v.isRearFacing),
|
|
21618
21528
|
style: idCardImageStyle,
|
|
21619
21529
|
src: requestedAction === 'SHOW_ID_BACK' ? idCaptureGuideImages.landscape.SHOW_ID_BACK.url : idCaptureGuideImages.landscape.SHOW_ID_FRONT.url,
|
|
21620
21530
|
onLoad: onImageLoaded
|
|
@@ -21628,8 +21538,8 @@
|
|
|
21628
21538
|
className: classNames.idCardGuideInstructionsContainer
|
|
21629
21539
|
}, /*#__PURE__*/React.createElement(IdCardGuideInstructions, {
|
|
21630
21540
|
className: classNames.idCardGuideInstructions,
|
|
21631
|
-
"$textColor": (
|
|
21632
|
-
"$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
|
|
21633
21543
|
}, instructionText))))));
|
|
21634
21544
|
};
|
|
21635
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) {
|
|
@@ -21774,100 +21684,99 @@
|
|
|
21774
21684
|
flipShortcutThreshold: 0.7
|
|
21775
21685
|
};
|
|
21776
21686
|
var IdVideoCapture = function IdVideoCapture(_a) {
|
|
21777
|
-
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;
|
|
21778
21688
|
var onComplete = _a.onComplete,
|
|
21779
21689
|
onIdFrontImageCaptured = _a.onIdFrontImageCaptured,
|
|
21780
21690
|
onIdBackImageCaptured = _a.onIdBackImageCaptured,
|
|
21781
21691
|
onFaceNotDetected = _a.onFaceNotDetected,
|
|
21782
21692
|
onRecordingFailed = _a.onRecordingFailed,
|
|
21783
21693
|
onExitCapture = _a.onExitCapture,
|
|
21784
|
-
|
|
21785
|
-
idCaptureModelsEnabled =
|
|
21786
|
-
|
|
21787
|
-
idCardCaptureGuideImages =
|
|
21788
|
-
|
|
21789
|
-
idCardFrontDelay =
|
|
21790
|
-
|
|
21791
|
-
videoIdCaptureThresholds =
|
|
21792
|
-
|
|
21793
|
-
skipShowIdCardBack =
|
|
21794
|
-
|
|
21795
|
-
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,
|
|
21796
21706
|
readTextPrompt = _a.readTextPrompt,
|
|
21797
|
-
|
|
21798
|
-
readTextTimeoutDurationMs =
|
|
21799
|
-
|
|
21800
|
-
readTextMinReadingMs =
|
|
21801
|
-
|
|
21802
|
-
disableFaceDetectionWhileAudioCapture =
|
|
21803
|
-
|
|
21804
|
-
disableFaceDetectionWhileAudioCaptureMsDelay =
|
|
21805
|
-
|
|
21806
|
-
mergeAVStreams =
|
|
21807
|
-
|
|
21808
|
-
classNames =
|
|
21809
|
-
|
|
21810
|
-
colors =
|
|
21811
|
-
|
|
21812
|
-
rawVerbiage =
|
|
21813
|
-
|
|
21814
|
-
debugMode =
|
|
21815
|
-
var
|
|
21816
|
-
ref =
|
|
21817
|
-
|
|
21818
|
-
width =
|
|
21819
|
-
|
|
21820
|
-
height =
|
|
21821
|
-
var
|
|
21822
|
-
|
|
21823
|
-
videoRef =
|
|
21824
|
-
videoLoaded =
|
|
21825
|
-
cameraReady =
|
|
21826
|
-
microphoneReady =
|
|
21827
|
-
audioStream =
|
|
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
|
-
|
|
21863
|
-
|
|
21864
|
-
|
|
21865
|
-
|
|
21866
|
-
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;
|
|
21867
21776
|
var countdownTimeoutRef = React.useRef(undefined);
|
|
21868
|
-
var
|
|
21869
|
-
countdownRemaining =
|
|
21870
|
-
setCountdownRemaining =
|
|
21777
|
+
var _23 = React.useState(-1),
|
|
21778
|
+
countdownRemaining = _23[0],
|
|
21779
|
+
setCountdownRemaining = _23[1];
|
|
21871
21780
|
React.useEffect(function () {
|
|
21872
21781
|
if (!isRecordingVideo && !videoUrl) {
|
|
21873
21782
|
startRecordingVideo();
|
|
@@ -21878,24 +21787,24 @@
|
|
|
21878
21787
|
var needsAudio = !!readTextPrompt && !mergeAVStreams;
|
|
21879
21788
|
var audioReady = !needsAudio || audioUrl;
|
|
21880
21789
|
if (videoUrl && audioReady) {
|
|
21881
|
-
|
|
21790
|
+
setVideoLoaded(false);
|
|
21882
21791
|
onComplete === null || onComplete === void 0 ? void 0 : onComplete(videoUrl, audioUrl);
|
|
21883
21792
|
}
|
|
21884
|
-
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt,
|
|
21793
|
+
}, [audioUrl, isRecordingVideo, mergeAVStreams, onComplete, readTextPrompt, setVideoLoaded, startRecordingVideo, videoUrl]);
|
|
21885
21794
|
React.useEffect(function () {
|
|
21886
|
-
if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped
|
|
21795
|
+
if (videoRecordingUnintentionallyStopped || audioRecordingUnintentionallyStopped) {
|
|
21887
21796
|
onRecordingFailed === null || onRecordingFailed === void 0 ? void 0 : onRecordingFailed();
|
|
21888
21797
|
}
|
|
21889
|
-
}, [audioRecordingUnintentionallyStopped,
|
|
21890
|
-
var
|
|
21891
|
-
requestedAction =
|
|
21892
|
-
setRequestedAction =
|
|
21798
|
+
}, [audioRecordingUnintentionallyStopped, onRecordingFailed, videoRecordingUnintentionallyStopped]);
|
|
21799
|
+
var _24 = React.useState('SHOW_ID_FRONT'),
|
|
21800
|
+
requestedAction = _24[0],
|
|
21801
|
+
setRequestedAction = _24[1];
|
|
21893
21802
|
var shouldRunIdModels = idCaptureModelsEnabled && videoLoaded && cameraReady && idModelsReady && !idModelError && requestedAction !== 'READ_TEXT' && (!readTextPrompt || microphoneReady);
|
|
21894
21803
|
React.useEffect(function startModelsWhenCapturing() {
|
|
21895
21804
|
if (!shouldRunIdModels) return;
|
|
21896
21805
|
startIdModels();
|
|
21897
21806
|
return function () {
|
|
21898
|
-
|
|
21807
|
+
stopIdModels();
|
|
21899
21808
|
};
|
|
21900
21809
|
}, [shouldRunIdModels, startIdModels, stopIdModels]);
|
|
21901
21810
|
React.useEffect(function () {
|
|
@@ -21909,18 +21818,18 @@
|
|
|
21909
21818
|
bottom: 1
|
|
21910
21819
|
});
|
|
21911
21820
|
}, [setDocumentDetectionBoundaries]);
|
|
21912
|
-
var
|
|
21913
|
-
currentDetectionScore =
|
|
21914
|
-
setCurrentDetectionScore =
|
|
21915
|
-
var
|
|
21916
|
-
currentDetectedDocumentType =
|
|
21917
|
-
setCurrentDetectedDocumentType =
|
|
21918
|
-
var _26 = React.useState(0),
|
|
21919
|
-
currentFocusScore = _26[0],
|
|
21920
|
-
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];
|
|
21921
21827
|
var _27 = React.useState(0),
|
|
21922
|
-
|
|
21923
|
-
|
|
21828
|
+
currentFocusScore = _27[0],
|
|
21829
|
+
setCurrentFocusScore = _27[1];
|
|
21830
|
+
var _28 = React.useState(0),
|
|
21831
|
+
goodFramesCount = _28[0],
|
|
21832
|
+
setGoodFramesCount = _28[1];
|
|
21924
21833
|
var goodFramesThreshold = requestedAction === 'SHOW_ID_FRONT' ? videoIdCaptureThresholds.goodFrames.idCardFront : videoIdCaptureThresholds.goodFrames.idCardBack;
|
|
21925
21834
|
var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
|
|
21926
21835
|
React.useEffect(function () {
|
|
@@ -21941,9 +21850,9 @@
|
|
|
21941
21850
|
} : 0);
|
|
21942
21851
|
});
|
|
21943
21852
|
}, [idCaptureModelsEnabled, onIdPredictionMade, idModelError, requestedAction, videoIdCaptureThresholds.flipShortcutThreshold]);
|
|
21944
|
-
var
|
|
21945
|
-
idFrontCaptureStartedAt =
|
|
21946
|
-
setFirstGoodFrameTime =
|
|
21853
|
+
var _29 = React.useState(null),
|
|
21854
|
+
idFrontCaptureStartedAt = _29[0],
|
|
21855
|
+
setFirstGoodFrameTime = _29[1];
|
|
21947
21856
|
React.useEffect(function () {
|
|
21948
21857
|
if (goodFramesCount === 1) setFirstGoodFrameTime(new Date().getTime());
|
|
21949
21858
|
}, [goodFramesCount]);
|
|
@@ -21964,9 +21873,9 @@
|
|
|
21964
21873
|
var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
|
|
21965
21874
|
var faceBox = face === null || face === void 0 ? void 0 : face.box;
|
|
21966
21875
|
var faceCentered = !faceBox || !frameWidth || faceBox.xMin > frameWidth * edgeBoundary && faceBox.yMin > frameHeight * edgeBoundary && faceBox.xMax < frameWidth * (1 - edgeBoundary) && faceBox.yMax < frameHeight * (1 - edgeBoundary);
|
|
21967
|
-
var
|
|
21968
|
-
countdownStartedAt =
|
|
21969
|
-
setCountdownStartedAt =
|
|
21876
|
+
var _30 = React.useState(),
|
|
21877
|
+
countdownStartedAt = _30[0],
|
|
21878
|
+
setCountdownStartedAt = _30[1];
|
|
21970
21879
|
var photoCanvas = React.useRef(null);
|
|
21971
21880
|
var frameLock = React.useRef(false);
|
|
21972
21881
|
var captureFrame = React.useCallback(function () {
|
|
@@ -22089,9 +21998,9 @@
|
|
|
22089
21998
|
stopSelfieGuidance();
|
|
22090
21999
|
};
|
|
22091
22000
|
}, [startSelfieGuidance, stopSelfieGuidance]);
|
|
22092
|
-
var
|
|
22093
|
-
numFramesWithoutFaces =
|
|
22094
|
-
setNumFramesWithoutFaces =
|
|
22001
|
+
var _31 = React.useState(0),
|
|
22002
|
+
numFramesWithoutFaces = _31[0],
|
|
22003
|
+
setNumFramesWithoutFaces = _31[1];
|
|
22095
22004
|
onSelfiePredictionMade(f(React.useCallback(function (_a) {
|
|
22096
22005
|
var face = _a.face;
|
|
22097
22006
|
if (selfieModelError) return;
|
|
@@ -22107,12 +22016,12 @@
|
|
|
22107
22016
|
}
|
|
22108
22017
|
}, [disableFaceDetectionWhileAudioCapture, disableFaceDetectionWhileAudioCaptureMsDelay, numFramesWithoutFaces, onFaceNotDetected, timeoutStartedAt]);
|
|
22109
22018
|
var theme = styled.useTheme();
|
|
22110
|
-
var
|
|
22019
|
+
var _32 = useTranslations(rawVerbiage, {
|
|
22111
22020
|
faceNotCenteredText: 'Please move your face to the center...',
|
|
22112
22021
|
captureBtnText: 'Capture'
|
|
22113
22022
|
}),
|
|
22114
|
-
captureBtnText =
|
|
22115
|
-
faceNotCenteredText =
|
|
22023
|
+
captureBtnText = _32.captureBtnText,
|
|
22024
|
+
faceNotCenteredText = _32.faceNotCenteredText;
|
|
22116
22025
|
var debugScalingDetails = useDebugScalingDetails({
|
|
22117
22026
|
enabled: debugMode,
|
|
22118
22027
|
pageWidth: width,
|
|
@@ -22121,6 +22030,8 @@
|
|
|
22121
22030
|
videoHeight: (_j = (_h = videoRef.current) === null || _h === void 0 ? void 0 : _h.videoHeight) !== null && _j !== void 0 ? _j : 0
|
|
22122
22031
|
});
|
|
22123
22032
|
var capturingId = ['SHOW_ID_FRONT', 'SHOW_ID_BACK'].includes(requestedAction);
|
|
22033
|
+
// const searchingForIdCard =
|
|
22034
|
+
// idCaptureModelsEnabled && capturingId && !goodFramesThresholdMet
|
|
22124
22035
|
var guidanceText = !faceCentered ? faceNotCenteredText : undefined;
|
|
22125
22036
|
return /*#__PURE__*/React.createElement(PageContainer, {
|
|
22126
22037
|
ref: ref,
|
|
@@ -22146,14 +22057,15 @@
|
|
|
22146
22057
|
faceGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor,
|
|
22147
22058
|
idCardGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor
|
|
22148
22059
|
}), debugMode && capturingId && ( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ObjectDetectionDebugOverlayDiv, {
|
|
22149
|
-
"$flipX": !isRearFacing
|
|
22060
|
+
"$flipX": !((_l = cameraRef.current) === null || _l === void 0 ? void 0 : _l.isRearFacing)
|
|
22150
22061
|
}, detectedObjects.map(function (obj, i) {
|
|
22062
|
+
var _a;
|
|
22151
22063
|
return /*#__PURE__*/React.createElement(IdCaptureDetectedObjectDebugBox, {
|
|
22152
22064
|
key: i,
|
|
22153
22065
|
obj: obj,
|
|
22154
22066
|
scaling: debugScalingDetails,
|
|
22155
22067
|
color: "blue",
|
|
22156
|
-
flipX: !isRearFacing
|
|
22068
|
+
flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing)
|
|
22157
22069
|
});
|
|
22158
22070
|
})), /*#__PURE__*/React.createElement(DebugBoundingBoxOverlay, null, face && ( /*#__PURE__*/React.createElement(SelfieCaptureFaceDebugBox, {
|
|
22159
22071
|
face: face,
|
|
@@ -22162,9 +22074,9 @@
|
|
|
22162
22074
|
className: classNames.guidanceMessageContainer
|
|
22163
22075
|
}, /*#__PURE__*/React.createElement(GuidanceMessage, {
|
|
22164
22076
|
className: classNames.guidanceMessage,
|
|
22165
|
-
"$background": (
|
|
22166
|
-
"$textColor": (
|
|
22167
|
-
}, 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, {
|
|
22168
22080
|
className: classNames.countdownContainer
|
|
22169
22081
|
}, /*#__PURE__*/React.createElement(Countdown, {
|
|
22170
22082
|
className: classNames.countdown
|
|
@@ -22173,7 +22085,7 @@
|
|
|
22173
22085
|
}, /*#__PURE__*/React.createElement(CaptureButton, {
|
|
22174
22086
|
finished: true,
|
|
22175
22087
|
onClick: function onClick() {
|
|
22176
|
-
|
|
22088
|
+
setCountdownStartedAt(new Date());
|
|
22177
22089
|
},
|
|
22178
22090
|
disabled: !!countdownStartedAt || frameLock.current,
|
|
22179
22091
|
className: classNames.captureBtn
|
|
@@ -22461,14 +22373,16 @@
|
|
|
22461
22373
|
className: "flex"
|
|
22462
22374
|
}, /*#__PURE__*/React.createElement(Spinner$1, null));
|
|
22463
22375
|
}
|
|
22464
|
-
return /*#__PURE__*/React.createElement(
|
|
22465
|
-
|
|
22376
|
+
return /*#__PURE__*/React.createElement(CameraProvider, {
|
|
22377
|
+
key: "".concat(isCapturingId ? 'id' : 'selfie', "-camera-").concat(attempt),
|
|
22378
|
+
preferContinuityCamera: isCapturingId,
|
|
22466
22379
|
preferFrontFacingCamera: !isCapturingId,
|
|
22467
22380
|
requireMicrophoneAccess: !isCapturingId && !!readTextPrompt,
|
|
22468
22381
|
maxVideoWidth: isCapturingId ? 1920 : 1280,
|
|
22469
22382
|
maxFps: isCapturingId ? 60 : 30,
|
|
22470
22383
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
22471
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
22384
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
22385
|
+
debugMode: debugMode
|
|
22472
22386
|
}, /*#__PURE__*/React.createElement(IdCaptureModelsProvider, {
|
|
22473
22387
|
autoStart: false,
|
|
22474
22388
|
documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
|
|
@@ -22479,7 +22393,7 @@
|
|
|
22479
22393
|
autoStart: false,
|
|
22480
22394
|
onModelError: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onModelError,
|
|
22481
22395
|
modelLoadTimeoutMs: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.modelLoadTimeoutMs,
|
|
22482
|
-
requireVerticalFaceCentering:
|
|
22396
|
+
requireVerticalFaceCentering: captureState === 'CHECKING_LIVENESS'
|
|
22483
22397
|
}, /*#__PURE__*/React.createElement(PageContainer, {
|
|
22484
22398
|
className: "flex ".concat((_k = classNames.container) !== null && _k !== void 0 ? _k : '')
|
|
22485
22399
|
}, ['CHECKING_LIVENESS', 'CAPTURING_VIDEO'].includes(captureState) && /*#__PURE__*/React.createElement(CameraVideoTag, {
|
|
@@ -22594,15 +22508,17 @@
|
|
|
22594
22508
|
_o = _a.captureSignatureVideo,
|
|
22595
22509
|
captureSignatureVideo = _o === void 0 ? false : _o,
|
|
22596
22510
|
onCameraAccessDenied = _a.onCameraAccessDenied,
|
|
22597
|
-
onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied
|
|
22598
|
-
|
|
22599
|
-
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22603
|
-
|
|
22604
|
-
|
|
22605
|
-
|
|
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];
|
|
22606
22522
|
var checks = React.useMemo(function () {
|
|
22607
22523
|
var _a, _b;
|
|
22608
22524
|
var checks = __spreadArray([], userChecks, true);
|
|
@@ -22680,6 +22596,16 @@
|
|
|
22680
22596
|
return i + 1;
|
|
22681
22597
|
});
|
|
22682
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]);
|
|
22683
22609
|
var onAdditionalDocumentCaptureCompleteProp = additionalDocumentCaptureProps === null || additionalDocumentCaptureProps === void 0 ? void 0 : additionalDocumentCaptureProps.onComplete;
|
|
22684
22610
|
var onAdditionalDocumentCaptureComplete = React.useCallback(function (uploadedDocuments) {
|
|
22685
22611
|
setAdditionalDocuments(uploadedDocuments);
|
|
@@ -22708,9 +22634,11 @@
|
|
|
22708
22634
|
}
|
|
22709
22635
|
switch (checks[checkIndex]) {
|
|
22710
22636
|
case 'IdCapture':
|
|
22711
|
-
return /*#__PURE__*/React.createElement(
|
|
22637
|
+
return /*#__PURE__*/React.createElement(CameraProvider, {
|
|
22638
|
+
key: "IdCaptureCamera",
|
|
22712
22639
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
22713
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
22640
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
22641
|
+
debugMode: debugMode
|
|
22714
22642
|
}, /*#__PURE__*/React.createElement(IdCaptureModelsProvider, {
|
|
22715
22643
|
autoStart: false,
|
|
22716
22644
|
documentDetectionModelUrl: (_d = (_c = idCaptureProps.assets) === null || _c === void 0 ? void 0 : _c.documentDetectionModelUrl) !== null && _d !== void 0 ? _d : '',
|
|
@@ -22727,11 +22655,13 @@
|
|
|
22727
22655
|
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
22728
22656
|
}));
|
|
22729
22657
|
case 'FaceLiveness':
|
|
22730
|
-
return /*#__PURE__*/React.createElement(
|
|
22658
|
+
return /*#__PURE__*/React.createElement(CameraProvider, {
|
|
22659
|
+
key: "FaceLivenessCamera",
|
|
22731
22660
|
preferFrontFacingCamera: true,
|
|
22732
|
-
|
|
22661
|
+
preferContinuityCamera: false,
|
|
22733
22662
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
22734
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
22663
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
22664
|
+
debugMode: debugMode
|
|
22735
22665
|
}, /*#__PURE__*/React.createElement(SelfieGuidanceModelsProvider, {
|
|
22736
22666
|
autoStart: false,
|
|
22737
22667
|
onModelError: faceLivenessProps.onModelError,
|
|
@@ -22744,13 +22674,15 @@
|
|
|
22744
22674
|
onAccept: onSignatureCaptureSuccess
|
|
22745
22675
|
}));
|
|
22746
22676
|
case 'VideoSignatureCapture':
|
|
22747
|
-
return /*#__PURE__*/React.createElement(
|
|
22748
|
-
|
|
22677
|
+
return /*#__PURE__*/React.createElement(CameraProvider, {
|
|
22678
|
+
key: "SignatureKycCamera-".concat(videoSignatureAttempts),
|
|
22679
|
+
preferContinuityCamera: false,
|
|
22749
22680
|
preferFrontFacingCamera: true,
|
|
22750
22681
|
maxVideoWidth: 1280,
|
|
22751
22682
|
maxFps: 30,
|
|
22752
22683
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
22753
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
22684
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
22685
|
+
debugMode: debugMode
|
|
22754
22686
|
}, /*#__PURE__*/React.createElement(SelfieGuidanceModelsProvider, {
|
|
22755
22687
|
autoStart: false,
|
|
22756
22688
|
throttleMs: 250,
|
|
@@ -22758,7 +22690,8 @@
|
|
|
22758
22690
|
modelLoadTimeoutMs: videoSignatureCaptureProps.modelLoadTimeoutMs,
|
|
22759
22691
|
requireVerticalFaceCentering: false
|
|
22760
22692
|
}, /*#__PURE__*/React.createElement(VideoSignatureWizard, _assign({}, videoSignatureCaptureProps, {
|
|
22761
|
-
onComplete: onVideoSignatureComplete
|
|
22693
|
+
onComplete: onVideoSignatureComplete,
|
|
22694
|
+
onRetryClicked: onVideoSignatureRetry
|
|
22762
22695
|
}))));
|
|
22763
22696
|
case 'AdditionalDocumentCapture':
|
|
22764
22697
|
return /*#__PURE__*/React.createElement(AdditionalDocumentCaptureWizard, _assign({}, additionalDocumentCaptureProps, {
|
|
@@ -23209,7 +23142,8 @@
|
|
|
23209
23142
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
23210
23143
|
captureSignature: captureSignature,
|
|
23211
23144
|
captureSignatureVideo: captureSignatureVideo,
|
|
23212
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
23145
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
23146
|
+
debugMode: debugMode
|
|
23213
23147
|
}))));
|
|
23214
23148
|
};
|
|
23215
23149
|
|
|
@@ -23315,7 +23249,8 @@
|
|
|
23315
23249
|
return ['FaceLiveness'];
|
|
23316
23250
|
}, []),
|
|
23317
23251
|
faceLivenessProps: faceLivenessProps,
|
|
23318
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
23252
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
23253
|
+
debugMode: debugMode
|
|
23319
23254
|
}))));
|
|
23320
23255
|
};
|
|
23321
23256
|
|
|
@@ -23548,7 +23483,8 @@
|
|
|
23548
23483
|
additionalDocumentCaptureProps: additionalDocumentCaptureProps,
|
|
23549
23484
|
captureSignature: captureSignature,
|
|
23550
23485
|
captureSignatureVideo: captureSignatureVideo,
|
|
23551
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
23486
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
23487
|
+
debugMode: debugMode
|
|
23552
23488
|
}))));
|
|
23553
23489
|
};
|
|
23554
23490
|
|
|
@@ -23803,7 +23739,8 @@
|
|
|
23803
23739
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
23804
23740
|
captureSignature: captureSignature,
|
|
23805
23741
|
captureSignatureVideo: captureSignatureVideo,
|
|
23806
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
23742
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
23743
|
+
debugMode: debugMode
|
|
23807
23744
|
}))));
|
|
23808
23745
|
};
|
|
23809
23746
|
|
|
@@ -24135,7 +24072,7 @@
|
|
|
24135
24072
|
var _l = React.useState('LOADING'),
|
|
24136
24073
|
captureState = _l[0],
|
|
24137
24074
|
setCaptureState = _l[1];
|
|
24138
|
-
var _m =
|
|
24075
|
+
var _m = React.useContext(CameraStateContext),
|
|
24139
24076
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
24140
24077
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
24141
24078
|
var _o = React.useContext(SelfieGuidanceModelsContext),
|
|
@@ -24341,9 +24278,10 @@
|
|
|
24341
24278
|
onSubmit: onSubmit,
|
|
24342
24279
|
geolocationEnabled: geolocationEnabled,
|
|
24343
24280
|
geolocationRequired: geolocationRequired
|
|
24344
|
-
}, /*#__PURE__*/React.createElement(
|
|
24281
|
+
}, /*#__PURE__*/React.createElement(CameraProvider, {
|
|
24345
24282
|
preferFrontFacingCamera: true,
|
|
24346
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
24283
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
24284
|
+
debugMode: debugMode
|
|
24347
24285
|
}, /*#__PURE__*/React.createElement(SelfieGuidanceModelsProvider, {
|
|
24348
24286
|
autoStart: false,
|
|
24349
24287
|
onModelError: onModelError,
|
|
@@ -24692,7 +24630,7 @@
|
|
|
24692
24630
|
var _l = React.useState('LOADING'),
|
|
24693
24631
|
captureState = _l[0],
|
|
24694
24632
|
setCaptureState = _l[1];
|
|
24695
|
-
var _m =
|
|
24633
|
+
var _m = React.useContext(CameraStateContext),
|
|
24696
24634
|
cameraAccessDenied = _m.cameraAccessDenied,
|
|
24697
24635
|
releaseCameraAccess = _m.releaseCameraAccess;
|
|
24698
24636
|
var _o = React.useContext(SelfieGuidanceModelsContext),
|
|
@@ -24896,9 +24834,10 @@
|
|
|
24896
24834
|
onSubmit: onSubmit,
|
|
24897
24835
|
geolocationEnabled: geolocationEnabled,
|
|
24898
24836
|
geolocationRequired: geolocationRequired
|
|
24899
|
-
}, /*#__PURE__*/React.createElement(
|
|
24837
|
+
}, /*#__PURE__*/React.createElement(CameraProvider, {
|
|
24900
24838
|
preferFrontFacingCamera: true,
|
|
24901
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
24839
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
24840
|
+
debugMode: debugMode
|
|
24902
24841
|
}, /*#__PURE__*/React.createElement(SelfieGuidanceModelsProvider, {
|
|
24903
24842
|
autoStart: false,
|
|
24904
24843
|
modelLoadTimeoutMs: modelLoadTimeoutMs,
|
|
@@ -25225,7 +25164,8 @@
|
|
|
25225
25164
|
captureSignature: captureSignature,
|
|
25226
25165
|
captureSignatureVideo: captureSignatureVideo,
|
|
25227
25166
|
onCameraAccessDenied: onCameraAccessDenied,
|
|
25228
|
-
onMicrophoneAccessDenied: onMicrophoneAccessDenied
|
|
25167
|
+
onMicrophoneAccessDenied: onMicrophoneAccessDenied,
|
|
25168
|
+
debugMode: debugMode
|
|
25229
25169
|
}))));
|
|
25230
25170
|
};
|
|
25231
25171
|
|
|
@@ -25382,7 +25322,8 @@
|
|
|
25382
25322
|
videoSignatureCaptureProps: videoSignatureCaptureProps,
|
|
25383
25323
|
captureSignature: captureSignature,
|
|
25384
25324
|
captureSignatureVideo: captureSignatureVideo,
|
|
25385
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
25325
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
25326
|
+
debugMode: debugMode
|
|
25386
25327
|
}))));
|
|
25387
25328
|
};
|
|
25388
25329
|
|
|
@@ -25440,10 +25381,11 @@
|
|
|
25440
25381
|
onDocumentUploadFailed: onDocumentUploadFailed,
|
|
25441
25382
|
geolocationEnabled: geolocationEnabled,
|
|
25442
25383
|
geolocationRequired: geolocationRequired
|
|
25443
|
-
}, /*#__PURE__*/React.createElement(
|
|
25384
|
+
}, /*#__PURE__*/React.createElement(CameraProvider, {
|
|
25444
25385
|
requestAccessAutomatically: false,
|
|
25445
|
-
|
|
25446
|
-
onCameraAccessDenied: onCameraAccessDenied
|
|
25386
|
+
preferContinuityCamera: true,
|
|
25387
|
+
onCameraAccessDenied: onCameraAccessDenied,
|
|
25388
|
+
debugMode: debugMode
|
|
25447
25389
|
}, /*#__PURE__*/React.createElement(DocumentCaptureWizard, {
|
|
25448
25390
|
onSuccess: onComplete,
|
|
25449
25391
|
onExitCapture: onExitCapture,
|