idmission-web-sdk 2.2.29 → 2.2.31

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.
Files changed (30) hide show
  1. package/dist/components/face_liveness/FaceLivenessWizard.d.ts +2 -1
  2. package/dist/components/face_liveness/FaceLivenessWizard.d.ts.map +1 -1
  3. package/dist/components/id_capture/DocumentDetectionModelProvider.d.ts.map +1 -1
  4. package/dist/components/id_capture/FocusModelProvider.d.ts.map +1 -1
  5. package/dist/components/selfie_capture/SelfieCaptureLoadingOverlay.d.ts +1 -0
  6. package/dist/components/selfie_capture/SelfieCaptureLoadingOverlay.d.ts.map +1 -1
  7. package/dist/components/selfie_capture/SelfieCaptureLoadingOverlayDefault.d.ts +1 -1
  8. package/dist/components/selfie_capture/SelfieCaptureLoadingOverlayDefault.d.ts.map +1 -1
  9. package/dist/components/selfie_capture/SelfieCaptureLoadingOverlayLegacy.d.ts +1 -1
  10. package/dist/components/selfie_capture/SelfieCaptureLoadingOverlayLegacy.d.ts.map +1 -1
  11. package/dist/components/selfie_capture/SelfieGuidanceModelsProvider.d.ts.map +1 -1
  12. package/dist/components/video_id/IdVideoCaptureWizard.d.ts.map +1 -1
  13. package/dist/lib/models/DocumentDetection.d.ts +2 -3
  14. package/dist/lib/models/DocumentDetection.d.ts.map +1 -1
  15. package/dist/lib/models/FaceDetection.d.ts +3 -4
  16. package/dist/lib/models/FaceDetection.d.ts.map +1 -1
  17. package/dist/lib/models/Focus.d.ts +2 -3
  18. package/dist/lib/models/Focus.d.ts.map +1 -1
  19. package/dist/sdk2.cjs.development.js +185 -192
  20. package/dist/sdk2.cjs.development.js.map +1 -1
  21. package/dist/sdk2.cjs.production.js +1 -1
  22. package/dist/sdk2.cjs.production.js.map +1 -1
  23. package/dist/sdk2.esm.js +185 -192
  24. package/dist/sdk2.esm.js.map +1 -1
  25. package/dist/sdk2.umd.development.js +185 -192
  26. package/dist/sdk2.umd.development.js.map +1 -1
  27. package/dist/sdk2.umd.production.js +1 -1
  28. package/dist/sdk2.umd.production.js.map +1 -1
  29. package/dist/version.d.ts +1 -1
  30. package/package.json +3 -3
@@ -232,7 +232,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
232
232
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
233
233
  };
234
234
 
235
- var webSdkVersion = '2.2.29';
235
+ var webSdkVersion = '2.2.31';
236
236
 
237
237
  function getPlatform() {
238
238
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2814,30 +2814,29 @@ var defaultFocusThresholds = {
2814
2814
  mobile: 0.3
2815
2815
  }
2816
2816
  };
2817
- var models = {};
2817
+ var classifier = null;
2818
+ var classifierSettings = null;
2818
2819
  function loadFocusModel() {
2819
2820
  return __awaiter(this, arguments, void 0, function (modelAssetPath) {
2820
- var id, _a, _b, _c, _d;
2821
+ var _a, _b;
2821
2822
  if (modelAssetPath === void 0) {
2822
2823
  modelAssetPath = defaultFocusModelPath;
2823
2824
  }
2824
- return __generator(this, function (_e) {
2825
- switch (_e.label) {
2825
+ return __generator(this, function (_c) {
2826
+ switch (_c.label) {
2826
2827
  case 0:
2827
- id = "".concat(modelAssetPath);
2828
- if (models[id]) return [2 /*return*/, models[id]];
2828
+ if (classifier && (classifierSettings === null || classifierSettings === void 0 ? void 0 : classifierSettings.modelAssetPath) === modelAssetPath) return [2 /*return*/, classifier];
2829
+ closeFocusModel();
2829
2830
  return [4 /*yield*/, preloadFocusModelDependencies()];
2830
2831
  case 1:
2831
- _e.sent();
2832
+ _c.sent();
2832
2833
  if (modelCapabilities.delegate === 'NONE') {
2833
2834
  throw new Error('No available delegate for focus detector.');
2834
2835
  }
2835
- _a = models;
2836
- _b = id;
2837
- _d = (_c = tasksVision.ImageClassifier).createFromOptions;
2836
+ _b = (_a = tasksVision.ImageClassifier).createFromOptions;
2838
2837
  return [4 /*yield*/, tasksVision.FilesetResolver.forVisionTasks(visionTasksBasePath)];
2839
2838
  case 2:
2840
- return [4 /*yield*/, _d.apply(_c, [_e.sent(), {
2839
+ return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
2841
2840
  baseOptions: {
2842
2841
  modelAssetPath: modelAssetPath,
2843
2842
  delegate: modelCapabilities.delegate
@@ -2846,20 +2845,19 @@ function loadFocusModel() {
2846
2845
  runningMode: 'VIDEO'
2847
2846
  }])];
2848
2847
  case 3:
2849
- _a[_b] = _e.sent();
2850
- return [2 /*return*/, models[id]];
2848
+ classifier = _c.sent();
2849
+ classifierSettings = {
2850
+ modelAssetPath: modelAssetPath
2851
+ };
2852
+ return [2 /*return*/, classifier];
2851
2853
  }
2852
2854
  });
2853
2855
  });
2854
2856
  }
2855
- function closeFocusModel(modelAssetPath) {
2856
- if (modelAssetPath === void 0) {
2857
- modelAssetPath = defaultFocusModelPath;
2858
- }
2859
- var id = "".concat(modelAssetPath);
2860
- if (!models[id]) return;
2861
- models[id].close();
2862
- delete models[id];
2857
+ function closeFocusModel() {
2858
+ classifier === null || classifier === void 0 ? void 0 : classifier.close();
2859
+ classifier = null;
2860
+ classifierSettings = null;
2863
2861
  }
2864
2862
  function useLoadFocusModel(_a) {
2865
2863
  var _b = _a.modelPath,
@@ -2867,7 +2865,6 @@ function useLoadFocusModel(_a) {
2867
2865
  _c = _a.modelLoadTimeoutMs,
2868
2866
  modelLoadTimeoutMs = _c === void 0 ? defaultFocusModelLoadTimeoutMs : _c,
2869
2867
  onModelError = _a.onModelError;
2870
- var model = React.useRef(null);
2871
2868
  var _d = React.useState(false),
2872
2869
  ready = _d[0],
2873
2870
  setReady = _d[1];
@@ -2893,7 +2890,6 @@ function useLoadFocusModel(_a) {
2893
2890
  return __generator(this, function (_a) {
2894
2891
  switch (_a.label) {
2895
2892
  case 0:
2896
- model.current = loadedModel;
2897
2893
  setModelDownloadProgress(100);
2898
2894
  clearTimeout(modelLoadTimeout);
2899
2895
  return [4 /*yield*/, waitForVideoReady(videoRef)];
@@ -2913,9 +2909,8 @@ function useLoadFocusModel(_a) {
2913
2909
  clearTimeout(modelLoadTimeout);
2914
2910
  });
2915
2911
  return function () {
2916
- log('unloading focus model', model.current);
2917
- model.current = null;
2918
- closeFocusModel(modelPath);
2912
+ log('unloading focus model');
2913
+ closeFocusModel();
2919
2914
  clearTimeout(modelLoadTimeout);
2920
2915
  document.removeEventListener('idmission.preloadProgress.focus', handleDownloadProgress);
2921
2916
  };
@@ -2924,7 +2919,6 @@ function useLoadFocusModel(_a) {
2924
2919
  modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
2925
2920
  }, [modelError, onModelError]);
2926
2921
  return {
2927
- model: model,
2928
2922
  ready: ready,
2929
2923
  modelDownloadProgress: modelDownloadProgress,
2930
2924
  modelError: modelError
@@ -2936,11 +2930,12 @@ function setLastFocusPredictionAt(time) {
2936
2930
  lastFocusPredictionTime = time - lastFocusPredictionAt;
2937
2931
  lastFocusPredictionAt = time;
2938
2932
  }
2939
- function makeFocusModelPrediction(model, imageData, cropCanvas, rotateCanvas, box) {
2933
+ function makeFocusModelPrediction(imageData, cropCanvas, rotateCanvas, box) {
2940
2934
  var _a, _b, _c, _d, _e;
2935
+ if (!classifier) return null;
2941
2936
  var startedAt = new Date();
2942
2937
  var image = cropIfNecessary(imageData, cropCanvas, rotateCanvas, box);
2943
- var result = model.classifyForVideo(image, performance.now());
2938
+ var result = classifier.classifyForVideo(image, performance.now());
2944
2939
  var score = (_e = (_d = (_c = (_b = (_a = result === null || result === void 0 ? void 0 : result.classifications) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.categories) === null || _c === void 0 ? void 0 : _c.find(function (c) {
2945
2940
  return c.categoryName === 'focused';
2946
2941
  })) === null || _d === void 0 ? void 0 : _d.score) !== null && _e !== void 0 ? _e : 0;
@@ -2969,30 +2964,29 @@ function cropIfNecessary(imageData, cropCanvas, rotateCanvas, box) {
2969
2964
  }
2970
2965
 
2971
2966
  var defaultSelfieCaptureModelLoadTimeoutMs = 45000;
2972
- var detectors$1 = {};
2967
+ var detector$1 = null;
2968
+ var detectorSettings$1 = null;
2973
2969
  function loadFaceDetector() {
2974
2970
  return __awaiter(this, arguments, void 0, function (modelAssetPath) {
2975
- var id, _a, _b, _c, _d;
2971
+ var _a, _b;
2976
2972
  if (modelAssetPath === void 0) {
2977
2973
  modelAssetPath = defaultFaceDetectorModelPath;
2978
2974
  }
2979
- return __generator(this, function (_e) {
2980
- switch (_e.label) {
2975
+ return __generator(this, function (_c) {
2976
+ switch (_c.label) {
2981
2977
  case 0:
2982
- id = "".concat(modelAssetPath);
2983
- if (detectors$1[id]) return [2 /*return*/, detectors$1[id]];
2978
+ if (detector$1 && (detectorSettings$1 === null || detectorSettings$1 === void 0 ? void 0 : detectorSettings$1.modelAssetPath) === modelAssetPath) return [2 /*return*/, detector$1];
2979
+ closeFaceDetector();
2984
2980
  return [4 /*yield*/, preloadFaceDetectorDependencies()];
2985
2981
  case 1:
2986
- _e.sent();
2982
+ _c.sent();
2987
2983
  if (modelCapabilities.delegate === 'NONE') {
2988
2984
  throw new Error('No available delegate for face detector.');
2989
2985
  }
2990
- _a = detectors$1;
2991
- _b = id;
2992
- _d = (_c = tasksVision.FaceDetector).createFromOptions;
2986
+ _b = (_a = tasksVision.FaceDetector).createFromOptions;
2993
2987
  return [4 /*yield*/, tasksVision.FilesetResolver.forVisionTasks(visionTasksBasePath)];
2994
2988
  case 2:
2995
- return [4 /*yield*/, _d.apply(_c, [_e.sent(), {
2989
+ return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
2996
2990
  // canvas: document.createElement('canvas'),
2997
2991
  baseOptions: {
2998
2992
  modelAssetPath: modelAssetPath,
@@ -3001,26 +2995,24 @@ function loadFaceDetector() {
3001
2995
  runningMode: 'VIDEO'
3002
2996
  }])];
3003
2997
  case 3:
3004
- _a[_b] = _e.sent();
3005
- return [2 /*return*/, detectors$1[id]];
2998
+ detector$1 = _c.sent();
2999
+ detectorSettings$1 = {
3000
+ modelAssetPath: modelAssetPath
3001
+ };
3002
+ return [2 /*return*/, detector$1];
3006
3003
  }
3007
3004
  });
3008
3005
  });
3009
3006
  }
3010
- function closeFaceDetector(modelAssetPath) {
3011
- if (modelAssetPath === void 0) {
3012
- modelAssetPath = defaultFaceDetectorModelPath;
3013
- }
3014
- var id = "".concat(modelAssetPath);
3015
- if (!detectors$1[id]) return;
3016
- detectors$1[id].close();
3017
- delete detectors$1[id];
3007
+ function closeFaceDetector() {
3008
+ detector$1 === null || detector$1 === void 0 ? void 0 : detector$1.close();
3009
+ detector$1 = null;
3010
+ detectorSettings$1 = null;
3018
3011
  }
3019
3012
  function useLoadFaceDetector(_a) {
3020
3013
  var onModelError = _a.onModelError,
3021
3014
  _b = _a.modelLoadTimeoutMs,
3022
3015
  modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b;
3023
- var detector = React.useRef(null);
3024
3016
  var _c = React.useState(false),
3025
3017
  ready = _c[0],
3026
3018
  setReady = _c[1];
@@ -3046,7 +3038,6 @@ function useLoadFaceDetector(_a) {
3046
3038
  return __generator(this, function (_a) {
3047
3039
  switch (_a.label) {
3048
3040
  case 0:
3049
- detector.current = model;
3050
3041
  setModelDownloadProgress(100);
3051
3042
  clearTimeout(modelLoadTimeout);
3052
3043
  return [4 /*yield*/, waitForVideoReady(videoRef)];
@@ -3064,8 +3055,7 @@ function useLoadFaceDetector(_a) {
3064
3055
  clearTimeout(modelLoadTimeout);
3065
3056
  });
3066
3057
  return function () {
3067
- log('unloading face detection model', detector.current);
3068
- detector.current = null;
3058
+ log('unloading face detection model');
3069
3059
  closeFaceDetector();
3070
3060
  clearTimeout(modelLoadTimeout);
3071
3061
  document.removeEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
@@ -3075,7 +3065,6 @@ function useLoadFaceDetector(_a) {
3075
3065
  modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
3076
3066
  }, [modelError, onModelError]);
3077
3067
  return {
3078
- detector: detector,
3079
3068
  ready: ready,
3080
3069
  modelDownloadProgress: modelDownloadProgress,
3081
3070
  modelError: modelError
@@ -3114,8 +3103,9 @@ function trackFace(face, framesNeeded) {
3114
3103
  if (lastNPairs$1.length > framesNeeded - 1) lastNPairs$1.length = framesNeeded - 1;
3115
3104
  }
3116
3105
  }
3117
- function makeFaceDetectorPrediction(model, imageData) {
3118
- var prediction = model.detectForVideo(imageData, performance.now());
3106
+ function makeFaceDetectorPrediction(imageData) {
3107
+ if (!detector$1) return null;
3108
+ var prediction = detector$1.detectForVideo(imageData, performance.now());
3119
3109
  var faces = prediction.detections.map(function (d) {
3120
3110
  return {
3121
3111
  box: convertBoundingBox(d.boundingBox),
@@ -3447,33 +3437,32 @@ var documentTypeDisplayNames = {
3447
3437
  passport: 'Passport',
3448
3438
  none: 'None'
3449
3439
  };
3450
- var detectors = {};
3440
+ var detector = null;
3441
+ var detectorSettings = null;
3451
3442
  function loadDocumentDetector() {
3452
3443
  return __awaiter(this, arguments, void 0, function (modelAssetPath, scoreThreshold) {
3453
- var id, _a, _b, _c, _d;
3444
+ var _a, _b;
3454
3445
  if (modelAssetPath === void 0) {
3455
3446
  modelAssetPath = defaultDocumentDetectorModelPath;
3456
3447
  }
3457
3448
  if (scoreThreshold === void 0) {
3458
3449
  scoreThreshold = defaultDocumentDetectionScoreThreshold;
3459
3450
  }
3460
- return __generator(this, function (_e) {
3461
- switch (_e.label) {
3451
+ return __generator(this, function (_c) {
3452
+ switch (_c.label) {
3462
3453
  case 0:
3463
- id = "".concat(modelAssetPath, ":").concat(scoreThreshold);
3464
- if (detectors[id]) return [2 /*return*/, detectors[id]];
3454
+ if (detector && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.modelAssetPath) === modelAssetPath && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.scoreThreshold) === scoreThreshold) return [2 /*return*/, detector];
3455
+ closeDocumentDetector();
3465
3456
  return [4 /*yield*/, preloadDocumentDetectorDependencies()];
3466
3457
  case 1:
3467
- _e.sent();
3458
+ _c.sent();
3468
3459
  if (modelCapabilities.delegate === 'NONE') {
3469
3460
  throw new Error('No available delegate for document detector.');
3470
3461
  }
3471
- _a = detectors;
3472
- _b = id;
3473
- _d = (_c = tasksVision.ObjectDetector).createFromOptions;
3462
+ _b = (_a = tasksVision.ObjectDetector).createFromOptions;
3474
3463
  return [4 /*yield*/, tasksVision.FilesetResolver.forVisionTasks(visionTasksBasePath)];
3475
3464
  case 2:
3476
- return [4 /*yield*/, _d.apply(_c, [_e.sent(), {
3465
+ return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
3477
3466
  baseOptions: {
3478
3467
  modelAssetPath: modelAssetPath,
3479
3468
  delegate: modelCapabilities.delegate
@@ -3483,23 +3472,20 @@ function loadDocumentDetector() {
3483
3472
  runningMode: 'VIDEO'
3484
3473
  }])];
3485
3474
  case 3:
3486
- _a[_b] = _e.sent();
3487
- return [2 /*return*/, detectors[id]];
3475
+ detector = _c.sent();
3476
+ detectorSettings = {
3477
+ modelAssetPath: modelAssetPath,
3478
+ scoreThreshold: scoreThreshold
3479
+ };
3480
+ return [2 /*return*/, detector];
3488
3481
  }
3489
3482
  });
3490
3483
  });
3491
3484
  }
3492
- function closeDocumentDetector(modelAssetPath, scoreThreshold) {
3493
- if (modelAssetPath === void 0) {
3494
- modelAssetPath = defaultDocumentDetectorModelPath;
3495
- }
3496
- if (scoreThreshold === void 0) {
3497
- scoreThreshold = defaultDocumentDetectionScoreThreshold;
3498
- }
3499
- var id = "".concat(modelAssetPath, ":").concat(scoreThreshold);
3500
- if (!detectors[id]) return;
3501
- detectors[id].close();
3502
- delete detectors[id];
3485
+ function closeDocumentDetector() {
3486
+ detector === null || detector === void 0 ? void 0 : detector.close();
3487
+ detector = null;
3488
+ detectorSettings = null;
3503
3489
  }
3504
3490
  function useLoadDocumentDetector(_a) {
3505
3491
  var _b = _a.modelPath,
@@ -3509,7 +3495,6 @@ function useLoadDocumentDetector(_a) {
3509
3495
  _d = _a.scoreThreshold,
3510
3496
  scoreThreshold = _d === void 0 ? defaultDocumentDetectionScoreThreshold : _d,
3511
3497
  onModelError = _a.onModelError;
3512
- var detector = React.useRef(null);
3513
3498
  var _e = React.useState(false),
3514
3499
  ready = _e[0],
3515
3500
  setReady = _e[1];
@@ -3535,7 +3520,6 @@ function useLoadDocumentDetector(_a) {
3535
3520
  return __generator(this, function (_a) {
3536
3521
  switch (_a.label) {
3537
3522
  case 0:
3538
- detector.current = model;
3539
3523
  setModelDownloadProgress(100);
3540
3524
  clearTimeout(modelLoadTimeout);
3541
3525
  return [4 /*yield*/, waitForVideoReady(videoRef)];
@@ -3556,8 +3540,7 @@ function useLoadDocumentDetector(_a) {
3556
3540
  });
3557
3541
  return function () {
3558
3542
  log('unloading document detection model');
3559
- detector.current = null;
3560
- closeDocumentDetector(modelPath, scoreThreshold);
3543
+ closeDocumentDetector();
3561
3544
  clearTimeout(modelLoadTimeout);
3562
3545
  document.removeEventListener('idmission.preloadProgress.documentDetection', handleDownloadProgress);
3563
3546
  };
@@ -3566,17 +3549,17 @@ function useLoadDocumentDetector(_a) {
3566
3549
  modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
3567
3550
  }, [modelError, onModelError]);
3568
3551
  return {
3569
- detector: detector,
3570
3552
  ready: ready,
3571
3553
  modelDownloadProgress: modelDownloadProgress,
3572
3554
  modelError: modelError,
3573
3555
  setModelError: setModelError
3574
3556
  };
3575
3557
  }
3576
- function makeDocumentDetectorPrediction(detector, frame) {
3558
+ function makeDocumentDetectorPrediction(frame) {
3577
3559
  return __awaiter(this, void 0, void 0, function () {
3578
3560
  var startedAt, prediction, time, frameWidth, frameHeight;
3579
3561
  return __generator(this, function (_a) {
3562
+ if (!detector) return [2 /*return*/, null];
3580
3563
  startedAt = new Date();
3581
3564
  // Detectors can throw errors, for example when using custom URLs that
3582
3565
  // contain a model that doesn't provide the expected output.
@@ -3900,7 +3883,6 @@ function DocumentDetectionModelProvider(_a) {
3900
3883
  scoreThreshold: documentDetectionModelScoreThreshold,
3901
3884
  onModelError: onDocumentDetectionModelError
3902
3885
  }),
3903
- detector = _o.detector,
3904
3886
  ready = _o.ready,
3905
3887
  modelDownloadProgress = _o.modelDownloadProgress,
3906
3888
  modelError = _o.modelError,
@@ -3912,7 +3894,7 @@ function DocumentDetectionModelProvider(_a) {
3912
3894
  return __generator(this, function (_b) {
3913
3895
  switch (_b.label) {
3914
3896
  case 0:
3915
- if (!videoLoaded || !cameraReady || !ready || !videoRef.current || !detector.current || !lastPredictionCanvas.current) return [2 /*return*/];
3897
+ if (!videoLoaded || !cameraReady || !ready || !videoRef.current || !lastPredictionCanvas.current) return [2 /*return*/];
3916
3898
  stopDetectionAtStart = stopDetection.current;
3917
3899
  vw = videoRef.current.videoWidth;
3918
3900
  vh = videoRef.current.videoHeight;
@@ -3922,7 +3904,7 @@ function DocumentDetectionModelProvider(_a) {
3922
3904
  if (!(ctx && videoRef.current.readyState === 4)) return [3 /*break*/, 3];
3923
3905
  if (stopDetectionAtStart !== stopDetection.current) return [2 /*return*/];
3924
3906
  ctx.drawImage(videoRef.current, 0, 0, vw, vh);
3925
- return [4 /*yield*/, makeDocumentDetectorPrediction(detector.current, lastPredictionCanvas.current)];
3907
+ return [4 /*yield*/, makeDocumentDetectorPrediction(lastPredictionCanvas.current)];
3926
3908
  case 1:
3927
3909
  prediction = _b.sent();
3928
3910
  if (!prediction) return [3 /*break*/, 3];
@@ -3944,7 +3926,7 @@ function DocumentDetectionModelProvider(_a) {
3944
3926
  }
3945
3927
  });
3946
3928
  });
3947
- }, [cameraReady, delayAfterStartMs, detector, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
3929
+ }, [cameraReady, delayAfterStartMs, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
3948
3930
  throttleMs: throttleMs,
3949
3931
  autoStart: autoStart
3950
3932
  }),
@@ -4021,16 +4003,16 @@ function FocusModelProvider(_a) {
4021
4003
  modelLoadTimeoutMs: focusModelLoadTimeoutMs,
4022
4004
  onModelError: onFocusModelError
4023
4005
  }),
4024
- model = _f.model,
4025
4006
  ready = _f.ready,
4026
4007
  modelDownloadProgress = _f.modelDownloadProgress,
4027
4008
  modelError = _f.modelError;
4028
4009
  var makeFocusPrediction = React.useCallback(function (imageData, box) {
4029
- if (!model.current) return null;
4030
- var prediction = makeFocusModelPrediction(model.current, imageData, cropCanvas.current, rotateCanvas.current, box);
4010
+ if (!ready) return null;
4011
+ var prediction = makeFocusModelPrediction(imageData, cropCanvas.current, rotateCanvas.current, box);
4012
+ if (!prediction) return null;
4031
4013
  setLastFocusPredictionAt(prediction.predictionTime);
4032
4014
  return prediction;
4033
- }, [model]);
4015
+ }, [ready]);
4034
4016
  var value = React.useMemo(function () {
4035
4017
  return {
4036
4018
  focusModelReady: ready,
@@ -9253,18 +9235,17 @@ function SelfieGuidanceModelsProvider(_a) {
9253
9235
  onModelError: onModelError,
9254
9236
  modelLoadTimeoutMs: modelLoadTimeoutMs
9255
9237
  }),
9256
- detector = _f.detector,
9257
9238
  ready = _f.ready,
9258
9239
  modelDownloadProgress = _f.modelDownloadProgress,
9259
9240
  modelError = _f.modelError;
9260
9241
  var _g = useFrameLoop(React.useCallback(function () {
9261
9242
  return __awaiter(_this, void 0, void 0, function () {
9262
- var vw, vh, ctx, faces, processed, e_1;
9263
- var _a;
9264
- return __generator(this, function (_b) {
9265
- switch (_b.label) {
9243
+ var vw, vh, ctx, prediction, processed, e_1;
9244
+ var _a, _b;
9245
+ return __generator(this, function (_c) {
9246
+ switch (_c.label) {
9266
9247
  case 0:
9267
- if (!videoLoaded || !cameraReady || !ready || modelError || !videoRef.current || !detector.current || !canvasRef.current) return [2 /*return*/];
9248
+ if (!videoLoaded || !cameraReady || !ready || modelError || !videoRef.current || !canvasRef.current) return [2 /*return*/];
9268
9249
  vw = videoRef.current.videoWidth;
9269
9250
  vh = videoRef.current.videoHeight;
9270
9251
  ctx = canvasRef.current.getContext('2d');
@@ -9274,23 +9255,23 @@ function SelfieGuidanceModelsProvider(_a) {
9274
9255
  ctx.translate(vw, 0);
9275
9256
  ctx.scale(-1, 1);
9276
9257
  ctx.drawImage(videoRef.current, 0, 0, vw, vh);
9277
- _b.label = 1;
9258
+ _c.label = 1;
9278
9259
  case 1:
9279
- _b.trys.push([1, 3,, 4]);
9280
- faces = makeFaceDetectorPrediction(detector.current, canvasRef.current).faces;
9260
+ _c.trys.push([1, 3,, 4]);
9261
+ prediction = makeFaceDetectorPrediction(canvasRef.current);
9281
9262
  processed = processFaceDetectorPrediction({
9282
- faces: faces,
9263
+ faces: (_a = prediction === null || prediction === void 0 ? void 0 : prediction.faces) !== null && _a !== void 0 ? _a : [],
9283
9264
  videoWidth: vw,
9284
9265
  videoHeight: vh,
9285
9266
  requireVerticalFaceCentering: requireVerticalFaceCentering
9286
9267
  });
9287
9268
  setLastFaceDetectionAt(new Date().getTime());
9288
- return [4 /*yield*/, (_a = onPredictionHandler.current) === null || _a === void 0 ? void 0 : _a.call(onPredictionHandler, processed)];
9269
+ return [4 /*yield*/, (_b = onPredictionHandler.current) === null || _b === void 0 ? void 0 : _b.call(onPredictionHandler, processed)];
9289
9270
  case 2:
9290
- _b.sent();
9271
+ _c.sent();
9291
9272
  return [3 /*break*/, 4];
9292
9273
  case 3:
9293
- e_1 = _b.sent();
9274
+ e_1 = _c.sent();
9294
9275
  error('caught face detection error', e_1);
9295
9276
  return [3 /*break*/, 4];
9296
9277
  case 4:
@@ -9298,7 +9279,7 @@ function SelfieGuidanceModelsProvider(_a) {
9298
9279
  }
9299
9280
  });
9300
9281
  });
9301
- }, [cameraReady, detector, modelError, ready, requireVerticalFaceCentering, videoLoaded, videoRef]), {
9282
+ }, [cameraReady, modelError, ready, requireVerticalFaceCentering, videoLoaded, videoRef]), {
9302
9283
  throttleMs: throttleMs,
9303
9284
  autoStart: autoStart
9304
9285
  }),
@@ -10170,21 +10151,24 @@ var templateObject_1$f, templateObject_2$d, templateObject_3$c, templateObject_4
10170
10151
  var SelfieCaptureLoadingOverlayLegacy = function SelfieCaptureLoadingOverlayLegacy(_a) {
10171
10152
  var onDismissed = _a.onDismissed,
10172
10153
  onUserCancel = _a.onUserCancel,
10173
- _b = _a.assets,
10174
- assets = _b === void 0 ? {} : _b,
10175
- _c = _a.classNames,
10176
- classNames = _c === void 0 ? {} : _c,
10177
- _d = _a.colors,
10178
- colors = _d === void 0 ? {} : _d,
10179
- _e = _a.verbiage,
10180
- rawVerbiage = _e === void 0 ? {} : _e;
10181
- var _f = React.useContext(CameraStateContext),
10182
- cameraReady = _f.cameraReady,
10183
- cameraAccessDenied = _f.cameraAccessDenied,
10184
- microphoneAccessDenied = _f.microphoneAccessDenied;
10185
- var _g = React.useContext(SelfieGuidanceModelsContext),
10186
- modelsReady = _g.ready,
10187
- modelDownloadProgress = _g.modelDownloadProgress;
10154
+ _b = _a.waitForIdCaptureModels,
10155
+ waitForIdCaptureModels = _b === void 0 ? false : _b,
10156
+ _c = _a.assets,
10157
+ assets = _c === void 0 ? {} : _c,
10158
+ _d = _a.classNames,
10159
+ classNames = _d === void 0 ? {} : _d,
10160
+ _e = _a.colors,
10161
+ colors = _e === void 0 ? {} : _e,
10162
+ _f = _a.verbiage,
10163
+ rawVerbiage = _f === void 0 ? {} : _f;
10164
+ var _g = React.useContext(CameraStateContext),
10165
+ cameraReady = _g.cameraReady,
10166
+ cameraAccessDenied = _g.cameraAccessDenied,
10167
+ microphoneAccessDenied = _g.microphoneAccessDenied;
10168
+ var _h = React.useContext(SelfieGuidanceModelsContext),
10169
+ modelsReady = _h.ready,
10170
+ modelDownloadProgress = _h.modelDownloadProgress;
10171
+ var idCaptureModelsContext = React.useContext(IdCaptureModelsContext);
10188
10172
  assets.instructionImageUrl || (assets.instructionImageUrl = "".concat(DEFAULT_CDN_URL, "/Selfie-Image-1.png"));
10189
10173
  var verbiage = useTranslations(rawVerbiage, {
10190
10174
  headingText: 'Use your device camera to capture your face',
@@ -10195,9 +10179,9 @@ var SelfieCaptureLoadingOverlayLegacy = function SelfieCaptureLoadingOverlayLega
10195
10179
  downloadingText: 'Downloading...',
10196
10180
  modelsWarmingUpText: 'Models warming up...'
10197
10181
  });
10198
- var _h = React.useState(false),
10199
- dismissed = _h[0],
10200
- setDismissed = _h[1];
10182
+ var _j = React.useState(false),
10183
+ dismissed = _j[0],
10184
+ setDismissed = _j[1];
10201
10185
  if (dismissed) return /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null);
10202
10186
  if (cameraAccessDenied) {
10203
10187
  return /*#__PURE__*/React__namespace.default.createElement(CameraAccessDeniedOverlay, {
@@ -10215,6 +10199,7 @@ var SelfieCaptureLoadingOverlayLegacy = function SelfieCaptureLoadingOverlayLega
10215
10199
  verbiage: rawVerbiage.microphoneAccessDenied
10216
10200
  });
10217
10201
  }
10202
+ var allModelsReady = modelsReady && (!waitForIdCaptureModels || (idCaptureModelsContext === null || idCaptureModelsContext === void 0 ? void 0 : idCaptureModelsContext.ready));
10218
10203
  return /*#__PURE__*/React__namespace.default.createElement(OverlayContainer, {
10219
10204
  className: classNames.container
10220
10205
  }, /*#__PURE__*/React__namespace.default.createElement(OverlayInner$2, {
@@ -10234,15 +10219,15 @@ var SelfieCaptureLoadingOverlayLegacy = function SelfieCaptureLoadingOverlayLega
10234
10219
  className: classNames.buttonsRow
10235
10220
  }, /*#__PURE__*/React__namespace.default.createElement(LoaderButton, {
10236
10221
  variant: "positive",
10237
- disabled: !cameraReady || !modelsReady,
10238
- finished: cameraReady && modelsReady,
10222
+ disabled: !cameraReady || !allModelsReady,
10223
+ finished: cameraReady && allModelsReady,
10239
10224
  className: classNames.continueBtn,
10240
10225
  colors: colors.continueBtn,
10241
10226
  onClick: function onClick() {
10242
10227
  setDismissed(true);
10243
10228
  onDismissed === null || onDismissed === void 0 ? void 0 : onDismissed();
10244
10229
  }
10245
- }, cameraReady && modelsReady ? verbiage.continueText : modelsReady ? verbiage.cameraInitializingText : modelDownloadProgress >= 100 ? "".concat(verbiage.modelsWarmingUpText) : "".concat(verbiage.downloadingText, " (").concat(modelDownloadProgress, "%)")))));
10230
+ }, cameraReady && allModelsReady ? verbiage.continueText : allModelsReady ? verbiage.cameraInitializingText : modelDownloadProgress >= 100 ? "".concat(verbiage.modelsWarmingUpText) : "".concat(verbiage.downloadingText, " (").concat(modelDownloadProgress, "%)")))));
10246
10231
  };
10247
10232
  var StyledGuidanceMessage$1 = styled__default.default(GuidanceMessage)(templateObject_1$e || (templateObject_1$e = __makeTemplateObject(["\n padding: 12px 24px;\n font-weight: normal;\n line-height: 1.5;\n margin-bottom: -30px;\n"], ["\n padding: 12px 24px;\n font-weight: normal;\n line-height: 1.5;\n margin-bottom: -30px;\n"])));
10248
10233
  var StyledButtonsRow$6 = styled__default.default(ButtonsRow)(templateObject_2$c || (templateObject_2$c = __makeTemplateObject(["\n flex-direction: column;\n padding-top: 25px;\n"], ["\n flex-direction: column;\n padding-top: 25px;\n"])));
@@ -10252,22 +10237,25 @@ var legacyInstructionImageUrl = "".concat(DEFAULT_CDN_URL, "/Selfie-Image-1.png"
10252
10237
  var SelfieCaptureLoadingOverlayDefault = function SelfieCaptureLoadingOverlayDefault(_a) {
10253
10238
  var onDismissed = _a.onDismissed,
10254
10239
  onUserCancel = _a.onUserCancel,
10255
- _b = _a.assets,
10256
- assets = _b === void 0 ? {} : _b,
10257
- _c = _a.classNames,
10258
- classNames = _c === void 0 ? {} : _c,
10259
- _d = _a.colors,
10260
- colors = _d === void 0 ? {} : _d,
10261
- _e = _a.verbiage,
10262
- rawVerbiage = _e === void 0 ? {} : _e,
10263
- customOverlayContent = _a.customOverlayContent;
10264
- var _f = React.useContext(CameraStateContext),
10265
- cameraReady = _f.cameraReady,
10266
- cameraAccessDenied = _f.cameraAccessDenied,
10267
- microphoneAccessDenied = _f.microphoneAccessDenied;
10268
- var _g = React.useContext(SelfieGuidanceModelsContext),
10269
- modelsReady = _g.ready,
10270
- modelDownloadProgress = _g.modelDownloadProgress;
10240
+ customOverlayContent = _a.customOverlayContent,
10241
+ _b = _a.waitForIdCaptureModels,
10242
+ waitForIdCaptureModels = _b === void 0 ? false : _b,
10243
+ _c = _a.assets,
10244
+ assets = _c === void 0 ? {} : _c,
10245
+ _d = _a.classNames,
10246
+ classNames = _d === void 0 ? {} : _d,
10247
+ _e = _a.colors,
10248
+ colors = _e === void 0 ? {} : _e,
10249
+ _f = _a.verbiage,
10250
+ rawVerbiage = _f === void 0 ? {} : _f;
10251
+ var _g = React.useContext(CameraStateContext),
10252
+ cameraReady = _g.cameraReady,
10253
+ cameraAccessDenied = _g.cameraAccessDenied,
10254
+ microphoneAccessDenied = _g.microphoneAccessDenied;
10255
+ var _h = React.useContext(SelfieGuidanceModelsContext),
10256
+ modelsReady = _h.ready,
10257
+ modelDownloadProgress = _h.modelDownloadProgress;
10258
+ var idCaptureModelsContext = React.useContext(IdCaptureModelsContext);
10271
10259
  var verbiage = useTranslations(rawVerbiage, {
10272
10260
  headingText: 'Use your device camera to capture your face',
10273
10261
  removeEyeCoveringsText: 'Remove Sunglasses & Hat',
@@ -10279,9 +10267,9 @@ var SelfieCaptureLoadingOverlayDefault = function SelfieCaptureLoadingOverlayDef
10279
10267
  modelsWarmingUpText: 'Loading guided capture experience...',
10280
10268
  modelsReadyText: 'Guided capture experience ready'
10281
10269
  });
10282
- var _h = React.useState(0),
10283
- headingTextIndex = _h[0],
10284
- setHeadingTextIndex = _h[1];
10270
+ var _j = React.useState(0),
10271
+ headingTextIndex = _j[0],
10272
+ setHeadingTextIndex = _j[1];
10285
10273
  var headingText = [verbiage.headingText, verbiage.removeEyeCoveringsText, verbiage.avoidExcessiveBacklightingText][headingTextIndex];
10286
10274
  React.useEffect(function () {
10287
10275
  setInterval(function () {
@@ -10290,9 +10278,9 @@ var SelfieCaptureLoadingOverlayDefault = function SelfieCaptureLoadingOverlayDef
10290
10278
  });
10291
10279
  }, 3000);
10292
10280
  }, []);
10293
- var _j = React.useState(false),
10294
- dismissed = _j[0],
10295
- setDismissed = _j[1];
10281
+ var _k = React.useState(false),
10282
+ dismissed = _k[0],
10283
+ setDismissed = _k[1];
10296
10284
  if (dismissed) return /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null);
10297
10285
  if (cameraAccessDenied) {
10298
10286
  return /*#__PURE__*/React__namespace.default.createElement(CameraAccessDeniedOverlay, {
@@ -10310,6 +10298,7 @@ var SelfieCaptureLoadingOverlayDefault = function SelfieCaptureLoadingOverlayDef
10310
10298
  verbiage: rawVerbiage.microphoneAccessDenied
10311
10299
  });
10312
10300
  }
10301
+ var allModelsReady = modelsReady && (!waitForIdCaptureModels || (idCaptureModelsContext === null || idCaptureModelsContext === void 0 ? void 0 : idCaptureModelsContext.ready));
10313
10302
  return /*#__PURE__*/React__namespace.default.createElement(OverlayContainer, {
10314
10303
  className: classNames.container
10315
10304
  }, /*#__PURE__*/React__namespace.default.createElement(OverlayInner, {
@@ -10350,13 +10339,13 @@ var SelfieCaptureLoadingOverlayDefault = function SelfieCaptureLoadingOverlayDef
10350
10339
  className: classNames.loadingListItemIndicator,
10351
10340
  state: cameraReady ? 'done' : 'running'
10352
10341
  }), cameraReady ? verbiage.cameraInitializedText : verbiage.cameraInitializingText), /*#__PURE__*/React__namespace.default.createElement(LoadingListItem, {
10353
- className: "".concat(classNames.loadingListItem, " ").concat(modelsReady ? 'done' : 'running')
10342
+ className: "".concat(classNames.loadingListItem, " ").concat(allModelsReady ? 'done' : 'running')
10354
10343
  }, /*#__PURE__*/React__namespace.default.createElement(LoadingListItemIndicator, {
10355
10344
  className: classNames.loadingListItemIndicator,
10356
- state: modelsReady ? 'done' : 'running'
10357
- }), modelsReady ? verbiage.modelsReadyText : modelDownloadProgress >= 100 ? verbiage.modelsWarmingUpText : "".concat(verbiage.downloadingText, " (").concat(modelDownloadProgress, "%)")))), /*#__PURE__*/React__namespace.default.createElement(ContinueButtonContainer, {
10345
+ state: allModelsReady ? 'done' : 'running'
10346
+ }), allModelsReady ? verbiage.modelsReadyText : modelDownloadProgress >= 100 ? verbiage.modelsWarmingUpText : "".concat(verbiage.downloadingText, " (").concat(modelDownloadProgress, "%)")))), /*#__PURE__*/React__namespace.default.createElement(ContinueButtonContainer, {
10358
10347
  className: classNames.continueBtnContainer
10359
- }, modelsReady && cameraReady && ( /*#__PURE__*/React__namespace.default.createElement(ContinueButton, {
10348
+ }, allModelsReady && cameraReady && ( /*#__PURE__*/React__namespace.default.createElement(ContinueButton, {
10360
10349
  finished: true,
10361
10350
  className: classNames.continueBtn,
10362
10351
  variant: "positive",
@@ -10457,42 +10446,44 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
10457
10446
  releaseCameraAccessOnExit = _k === void 0 ? true : _k,
10458
10447
  _l = _a.silentFallback,
10459
10448
  silentFallback = _l === void 0 ? false : _l,
10449
+ _m = _a.waitForIdCaptureModels,
10450
+ waitForIdCaptureModels = _m === void 0 ? false : _m,
10460
10451
  guidesComponent = _a.guidesComponent,
10461
10452
  disableCapturePreview = _a.disableCapturePreview,
10462
- _m = _a.assets,
10463
- assets = _m === void 0 ? {} : _m,
10464
- _o = _a.classNames,
10465
- classNames = _o === void 0 ? {} : _o,
10466
- _p = _a.colors,
10467
- colors = _p === void 0 ? {} : _p,
10468
- _q = _a.verbiage,
10469
- verbiage = _q === void 0 ? {} : _q,
10470
- _r = _a.debugMode,
10471
- debugMode = _r === void 0 ? false : _r;
10472
- var _s = React.useContext(SubmissionContext),
10473
- submissionResponse = _s.submissionResponse,
10474
- livenessCheckRequest = _s.livenessCheckRequest,
10475
- setSelfieImage = _s.setSelfieImage,
10476
- logSelfieCaptureAttempt = _s.logSelfieCaptureAttempt;
10477
- var _t = React.useContext(CameraStateContext),
10478
- cameraAccessDenied = _t.cameraAccessDenied,
10479
- requestCameraAccess = _t.requestCameraAccess,
10480
- releaseCameraAccess = _t.releaseCameraAccess;
10481
- var _u = React.useState(''),
10482
- faceCropImageUrl = _u[0],
10483
- setFaceCropImageUrl = _u[1];
10484
- var _v = React.useState(0),
10485
- retryCount = _v[0],
10486
- setRetryCount = _v[1];
10487
- var _w = React.useState('LOADING'),
10488
- captureState = _w[0],
10489
- setCaptureState = _w[1];
10453
+ _o = _a.assets,
10454
+ assets = _o === void 0 ? {} : _o,
10455
+ _p = _a.classNames,
10456
+ classNames = _p === void 0 ? {} : _p,
10457
+ _q = _a.colors,
10458
+ colors = _q === void 0 ? {} : _q,
10459
+ _r = _a.verbiage,
10460
+ verbiage = _r === void 0 ? {} : _r,
10461
+ _s = _a.debugMode,
10462
+ debugMode = _s === void 0 ? false : _s;
10463
+ var _t = React.useContext(SubmissionContext),
10464
+ submissionResponse = _t.submissionResponse,
10465
+ livenessCheckRequest = _t.livenessCheckRequest,
10466
+ setSelfieImage = _t.setSelfieImage,
10467
+ logSelfieCaptureAttempt = _t.logSelfieCaptureAttempt;
10468
+ var _u = React.useContext(CameraStateContext),
10469
+ cameraAccessDenied = _u.cameraAccessDenied,
10470
+ requestCameraAccess = _u.requestCameraAccess,
10471
+ releaseCameraAccess = _u.releaseCameraAccess;
10472
+ var _v = React.useState(''),
10473
+ faceCropImageUrl = _v[0],
10474
+ setFaceCropImageUrl = _v[1];
10475
+ var _w = React.useState(0),
10476
+ retryCount = _w[0],
10477
+ setRetryCount = _w[1];
10478
+ var _x = React.useState('LOADING'),
10479
+ captureState = _x[0],
10480
+ setCaptureState = _x[1];
10490
10481
  var captureStartedAt = React.useRef();
10491
10482
  var captureEndedAt = React.useRef();
10492
10483
  var operationStartedAt = React.useRef();
10493
- var _x = React.useContext(SelfieGuidanceModelsContext),
10494
- start = _x.start,
10495
- stop = _x.stop;
10484
+ var _y = React.useContext(SelfieGuidanceModelsContext),
10485
+ start = _y.start,
10486
+ stop = _y.stop;
10496
10487
  React.useEffect(function () {
10497
10488
  operationStartedAt.current = new Date();
10498
10489
  }, []);
@@ -10547,9 +10538,9 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
10547
10538
  setCaptureState('FAILED');
10548
10539
  onDenied === null || onDenied === void 0 ? void 0 : onDenied(submissionResponse, livenessCheckRequest);
10549
10540
  }, [onDenied, submissionResponse, livenessCheckRequest]);
10550
- var _y = React.useState(0),
10551
- attempt = _y[0],
10552
- setAttempt = _y[1];
10541
+ var _z = React.useState(0),
10542
+ attempt = _z[0],
10543
+ setAttempt = _z[1];
10553
10544
  var onExitCallback = React.useCallback(function () {
10554
10545
  setAttempt(function (n) {
10555
10546
  return n + 1;
@@ -10655,7 +10646,8 @@ var FaceLivenessWizard = function FaceLivenessWizard(_a) {
10655
10646
  colors: colors.loadingOverlay,
10656
10647
  verbiage: verbiage.loadingOverlay,
10657
10648
  onUserCancel: onUserCancel,
10658
- onDismissed: onLoadingOverlayDismissedCallback
10649
+ onDismissed: onLoadingOverlayDismissedCallback,
10650
+ waitForIdCaptureModels: waitForIdCaptureModels
10659
10651
  }));
10660
10652
  };
10661
10653
 
@@ -12752,6 +12744,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
12752
12744
  skipSuccessScreen: true,
12753
12745
  renderCameraFeed: false,
12754
12746
  releaseCameraAccessOnExit: false,
12747
+ waitForIdCaptureModels: true,
12755
12748
  disableCapturePreview: !debugMode,
12756
12749
  guidesComponent: faceLivenessGuides,
12757
12750
  assets: assets.faceLiveness,