biometry-react-components 1.1.0 → 1.2.1
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 +23 -11
- package/dist/index.js +23 -11
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -7053,6 +7053,13 @@ var RecordRTC = /*@__PURE__*/getDefaultExportFromCjs(RecordRTCExports);function
|
|
|
7053
7053
|
else {
|
|
7054
7054
|
console.error("no suitable mimetype found for this device");
|
|
7055
7055
|
}
|
|
7056
|
+
}
|
|
7057
|
+
function numberToWord(num) {
|
|
7058
|
+
const words = ['ZERO', 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE'];
|
|
7059
|
+
return words[num] || 'ZERO';
|
|
7060
|
+
}
|
|
7061
|
+
function numbersToPhrase(numbers) {
|
|
7062
|
+
return numbers.map(numberToWord).join(' ');
|
|
7056
7063
|
}const useRecorder = (stream, type, onStopRecording) => {
|
|
7057
7064
|
const [isRecording, setIsRecording] = useState(false);
|
|
7058
7065
|
const recorderRef = useRef(null);
|
|
@@ -7356,7 +7363,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
|
|
|
7356
7363
|
const handleConfirm = () => {
|
|
7357
7364
|
if (videoBlob) {
|
|
7358
7365
|
const file = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
|
|
7359
|
-
onCapture(file, digits
|
|
7366
|
+
onCapture(file, numbersToPhrase(digits));
|
|
7360
7367
|
if (videoUrl)
|
|
7361
7368
|
URL.revokeObjectURL(videoUrl);
|
|
7362
7369
|
setVideoUrl(null);
|
|
@@ -7663,13 +7670,18 @@ if (typeof document !== 'undefined') {
|
|
|
7663
7670
|
const RECORD_SECONDS = 10;
|
|
7664
7671
|
const PREP_SECONDS = 3;
|
|
7665
7672
|
function generateRandomDigits(count) {
|
|
7666
|
-
|
|
7673
|
+
const digits = Array.from({ length: 10 }, (_, i) => i);
|
|
7674
|
+
for (let i = digits.length - 1; i > 0; i--) {
|
|
7675
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
7676
|
+
[digits[i], digits[j]] = [digits[j], digits[i]];
|
|
7677
|
+
}
|
|
7678
|
+
return digits.slice(0, count);
|
|
7667
7679
|
}
|
|
7668
7680
|
const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, style, noShadow = false, }) => {
|
|
7669
7681
|
const [state, setState] = useState('preparation');
|
|
7670
7682
|
const [prepTimer, setPrepTimer] = useState(PREP_SECONDS);
|
|
7671
7683
|
const [recordTimer, setRecordTimer] = useState(RECORD_SECONDS);
|
|
7672
|
-
const [digits, setDigits] = useState(generateRandomDigits(
|
|
7684
|
+
const [digits, setDigits] = useState(generateRandomDigits(10));
|
|
7673
7685
|
const [audioLevel, setAudioLevel] = useState(0);
|
|
7674
7686
|
const [waveformData, setWaveformData] = useState([]);
|
|
7675
7687
|
const { permission, stream, stopStreamTracks, requestPermissions, isLoading } = useAudioPermissions();
|
|
@@ -7756,7 +7768,7 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
|
|
|
7756
7768
|
}
|
|
7757
7769
|
}, [state, recordTimer]);
|
|
7758
7770
|
const startRecording = async () => {
|
|
7759
|
-
setDigits(generateRandomDigits(
|
|
7771
|
+
setDigits(generateRandomDigits(10));
|
|
7760
7772
|
setRecordTimer(RECORD_SECONDS);
|
|
7761
7773
|
setState('countdown');
|
|
7762
7774
|
};
|
|
@@ -7777,7 +7789,7 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
|
|
|
7777
7789
|
const handleConfirm = () => {
|
|
7778
7790
|
if (audioBlob) {
|
|
7779
7791
|
const file = new File([audioBlob], 'voice-recording.webm', { type: audioBlob.type });
|
|
7780
|
-
onCapture(file, digits
|
|
7792
|
+
onCapture(file, numbersToPhrase(digits));
|
|
7781
7793
|
if (audioUrl)
|
|
7782
7794
|
URL.revokeObjectURL(audioUrl);
|
|
7783
7795
|
setAudioUrl(null);
|
|
@@ -7853,16 +7865,16 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
|
|
|
7853
7865
|
const numberRow = {
|
|
7854
7866
|
display: 'flex',
|
|
7855
7867
|
justifyContent: 'center',
|
|
7856
|
-
gap:
|
|
7868
|
+
gap: 6,
|
|
7857
7869
|
margin: '16px 0 24px 0',
|
|
7858
7870
|
};
|
|
7859
7871
|
const numberBox = {
|
|
7860
|
-
minWidth:
|
|
7861
|
-
minHeight:
|
|
7872
|
+
minWidth: 24,
|
|
7873
|
+
minHeight: 32,
|
|
7862
7874
|
background: '#f5f5f5',
|
|
7863
7875
|
border: '2px solid #333',
|
|
7864
|
-
borderRadius:
|
|
7865
|
-
fontSize:
|
|
7876
|
+
borderRadius: 4,
|
|
7877
|
+
fontSize: 16,
|
|
7866
7878
|
fontWeight: 600,
|
|
7867
7879
|
color: '#333',
|
|
7868
7880
|
display: 'flex',
|
|
@@ -7971,7 +7983,7 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
|
|
|
7971
7983
|
justifyContent: 'center',
|
|
7972
7984
|
height: '120px',
|
|
7973
7985
|
gap: '2px',
|
|
7974
|
-
}, children: waveformData.map((value, index) => (jsx("div", { style: waveformBar(value / 255) }, index))) }) }), jsx("div", { style: timerStyle, children: recordTimer }), jsx("div", { style: guidanceText, children: "Speak clearly into your microphone" })] }))] })] }), jsx("div", { style: numberRow, children: (state === 'recording' ? digits : Array(
|
|
7986
|
+
}, children: waveformData.map((value, index) => (jsx("div", { style: waveformBar(value / 255) }, index))) }) }), jsx("div", { style: timerStyle, children: recordTimer }), jsx("div", { style: guidanceText, children: "Speak clearly into your microphone" })] }))] })] }), jsx("div", { style: numberRow, children: (state === 'recording' ? digits : Array(10).fill('*')).map((num, i) => (jsx("div", { style: numberBox, children: num }, i))) }), state === 'preparation' && (jsx("button", { type: "button", style: actionButton, onClick: startRecording, children: "Start recording" })), state === 'recording' && (jsx("button", { type: "button", style: { ...actionButton, background: '#d32f2f' }, onClick: handleCancel, children: "Cancel" }))] })), state === 'processing' && (jsx(Fragment, { children: jsx("div", { className: "voicerecorder-processing", style: preview, children: jsxs("div", { style: {
|
|
7975
7987
|
display: 'flex',
|
|
7976
7988
|
flexDirection: 'column',
|
|
7977
7989
|
alignItems: 'center',
|
package/dist/index.js
CHANGED
|
@@ -7053,6 +7053,13 @@ var RecordRTC = /*@__PURE__*/getDefaultExportFromCjs(RecordRTCExports);function
|
|
|
7053
7053
|
else {
|
|
7054
7054
|
console.error("no suitable mimetype found for this device");
|
|
7055
7055
|
}
|
|
7056
|
+
}
|
|
7057
|
+
function numberToWord(num) {
|
|
7058
|
+
const words = ['ZERO', 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE'];
|
|
7059
|
+
return words[num] || 'ZERO';
|
|
7060
|
+
}
|
|
7061
|
+
function numbersToPhrase(numbers) {
|
|
7062
|
+
return numbers.map(numberToWord).join(' ');
|
|
7056
7063
|
}const useRecorder = (stream, type, onStopRecording) => {
|
|
7057
7064
|
const [isRecording, setIsRecording] = react.useState(false);
|
|
7058
7065
|
const recorderRef = react.useRef(null);
|
|
@@ -7356,7 +7363,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
|
|
|
7356
7363
|
const handleConfirm = () => {
|
|
7357
7364
|
if (videoBlob) {
|
|
7358
7365
|
const file = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
|
|
7359
|
-
onCapture(file, digits
|
|
7366
|
+
onCapture(file, numbersToPhrase(digits));
|
|
7360
7367
|
if (videoUrl)
|
|
7361
7368
|
URL.revokeObjectURL(videoUrl);
|
|
7362
7369
|
setVideoUrl(null);
|
|
@@ -7663,13 +7670,18 @@ if (typeof document !== 'undefined') {
|
|
|
7663
7670
|
const RECORD_SECONDS = 10;
|
|
7664
7671
|
const PREP_SECONDS = 3;
|
|
7665
7672
|
function generateRandomDigits(count) {
|
|
7666
|
-
|
|
7673
|
+
const digits = Array.from({ length: 10 }, (_, i) => i);
|
|
7674
|
+
for (let i = digits.length - 1; i > 0; i--) {
|
|
7675
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
7676
|
+
[digits[i], digits[j]] = [digits[j], digits[i]];
|
|
7677
|
+
}
|
|
7678
|
+
return digits.slice(0, count);
|
|
7667
7679
|
}
|
|
7668
7680
|
const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, style, noShadow = false, }) => {
|
|
7669
7681
|
const [state, setState] = react.useState('preparation');
|
|
7670
7682
|
const [prepTimer, setPrepTimer] = react.useState(PREP_SECONDS);
|
|
7671
7683
|
const [recordTimer, setRecordTimer] = react.useState(RECORD_SECONDS);
|
|
7672
|
-
const [digits, setDigits] = react.useState(generateRandomDigits(
|
|
7684
|
+
const [digits, setDigits] = react.useState(generateRandomDigits(10));
|
|
7673
7685
|
const [audioLevel, setAudioLevel] = react.useState(0);
|
|
7674
7686
|
const [waveformData, setWaveformData] = react.useState([]);
|
|
7675
7687
|
const { permission, stream, stopStreamTracks, requestPermissions, isLoading } = useAudioPermissions();
|
|
@@ -7756,7 +7768,7 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
|
|
|
7756
7768
|
}
|
|
7757
7769
|
}, [state, recordTimer]);
|
|
7758
7770
|
const startRecording = async () => {
|
|
7759
|
-
setDigits(generateRandomDigits(
|
|
7771
|
+
setDigits(generateRandomDigits(10));
|
|
7760
7772
|
setRecordTimer(RECORD_SECONDS);
|
|
7761
7773
|
setState('countdown');
|
|
7762
7774
|
};
|
|
@@ -7777,7 +7789,7 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
|
|
|
7777
7789
|
const handleConfirm = () => {
|
|
7778
7790
|
if (audioBlob) {
|
|
7779
7791
|
const file = new File([audioBlob], 'voice-recording.webm', { type: audioBlob.type });
|
|
7780
|
-
onCapture(file, digits
|
|
7792
|
+
onCapture(file, numbersToPhrase(digits));
|
|
7781
7793
|
if (audioUrl)
|
|
7782
7794
|
URL.revokeObjectURL(audioUrl);
|
|
7783
7795
|
setAudioUrl(null);
|
|
@@ -7853,16 +7865,16 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
|
|
|
7853
7865
|
const numberRow = {
|
|
7854
7866
|
display: 'flex',
|
|
7855
7867
|
justifyContent: 'center',
|
|
7856
|
-
gap:
|
|
7868
|
+
gap: 6,
|
|
7857
7869
|
margin: '16px 0 24px 0',
|
|
7858
7870
|
};
|
|
7859
7871
|
const numberBox = {
|
|
7860
|
-
minWidth:
|
|
7861
|
-
minHeight:
|
|
7872
|
+
minWidth: 24,
|
|
7873
|
+
minHeight: 32,
|
|
7862
7874
|
background: '#f5f5f5',
|
|
7863
7875
|
border: '2px solid #333',
|
|
7864
|
-
borderRadius:
|
|
7865
|
-
fontSize:
|
|
7876
|
+
borderRadius: 4,
|
|
7877
|
+
fontSize: 16,
|
|
7866
7878
|
fontWeight: 600,
|
|
7867
7879
|
color: '#333',
|
|
7868
7880
|
display: 'flex',
|
|
@@ -7971,7 +7983,7 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
|
|
|
7971
7983
|
justifyContent: 'center',
|
|
7972
7984
|
height: '120px',
|
|
7973
7985
|
gap: '2px',
|
|
7974
|
-
}, children: waveformData.map((value, index) => (jsxRuntime.jsx("div", { style: waveformBar(value / 255) }, index))) }) }), jsxRuntime.jsx("div", { style: timerStyle, children: recordTimer }), jsxRuntime.jsx("div", { style: guidanceText, children: "Speak clearly into your microphone" })] }))] })] }), jsxRuntime.jsx("div", { style: numberRow, children: (state === 'recording' ? digits : Array(
|
|
7986
|
+
}, children: waveformData.map((value, index) => (jsxRuntime.jsx("div", { style: waveformBar(value / 255) }, index))) }) }), jsxRuntime.jsx("div", { style: timerStyle, children: recordTimer }), jsxRuntime.jsx("div", { style: guidanceText, children: "Speak clearly into your microphone" })] }))] })] }), jsxRuntime.jsx("div", { style: numberRow, children: (state === 'recording' ? digits : Array(10).fill('*')).map((num, i) => (jsxRuntime.jsx("div", { style: numberBox, children: num }, i))) }), state === 'preparation' && (jsxRuntime.jsx("button", { type: "button", style: actionButton, onClick: startRecording, children: "Start recording" })), state === 'recording' && (jsxRuntime.jsx("button", { type: "button", style: { ...actionButton, background: '#d32f2f' }, onClick: handleCancel, children: "Cancel" }))] })), state === 'processing' && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { className: "voicerecorder-processing", style: preview, children: jsxRuntime.jsxs("div", { style: {
|
|
7975
7987
|
display: 'flex',
|
|
7976
7988
|
flexDirection: 'column',
|
|
7977
7989
|
alignItems: 'center',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "biometry-react-components",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
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",
|