@hexar/biometric-identity-sdk-react-native 1.0.11 → 1.0.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"VideoRecorder.d.ts","sourceRoot":"","sources":["../../src/components/VideoRecorder.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAmD,MAAM,OAAO,CAAC;AAaxE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,iBAAiB,EAA2B,MAAM,oCAAoC,CAAC;AAGlI,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACrC,0CAA0C;IAC1C,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IAC/B,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wCAAwC;IACxC,UAAU,EAAE,CAAC,SAAS,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACtD,iCAAiC;IACjC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,gDAAgD;IAChD,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,oB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CACtD;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA+CD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA80BtD,CAAC;AA4OF,eAAe,aAAa,CAAC"}
@@ -275,12 +275,14 @@ const VideoRecorder = ({ theme, language, duration, instructions, challenges: pr
275
275
  react_native_1.Alert.alert('Recording Error', 'Failed to record video. Please try again.', [{ text: 'OK', onPress: onCancel }]);
276
276
  }, [onCancel]);
277
277
  const handleVideoComplete = (0, react_1.useCallback)(async (video) => {
278
- console.log('handleVideoComplete called with video:', video?.path);
279
- if (!isRecordingRef.current && phase !== 'processing') {
280
- console.log('Video already processed, ignoring duplicate callback');
278
+ console.log('handleVideoComplete called with video:', video?.path, 'current phase:', phase, 'isRecording:', isRecordingRef.current);
279
+ // Don't process if we're already done (result screen or error)
280
+ if (phase === 'loading' && !video) {
281
+ console.log('Video completion in loading phase with no video, ignoring');
281
282
  return;
282
283
  }
283
284
  try {
285
+ console.log('Setting phase to processing');
284
286
  setPhase('processing');
285
287
  setOverallProgress(100);
286
288
  const actualDuration = Date.now() - recordingStartTime.current;
@@ -370,7 +372,7 @@ const VideoRecorder = ({ theme, language, duration, instructions, challenges: pr
370
372
  }
371
373
  }, [device]);
372
374
  const stopRecording = (0, react_1.useCallback)(async () => {
373
- console.log('stopRecording called, isRecording:', isRecordingRef.current);
375
+ console.log('stopRecording called, isRecording:', isRecordingRef.current, 'hasVideoRef:', !!videoRecordingRef.current);
374
376
  // Clear any pending timeouts
375
377
  if (recordingTimeoutRef.current) {
376
378
  clearTimeout(recordingTimeoutRef.current);
@@ -385,18 +387,19 @@ const VideoRecorder = ({ theme, language, duration, instructions, challenges: pr
385
387
  console.log('Recording already stopped, ignoring');
386
388
  return;
387
389
  }
390
+ // Mark as not recording first to prevent re-entry
391
+ isRecordingRef.current = false;
388
392
  if (videoRecordingRef.current) {
389
393
  try {
390
- console.log('Stopping video recording, current ref:', !!videoRecordingRef.current);
394
+ console.log('Stopping video recording, current ref exists');
391
395
  const recording = videoRecordingRef.current;
392
396
  videoRecordingRef.current = null;
393
- isRecordingRef.current = false;
394
397
  await recording.stop();
395
398
  console.log('Video recording stopped - waiting for onRecordingFinished callback');
399
+ // onRecordingFinished callback will handle completion
396
400
  }
397
401
  catch (error) {
398
402
  console.error('Error stopping video recording:', error);
399
- isRecordingRef.current = false;
400
403
  const actualDuration = Date.now() - recordingStartTime.current;
401
404
  console.log('Error duration check:', actualDuration, 'minDurationMs:', minDurationMs, 'frames:', frames.length);
402
405
  if (actualDuration >= minDurationMs && frames.length > 0) {
@@ -411,11 +414,45 @@ const VideoRecorder = ({ theme, language, duration, instructions, challenges: pr
411
414
  };
412
415
  onComplete(result);
413
416
  }
417
+ else {
418
+ // Even if we don't have enough frames, try to complete with what we have
419
+ console.log('Completing with available data despite error');
420
+ const result = {
421
+ frames: frames.length > 0 ? frames : [],
422
+ duration: actualDuration,
423
+ instructionsFollowed: completedChallenges.length === challenges.length,
424
+ qualityScore: frames.length > 0 ? Math.min(100, (frames.length / 30) * 100) : 0,
425
+ challengesCompleted: completedChallenges,
426
+ sessionId,
427
+ };
428
+ onComplete(result);
429
+ }
414
430
  }
415
431
  }
416
432
  else {
417
- console.log('No video recording ref, just setting flag to false');
418
- isRecordingRef.current = false;
433
+ console.log('No video recording ref - completing with captured frames');
434
+ const actualDuration = Date.now() - recordingStartTime.current;
435
+ // Set phase to processing immediately
436
+ setPhase('processing');
437
+ setOverallProgress(100);
438
+ // Complete with frames we have
439
+ const result = {
440
+ frames: frames.length > 0 ? frames : [],
441
+ duration: actualDuration,
442
+ instructionsFollowed: completedChallenges.length === challenges.length,
443
+ qualityScore: frames.length > 0 ? Math.min(100, (frames.length / 30) * 100) : 0,
444
+ challengesCompleted: completedChallenges,
445
+ sessionId,
446
+ };
447
+ console.log('Completing without video ref:', {
448
+ frames: result.frames.length,
449
+ duration: (actualDuration / 1000).toFixed(1) + 's',
450
+ challenges: completedChallenges.length
451
+ });
452
+ // Small delay to ensure UI updates
453
+ setTimeout(() => {
454
+ onComplete(result);
455
+ }, 100);
419
456
  }
420
457
  }, [frames, completedChallenges, challenges, sessionId, onComplete, minDurationMs]);
421
458
  const runChallenge = (0, react_1.useCallback)((index) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexar/biometric-identity-sdk-react-native",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "React Native wrapper for Biometric Identity SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -329,14 +329,16 @@ export const VideoRecorder: React.FC<VideoRecorderProps> = ({
329
329
  }, [onCancel]);
330
330
 
331
331
  const handleVideoComplete = useCallback(async (video: any) => {
332
- console.log('handleVideoComplete called with video:', video?.path);
332
+ console.log('handleVideoComplete called with video:', video?.path, 'current phase:', phase, 'isRecording:', isRecordingRef.current);
333
333
 
334
- if (!isRecordingRef.current && phase !== 'processing') {
335
- console.log('Video already processed, ignoring duplicate callback');
334
+ // Don't process if we're already done (result screen or error)
335
+ if (phase === 'loading' && !video) {
336
+ console.log('Video completion in loading phase with no video, ignoring');
336
337
  return;
337
338
  }
338
339
 
339
340
  try {
341
+ console.log('Setting phase to processing');
340
342
  setPhase('processing');
341
343
  setOverallProgress(100);
342
344
 
@@ -437,7 +439,7 @@ export const VideoRecorder: React.FC<VideoRecorderProps> = ({
437
439
  }, [device]);
438
440
 
439
441
  const stopRecording = useCallback(async () => {
440
- console.log('stopRecording called, isRecording:', isRecordingRef.current);
442
+ console.log('stopRecording called, isRecording:', isRecordingRef.current, 'hasVideoRef:', !!videoRecordingRef.current);
441
443
 
442
444
  // Clear any pending timeouts
443
445
  if (recordingTimeoutRef.current) {
@@ -456,18 +458,20 @@ export const VideoRecorder: React.FC<VideoRecorderProps> = ({
456
458
  return;
457
459
  }
458
460
 
461
+ // Mark as not recording first to prevent re-entry
462
+ isRecordingRef.current = false;
463
+
459
464
  if (videoRecordingRef.current) {
460
465
  try {
461
- console.log('Stopping video recording, current ref:', !!videoRecordingRef.current);
466
+ console.log('Stopping video recording, current ref exists');
462
467
  const recording = videoRecordingRef.current;
463
468
  videoRecordingRef.current = null;
464
- isRecordingRef.current = false;
465
469
 
466
470
  await recording.stop();
467
471
  console.log('Video recording stopped - waiting for onRecordingFinished callback');
472
+ // onRecordingFinished callback will handle completion
468
473
  } catch (error) {
469
474
  console.error('Error stopping video recording:', error);
470
- isRecordingRef.current = false;
471
475
 
472
476
  const actualDuration = Date.now() - recordingStartTime.current;
473
477
  console.log('Error duration check:', actualDuration, 'minDurationMs:', minDurationMs, 'frames:', frames.length);
@@ -482,11 +486,48 @@ export const VideoRecorder: React.FC<VideoRecorderProps> = ({
482
486
  sessionId,
483
487
  };
484
488
  onComplete(result);
489
+ } else {
490
+ // Even if we don't have enough frames, try to complete with what we have
491
+ console.log('Completing with available data despite error');
492
+ const result: VideoRecordingResult = {
493
+ frames: frames.length > 0 ? frames : [],
494
+ duration: actualDuration,
495
+ instructionsFollowed: completedChallenges.length === challenges.length,
496
+ qualityScore: frames.length > 0 ? Math.min(100, (frames.length / 30) * 100) : 0,
497
+ challengesCompleted: completedChallenges,
498
+ sessionId,
499
+ };
500
+ onComplete(result);
485
501
  }
486
502
  }
487
503
  } else {
488
- console.log('No video recording ref, just setting flag to false');
489
- isRecordingRef.current = false;
504
+ console.log('No video recording ref - completing with captured frames');
505
+ const actualDuration = Date.now() - recordingStartTime.current;
506
+
507
+ // Set phase to processing immediately
508
+ setPhase('processing');
509
+ setOverallProgress(100);
510
+
511
+ // Complete with frames we have
512
+ const result: VideoRecordingResult = {
513
+ frames: frames.length > 0 ? frames : [],
514
+ duration: actualDuration,
515
+ instructionsFollowed: completedChallenges.length === challenges.length,
516
+ qualityScore: frames.length > 0 ? Math.min(100, (frames.length / 30) * 100) : 0,
517
+ challengesCompleted: completedChallenges,
518
+ sessionId,
519
+ };
520
+
521
+ console.log('Completing without video ref:', {
522
+ frames: result.frames.length,
523
+ duration: (actualDuration / 1000).toFixed(1) + 's',
524
+ challenges: completedChallenges.length
525
+ });
526
+
527
+ // Small delay to ensure UI updates
528
+ setTimeout(() => {
529
+ onComplete(result);
530
+ }, 100);
490
531
  }
491
532
  }, [frames, completedChallenges, challenges, sessionId, onComplete, minDurationMs]);
492
533