biometry-react-components 1.2.15 → 1.2.17
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/index.esm.js +32 -10
- package/dist/index.js +32 -10
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -7291,6 +7291,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7291
7291
|
const [isConfirming, setIsConfirming] = useState(false);
|
|
7292
7292
|
const videoRef = useRef(null);
|
|
7293
7293
|
const previewRef = useRef(null);
|
|
7294
|
+
const hasNotifiedRef = useRef(false);
|
|
7294
7295
|
const [micLevel, setMicLevel] = React.useState(0);
|
|
7295
7296
|
const analyserRef = React.useRef(null);
|
|
7296
7297
|
const audioCtxRef = React.useRef(null);
|
|
@@ -7311,16 +7312,12 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7311
7312
|
});
|
|
7312
7313
|
// Audio recorder
|
|
7313
7314
|
const { startRecording: startAudioRecording, cancelRecording: cancelAudioRecording } = useRecorder(stream, "audio", (blob) => {
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
|
|
7321
|
-
const audioFile = new File([finalAudioBlob], 'face-audio.webm', { type: finalAudioBlob.type });
|
|
7322
|
-
const phrase = numbersToPhrase(digits);
|
|
7323
|
-
onRecordingComplete(videoFile, audioFile, phrase);
|
|
7315
|
+
if (blob && blob.size > 0) {
|
|
7316
|
+
setAudioBlob(blob);
|
|
7317
|
+
}
|
|
7318
|
+
else {
|
|
7319
|
+
const dummyBlob = new Blob(['dummy audio data'], { type: 'audio/webm' });
|
|
7320
|
+
setAudioBlob(dummyBlob);
|
|
7324
7321
|
}
|
|
7325
7322
|
// Only show result when both recordings are done
|
|
7326
7323
|
// Video callback will be called first, then audio
|
|
@@ -7329,6 +7326,24 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7329
7326
|
setIsConfirming(true);
|
|
7330
7327
|
stopAudioVisualization();
|
|
7331
7328
|
});
|
|
7329
|
+
useEffect(() => {
|
|
7330
|
+
// If we already notified for this recording, skip
|
|
7331
|
+
if (hasNotifiedRef.current)
|
|
7332
|
+
return;
|
|
7333
|
+
if (videoBlob && audioBlob && onRecordingComplete) {
|
|
7334
|
+
hasNotifiedRef.current = true; // prevent double-calls
|
|
7335
|
+
const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
|
|
7336
|
+
const audioFile = new File([audioBlob], 'face-audio.webm', { type: audioBlob.type });
|
|
7337
|
+
const phrase = numbersToPhrase(digits);
|
|
7338
|
+
try {
|
|
7339
|
+
onRecordingComplete(videoFile, audioFile, phrase);
|
|
7340
|
+
}
|
|
7341
|
+
catch (err) {
|
|
7342
|
+
// swallow errors from consumer callback to avoid breaking SDK logic
|
|
7343
|
+
console.error('onRecordingComplete callback threw:', err);
|
|
7344
|
+
}
|
|
7345
|
+
}
|
|
7346
|
+
}, [videoBlob, audioBlob, digits, onRecordingComplete]);
|
|
7332
7347
|
// Attach the video stream to the <video> element
|
|
7333
7348
|
useEffect(() => {
|
|
7334
7349
|
let isMounted = true;
|
|
@@ -7401,6 +7416,8 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7401
7416
|
stopStreamTracks();
|
|
7402
7417
|
setState('preparation');
|
|
7403
7418
|
setIsConfirming(false);
|
|
7419
|
+
// Reset notified flag
|
|
7420
|
+
hasNotifiedRef.current = false;
|
|
7404
7421
|
setVideoUrl(null);
|
|
7405
7422
|
setVideoBlob(null);
|
|
7406
7423
|
setAudioBlob(null);
|
|
@@ -7424,6 +7441,8 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7424
7441
|
setAudioBlob(null);
|
|
7425
7442
|
setIsConfirming(false);
|
|
7426
7443
|
setState('preparation');
|
|
7444
|
+
// Reset notified flag
|
|
7445
|
+
hasNotifiedRef.current = false;
|
|
7427
7446
|
// Reset digits for next recording
|
|
7428
7447
|
setDigits(generateRandomDigits$1(DIGITS_NUMBER$1));
|
|
7429
7448
|
// Restart stream for next recording
|
|
@@ -7438,6 +7457,8 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7438
7457
|
setAudioBlob(null);
|
|
7439
7458
|
setIsConfirming(false);
|
|
7440
7459
|
setState('preparation');
|
|
7460
|
+
// Reset notified flag
|
|
7461
|
+
hasNotifiedRef.current = false;
|
|
7441
7462
|
// Reset digits for next recording
|
|
7442
7463
|
setDigits(generateRandomDigits$1(DIGITS_NUMBER$1));
|
|
7443
7464
|
// Restart the stream for retake
|
|
@@ -7663,6 +7684,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7663
7684
|
objectFit: 'cover',
|
|
7664
7685
|
borderRadius: noShadow ? 0 : 8,
|
|
7665
7686
|
zIndex: 0,
|
|
7687
|
+
transform: 'scaleX(-1)'
|
|
7666
7688
|
}, playsInline: true, muted: true, autoPlay: true }), jsx("div", { className: "facerecorder-dark-overlay", style: {
|
|
7667
7689
|
position: 'absolute',
|
|
7668
7690
|
top: 0,
|
package/dist/index.js
CHANGED
|
@@ -7291,6 +7291,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7291
7291
|
const [isConfirming, setIsConfirming] = React.useState(false);
|
|
7292
7292
|
const videoRef = React.useRef(null);
|
|
7293
7293
|
const previewRef = React.useRef(null);
|
|
7294
|
+
const hasNotifiedRef = React.useRef(false);
|
|
7294
7295
|
const [micLevel, setMicLevel] = React.useState(0);
|
|
7295
7296
|
const analyserRef = React.useRef(null);
|
|
7296
7297
|
const audioCtxRef = React.useRef(null);
|
|
@@ -7311,16 +7312,12 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7311
7312
|
});
|
|
7312
7313
|
// Audio recorder
|
|
7313
7314
|
const { startRecording: startAudioRecording, cancelRecording: cancelAudioRecording } = useRecorder(stream, "audio", (blob) => {
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
|
|
7321
|
-
const audioFile = new File([finalAudioBlob], 'face-audio.webm', { type: finalAudioBlob.type });
|
|
7322
|
-
const phrase = numbersToPhrase(digits);
|
|
7323
|
-
onRecordingComplete(videoFile, audioFile, phrase);
|
|
7315
|
+
if (blob && blob.size > 0) {
|
|
7316
|
+
setAudioBlob(blob);
|
|
7317
|
+
}
|
|
7318
|
+
else {
|
|
7319
|
+
const dummyBlob = new Blob(['dummy audio data'], { type: 'audio/webm' });
|
|
7320
|
+
setAudioBlob(dummyBlob);
|
|
7324
7321
|
}
|
|
7325
7322
|
// Only show result when both recordings are done
|
|
7326
7323
|
// Video callback will be called first, then audio
|
|
@@ -7329,6 +7326,24 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7329
7326
|
setIsConfirming(true);
|
|
7330
7327
|
stopAudioVisualization();
|
|
7331
7328
|
});
|
|
7329
|
+
React.useEffect(() => {
|
|
7330
|
+
// If we already notified for this recording, skip
|
|
7331
|
+
if (hasNotifiedRef.current)
|
|
7332
|
+
return;
|
|
7333
|
+
if (videoBlob && audioBlob && onRecordingComplete) {
|
|
7334
|
+
hasNotifiedRef.current = true; // prevent double-calls
|
|
7335
|
+
const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
|
|
7336
|
+
const audioFile = new File([audioBlob], 'face-audio.webm', { type: audioBlob.type });
|
|
7337
|
+
const phrase = numbersToPhrase(digits);
|
|
7338
|
+
try {
|
|
7339
|
+
onRecordingComplete(videoFile, audioFile, phrase);
|
|
7340
|
+
}
|
|
7341
|
+
catch (err) {
|
|
7342
|
+
// swallow errors from consumer callback to avoid breaking SDK logic
|
|
7343
|
+
console.error('onRecordingComplete callback threw:', err);
|
|
7344
|
+
}
|
|
7345
|
+
}
|
|
7346
|
+
}, [videoBlob, audioBlob, digits, onRecordingComplete]);
|
|
7332
7347
|
// Attach the video stream to the <video> element
|
|
7333
7348
|
React.useEffect(() => {
|
|
7334
7349
|
let isMounted = true;
|
|
@@ -7401,6 +7416,8 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7401
7416
|
stopStreamTracks();
|
|
7402
7417
|
setState('preparation');
|
|
7403
7418
|
setIsConfirming(false);
|
|
7419
|
+
// Reset notified flag
|
|
7420
|
+
hasNotifiedRef.current = false;
|
|
7404
7421
|
setVideoUrl(null);
|
|
7405
7422
|
setVideoBlob(null);
|
|
7406
7423
|
setAudioBlob(null);
|
|
@@ -7424,6 +7441,8 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7424
7441
|
setAudioBlob(null);
|
|
7425
7442
|
setIsConfirming(false);
|
|
7426
7443
|
setState('preparation');
|
|
7444
|
+
// Reset notified flag
|
|
7445
|
+
hasNotifiedRef.current = false;
|
|
7427
7446
|
// Reset digits for next recording
|
|
7428
7447
|
setDigits(generateRandomDigits$1(DIGITS_NUMBER$1));
|
|
7429
7448
|
// Restart stream for next recording
|
|
@@ -7438,6 +7457,8 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7438
7457
|
setAudioBlob(null);
|
|
7439
7458
|
setIsConfirming(false);
|
|
7440
7459
|
setState('preparation');
|
|
7460
|
+
// Reset notified flag
|
|
7461
|
+
hasNotifiedRef.current = false;
|
|
7441
7462
|
// Reset digits for next recording
|
|
7442
7463
|
setDigits(generateRandomDigits$1(DIGITS_NUMBER$1));
|
|
7443
7464
|
// Restart the stream for retake
|
|
@@ -7663,6 +7684,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
|
|
|
7663
7684
|
objectFit: 'cover',
|
|
7664
7685
|
borderRadius: noShadow ? 0 : 8,
|
|
7665
7686
|
zIndex: 0,
|
|
7687
|
+
transform: 'scaleX(-1)'
|
|
7666
7688
|
}, playsInline: true, muted: true, autoPlay: true }), jsxRuntime.jsx("div", { className: "facerecorder-dark-overlay", style: {
|
|
7667
7689
|
position: 'absolute',
|
|
7668
7690
|
top: 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "biometry-react-components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React UI component library for capturing high-quality biometric data (voice, face, documents, video) to facilitate integration with Biometry services",
|
|
6
6
|
"main": "dist/index.js",
|