idmission-web-sdk 2.2.30 → 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.
package/dist/sdk2.esm.js CHANGED
@@ -201,7 +201,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
201
201
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
202
202
  };
203
203
 
204
- var webSdkVersion = '2.2.30';
204
+ var webSdkVersion = '2.2.31';
205
205
 
206
206
  function getPlatform() {
207
207
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2783,30 +2783,29 @@ var defaultFocusThresholds = {
2783
2783
  mobile: 0.3
2784
2784
  }
2785
2785
  };
2786
- var models = {};
2786
+ var classifier = null;
2787
+ var classifierSettings = null;
2787
2788
  function loadFocusModel() {
2788
2789
  return __awaiter(this, arguments, void 0, function (modelAssetPath) {
2789
- var id, _a, _b, _c, _d;
2790
+ var _a, _b;
2790
2791
  if (modelAssetPath === void 0) {
2791
2792
  modelAssetPath = defaultFocusModelPath;
2792
2793
  }
2793
- return __generator(this, function (_e) {
2794
- switch (_e.label) {
2794
+ return __generator(this, function (_c) {
2795
+ switch (_c.label) {
2795
2796
  case 0:
2796
- id = "".concat(modelAssetPath);
2797
- if (models[id]) return [2 /*return*/, models[id]];
2797
+ if (classifier && (classifierSettings === null || classifierSettings === void 0 ? void 0 : classifierSettings.modelAssetPath) === modelAssetPath) return [2 /*return*/, classifier];
2798
+ closeFocusModel();
2798
2799
  return [4 /*yield*/, preloadFocusModelDependencies()];
2799
2800
  case 1:
2800
- _e.sent();
2801
+ _c.sent();
2801
2802
  if (modelCapabilities.delegate === 'NONE') {
2802
2803
  throw new Error('No available delegate for focus detector.');
2803
2804
  }
2804
- _a = models;
2805
- _b = id;
2806
- _d = (_c = ImageClassifier).createFromOptions;
2805
+ _b = (_a = ImageClassifier).createFromOptions;
2807
2806
  return [4 /*yield*/, FilesetResolver.forVisionTasks(visionTasksBasePath)];
2808
2807
  case 2:
2809
- return [4 /*yield*/, _d.apply(_c, [_e.sent(), {
2808
+ return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
2810
2809
  baseOptions: {
2811
2810
  modelAssetPath: modelAssetPath,
2812
2811
  delegate: modelCapabilities.delegate
@@ -2815,20 +2814,19 @@ function loadFocusModel() {
2815
2814
  runningMode: 'VIDEO'
2816
2815
  }])];
2817
2816
  case 3:
2818
- _a[_b] = _e.sent();
2819
- return [2 /*return*/, models[id]];
2817
+ classifier = _c.sent();
2818
+ classifierSettings = {
2819
+ modelAssetPath: modelAssetPath
2820
+ };
2821
+ return [2 /*return*/, classifier];
2820
2822
  }
2821
2823
  });
2822
2824
  });
2823
2825
  }
2824
- function closeFocusModel(modelAssetPath) {
2825
- if (modelAssetPath === void 0) {
2826
- modelAssetPath = defaultFocusModelPath;
2827
- }
2828
- var id = "".concat(modelAssetPath);
2829
- if (!models[id]) return;
2830
- models[id].close();
2831
- delete models[id];
2826
+ function closeFocusModel() {
2827
+ classifier === null || classifier === void 0 ? void 0 : classifier.close();
2828
+ classifier = null;
2829
+ classifierSettings = null;
2832
2830
  }
2833
2831
  function useLoadFocusModel(_a) {
2834
2832
  var _b = _a.modelPath,
@@ -2836,7 +2834,6 @@ function useLoadFocusModel(_a) {
2836
2834
  _c = _a.modelLoadTimeoutMs,
2837
2835
  modelLoadTimeoutMs = _c === void 0 ? defaultFocusModelLoadTimeoutMs : _c,
2838
2836
  onModelError = _a.onModelError;
2839
- var model = useRef(null);
2840
2837
  var _d = useState(false),
2841
2838
  ready = _d[0],
2842
2839
  setReady = _d[1];
@@ -2862,7 +2859,6 @@ function useLoadFocusModel(_a) {
2862
2859
  return __generator(this, function (_a) {
2863
2860
  switch (_a.label) {
2864
2861
  case 0:
2865
- model.current = loadedModel;
2866
2862
  setModelDownloadProgress(100);
2867
2863
  clearTimeout(modelLoadTimeout);
2868
2864
  return [4 /*yield*/, waitForVideoReady(videoRef)];
@@ -2882,9 +2878,8 @@ function useLoadFocusModel(_a) {
2882
2878
  clearTimeout(modelLoadTimeout);
2883
2879
  });
2884
2880
  return function () {
2885
- log('unloading focus model', model.current);
2886
- model.current = null;
2887
- closeFocusModel(modelPath);
2881
+ log('unloading focus model');
2882
+ closeFocusModel();
2888
2883
  clearTimeout(modelLoadTimeout);
2889
2884
  document.removeEventListener('idmission.preloadProgress.focus', handleDownloadProgress);
2890
2885
  };
@@ -2893,7 +2888,6 @@ function useLoadFocusModel(_a) {
2893
2888
  modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
2894
2889
  }, [modelError, onModelError]);
2895
2890
  return {
2896
- model: model,
2897
2891
  ready: ready,
2898
2892
  modelDownloadProgress: modelDownloadProgress,
2899
2893
  modelError: modelError
@@ -2905,11 +2899,12 @@ function setLastFocusPredictionAt(time) {
2905
2899
  lastFocusPredictionTime = time - lastFocusPredictionAt;
2906
2900
  lastFocusPredictionAt = time;
2907
2901
  }
2908
- function makeFocusModelPrediction(model, imageData, cropCanvas, rotateCanvas, box) {
2902
+ function makeFocusModelPrediction(imageData, cropCanvas, rotateCanvas, box) {
2909
2903
  var _a, _b, _c, _d, _e;
2904
+ if (!classifier) return null;
2910
2905
  var startedAt = new Date();
2911
2906
  var image = cropIfNecessary(imageData, cropCanvas, rotateCanvas, box);
2912
- var result = model.classifyForVideo(image, performance.now());
2907
+ var result = classifier.classifyForVideo(image, performance.now());
2913
2908
  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) {
2914
2909
  return c.categoryName === 'focused';
2915
2910
  })) === null || _d === void 0 ? void 0 : _d.score) !== null && _e !== void 0 ? _e : 0;
@@ -2938,30 +2933,29 @@ function cropIfNecessary(imageData, cropCanvas, rotateCanvas, box) {
2938
2933
  }
2939
2934
 
2940
2935
  var defaultSelfieCaptureModelLoadTimeoutMs = 45000;
2941
- var detectors$1 = {};
2936
+ var detector$1 = null;
2937
+ var detectorSettings$1 = null;
2942
2938
  function loadFaceDetector() {
2943
2939
  return __awaiter(this, arguments, void 0, function (modelAssetPath) {
2944
- var id, _a, _b, _c, _d;
2940
+ var _a, _b;
2945
2941
  if (modelAssetPath === void 0) {
2946
2942
  modelAssetPath = defaultFaceDetectorModelPath;
2947
2943
  }
2948
- return __generator(this, function (_e) {
2949
- switch (_e.label) {
2944
+ return __generator(this, function (_c) {
2945
+ switch (_c.label) {
2950
2946
  case 0:
2951
- id = "".concat(modelAssetPath);
2952
- if (detectors$1[id]) return [2 /*return*/, detectors$1[id]];
2947
+ if (detector$1 && (detectorSettings$1 === null || detectorSettings$1 === void 0 ? void 0 : detectorSettings$1.modelAssetPath) === modelAssetPath) return [2 /*return*/, detector$1];
2948
+ closeFaceDetector();
2953
2949
  return [4 /*yield*/, preloadFaceDetectorDependencies()];
2954
2950
  case 1:
2955
- _e.sent();
2951
+ _c.sent();
2956
2952
  if (modelCapabilities.delegate === 'NONE') {
2957
2953
  throw new Error('No available delegate for face detector.');
2958
2954
  }
2959
- _a = detectors$1;
2960
- _b = id;
2961
- _d = (_c = FaceDetector).createFromOptions;
2955
+ _b = (_a = FaceDetector).createFromOptions;
2962
2956
  return [4 /*yield*/, FilesetResolver.forVisionTasks(visionTasksBasePath)];
2963
2957
  case 2:
2964
- return [4 /*yield*/, _d.apply(_c, [_e.sent(), {
2958
+ return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
2965
2959
  // canvas: document.createElement('canvas'),
2966
2960
  baseOptions: {
2967
2961
  modelAssetPath: modelAssetPath,
@@ -2970,26 +2964,24 @@ function loadFaceDetector() {
2970
2964
  runningMode: 'VIDEO'
2971
2965
  }])];
2972
2966
  case 3:
2973
- _a[_b] = _e.sent();
2974
- return [2 /*return*/, detectors$1[id]];
2967
+ detector$1 = _c.sent();
2968
+ detectorSettings$1 = {
2969
+ modelAssetPath: modelAssetPath
2970
+ };
2971
+ return [2 /*return*/, detector$1];
2975
2972
  }
2976
2973
  });
2977
2974
  });
2978
2975
  }
2979
- function closeFaceDetector(modelAssetPath) {
2980
- if (modelAssetPath === void 0) {
2981
- modelAssetPath = defaultFaceDetectorModelPath;
2982
- }
2983
- var id = "".concat(modelAssetPath);
2984
- if (!detectors$1[id]) return;
2985
- detectors$1[id].close();
2986
- delete detectors$1[id];
2976
+ function closeFaceDetector() {
2977
+ detector$1 === null || detector$1 === void 0 ? void 0 : detector$1.close();
2978
+ detector$1 = null;
2979
+ detectorSettings$1 = null;
2987
2980
  }
2988
2981
  function useLoadFaceDetector(_a) {
2989
2982
  var onModelError = _a.onModelError,
2990
2983
  _b = _a.modelLoadTimeoutMs,
2991
2984
  modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b;
2992
- var detector = useRef(null);
2993
2985
  var _c = useState(false),
2994
2986
  ready = _c[0],
2995
2987
  setReady = _c[1];
@@ -3015,7 +3007,6 @@ function useLoadFaceDetector(_a) {
3015
3007
  return __generator(this, function (_a) {
3016
3008
  switch (_a.label) {
3017
3009
  case 0:
3018
- detector.current = model;
3019
3010
  setModelDownloadProgress(100);
3020
3011
  clearTimeout(modelLoadTimeout);
3021
3012
  return [4 /*yield*/, waitForVideoReady(videoRef)];
@@ -3033,8 +3024,7 @@ function useLoadFaceDetector(_a) {
3033
3024
  clearTimeout(modelLoadTimeout);
3034
3025
  });
3035
3026
  return function () {
3036
- log('unloading face detection model', detector.current);
3037
- detector.current = null;
3027
+ log('unloading face detection model');
3038
3028
  closeFaceDetector();
3039
3029
  clearTimeout(modelLoadTimeout);
3040
3030
  document.removeEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
@@ -3044,7 +3034,6 @@ function useLoadFaceDetector(_a) {
3044
3034
  modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
3045
3035
  }, [modelError, onModelError]);
3046
3036
  return {
3047
- detector: detector,
3048
3037
  ready: ready,
3049
3038
  modelDownloadProgress: modelDownloadProgress,
3050
3039
  modelError: modelError
@@ -3083,8 +3072,9 @@ function trackFace(face, framesNeeded) {
3083
3072
  if (lastNPairs$1.length > framesNeeded - 1) lastNPairs$1.length = framesNeeded - 1;
3084
3073
  }
3085
3074
  }
3086
- function makeFaceDetectorPrediction(model, imageData) {
3087
- var prediction = model.detectForVideo(imageData, performance.now());
3075
+ function makeFaceDetectorPrediction(imageData) {
3076
+ if (!detector$1) return null;
3077
+ var prediction = detector$1.detectForVideo(imageData, performance.now());
3088
3078
  var faces = prediction.detections.map(function (d) {
3089
3079
  return {
3090
3080
  box: convertBoundingBox(d.boundingBox),
@@ -3416,33 +3406,32 @@ var documentTypeDisplayNames = {
3416
3406
  passport: 'Passport',
3417
3407
  none: 'None'
3418
3408
  };
3419
- var detectors = {};
3409
+ var detector = null;
3410
+ var detectorSettings = null;
3420
3411
  function loadDocumentDetector() {
3421
3412
  return __awaiter(this, arguments, void 0, function (modelAssetPath, scoreThreshold) {
3422
- var id, _a, _b, _c, _d;
3413
+ var _a, _b;
3423
3414
  if (modelAssetPath === void 0) {
3424
3415
  modelAssetPath = defaultDocumentDetectorModelPath;
3425
3416
  }
3426
3417
  if (scoreThreshold === void 0) {
3427
3418
  scoreThreshold = defaultDocumentDetectionScoreThreshold;
3428
3419
  }
3429
- return __generator(this, function (_e) {
3430
- switch (_e.label) {
3420
+ return __generator(this, function (_c) {
3421
+ switch (_c.label) {
3431
3422
  case 0:
3432
- id = "".concat(modelAssetPath, ":").concat(scoreThreshold);
3433
- if (detectors[id]) return [2 /*return*/, detectors[id]];
3423
+ 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];
3424
+ closeDocumentDetector();
3434
3425
  return [4 /*yield*/, preloadDocumentDetectorDependencies()];
3435
3426
  case 1:
3436
- _e.sent();
3427
+ _c.sent();
3437
3428
  if (modelCapabilities.delegate === 'NONE') {
3438
3429
  throw new Error('No available delegate for document detector.');
3439
3430
  }
3440
- _a = detectors;
3441
- _b = id;
3442
- _d = (_c = ObjectDetector).createFromOptions;
3431
+ _b = (_a = ObjectDetector).createFromOptions;
3443
3432
  return [4 /*yield*/, FilesetResolver.forVisionTasks(visionTasksBasePath)];
3444
3433
  case 2:
3445
- return [4 /*yield*/, _d.apply(_c, [_e.sent(), {
3434
+ return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
3446
3435
  baseOptions: {
3447
3436
  modelAssetPath: modelAssetPath,
3448
3437
  delegate: modelCapabilities.delegate
@@ -3452,23 +3441,20 @@ function loadDocumentDetector() {
3452
3441
  runningMode: 'VIDEO'
3453
3442
  }])];
3454
3443
  case 3:
3455
- _a[_b] = _e.sent();
3456
- return [2 /*return*/, detectors[id]];
3444
+ detector = _c.sent();
3445
+ detectorSettings = {
3446
+ modelAssetPath: modelAssetPath,
3447
+ scoreThreshold: scoreThreshold
3448
+ };
3449
+ return [2 /*return*/, detector];
3457
3450
  }
3458
3451
  });
3459
3452
  });
3460
3453
  }
3461
- function closeDocumentDetector(modelAssetPath, scoreThreshold) {
3462
- if (modelAssetPath === void 0) {
3463
- modelAssetPath = defaultDocumentDetectorModelPath;
3464
- }
3465
- if (scoreThreshold === void 0) {
3466
- scoreThreshold = defaultDocumentDetectionScoreThreshold;
3467
- }
3468
- var id = "".concat(modelAssetPath, ":").concat(scoreThreshold);
3469
- if (!detectors[id]) return;
3470
- detectors[id].close();
3471
- delete detectors[id];
3454
+ function closeDocumentDetector() {
3455
+ detector === null || detector === void 0 ? void 0 : detector.close();
3456
+ detector = null;
3457
+ detectorSettings = null;
3472
3458
  }
3473
3459
  function useLoadDocumentDetector(_a) {
3474
3460
  var _b = _a.modelPath,
@@ -3478,7 +3464,6 @@ function useLoadDocumentDetector(_a) {
3478
3464
  _d = _a.scoreThreshold,
3479
3465
  scoreThreshold = _d === void 0 ? defaultDocumentDetectionScoreThreshold : _d,
3480
3466
  onModelError = _a.onModelError;
3481
- var detector = useRef(null);
3482
3467
  var _e = useState(false),
3483
3468
  ready = _e[0],
3484
3469
  setReady = _e[1];
@@ -3504,7 +3489,6 @@ function useLoadDocumentDetector(_a) {
3504
3489
  return __generator(this, function (_a) {
3505
3490
  switch (_a.label) {
3506
3491
  case 0:
3507
- detector.current = model;
3508
3492
  setModelDownloadProgress(100);
3509
3493
  clearTimeout(modelLoadTimeout);
3510
3494
  return [4 /*yield*/, waitForVideoReady(videoRef)];
@@ -3525,8 +3509,7 @@ function useLoadDocumentDetector(_a) {
3525
3509
  });
3526
3510
  return function () {
3527
3511
  log('unloading document detection model');
3528
- detector.current = null;
3529
- closeDocumentDetector(modelPath, scoreThreshold);
3512
+ closeDocumentDetector();
3530
3513
  clearTimeout(modelLoadTimeout);
3531
3514
  document.removeEventListener('idmission.preloadProgress.documentDetection', handleDownloadProgress);
3532
3515
  };
@@ -3535,17 +3518,17 @@ function useLoadDocumentDetector(_a) {
3535
3518
  modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
3536
3519
  }, [modelError, onModelError]);
3537
3520
  return {
3538
- detector: detector,
3539
3521
  ready: ready,
3540
3522
  modelDownloadProgress: modelDownloadProgress,
3541
3523
  modelError: modelError,
3542
3524
  setModelError: setModelError
3543
3525
  };
3544
3526
  }
3545
- function makeDocumentDetectorPrediction(detector, frame) {
3527
+ function makeDocumentDetectorPrediction(frame) {
3546
3528
  return __awaiter(this, void 0, void 0, function () {
3547
3529
  var startedAt, prediction, time, frameWidth, frameHeight;
3548
3530
  return __generator(this, function (_a) {
3531
+ if (!detector) return [2 /*return*/, null];
3549
3532
  startedAt = new Date();
3550
3533
  // Detectors can throw errors, for example when using custom URLs that
3551
3534
  // contain a model that doesn't provide the expected output.
@@ -3869,7 +3852,6 @@ function DocumentDetectionModelProvider(_a) {
3869
3852
  scoreThreshold: documentDetectionModelScoreThreshold,
3870
3853
  onModelError: onDocumentDetectionModelError
3871
3854
  }),
3872
- detector = _o.detector,
3873
3855
  ready = _o.ready,
3874
3856
  modelDownloadProgress = _o.modelDownloadProgress,
3875
3857
  modelError = _o.modelError,
@@ -3881,7 +3863,7 @@ function DocumentDetectionModelProvider(_a) {
3881
3863
  return __generator(this, function (_b) {
3882
3864
  switch (_b.label) {
3883
3865
  case 0:
3884
- if (!videoLoaded || !cameraReady || !ready || !videoRef.current || !detector.current || !lastPredictionCanvas.current) return [2 /*return*/];
3866
+ if (!videoLoaded || !cameraReady || !ready || !videoRef.current || !lastPredictionCanvas.current) return [2 /*return*/];
3885
3867
  stopDetectionAtStart = stopDetection.current;
3886
3868
  vw = videoRef.current.videoWidth;
3887
3869
  vh = videoRef.current.videoHeight;
@@ -3891,7 +3873,7 @@ function DocumentDetectionModelProvider(_a) {
3891
3873
  if (!(ctx && videoRef.current.readyState === 4)) return [3 /*break*/, 3];
3892
3874
  if (stopDetectionAtStart !== stopDetection.current) return [2 /*return*/];
3893
3875
  ctx.drawImage(videoRef.current, 0, 0, vw, vh);
3894
- return [4 /*yield*/, makeDocumentDetectorPrediction(detector.current, lastPredictionCanvas.current)];
3876
+ return [4 /*yield*/, makeDocumentDetectorPrediction(lastPredictionCanvas.current)];
3895
3877
  case 1:
3896
3878
  prediction = _b.sent();
3897
3879
  if (!prediction) return [3 /*break*/, 3];
@@ -3913,7 +3895,7 @@ function DocumentDetectionModelProvider(_a) {
3913
3895
  }
3914
3896
  });
3915
3897
  });
3916
- }, [cameraReady, delayAfterStartMs, detector, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
3898
+ }, [cameraReady, delayAfterStartMs, documentDetectionBoundaries, documentDetectionThresholds, ready, videoLoaded, videoRef]), {
3917
3899
  throttleMs: throttleMs,
3918
3900
  autoStart: autoStart
3919
3901
  }),
@@ -3990,16 +3972,16 @@ function FocusModelProvider(_a) {
3990
3972
  modelLoadTimeoutMs: focusModelLoadTimeoutMs,
3991
3973
  onModelError: onFocusModelError
3992
3974
  }),
3993
- model = _f.model,
3994
3975
  ready = _f.ready,
3995
3976
  modelDownloadProgress = _f.modelDownloadProgress,
3996
3977
  modelError = _f.modelError;
3997
3978
  var makeFocusPrediction = useCallback(function (imageData, box) {
3998
- if (!model.current) return null;
3999
- var prediction = makeFocusModelPrediction(model.current, imageData, cropCanvas.current, rotateCanvas.current, box);
3979
+ if (!ready) return null;
3980
+ var prediction = makeFocusModelPrediction(imageData, cropCanvas.current, rotateCanvas.current, box);
3981
+ if (!prediction) return null;
4000
3982
  setLastFocusPredictionAt(prediction.predictionTime);
4001
3983
  return prediction;
4002
- }, [model]);
3984
+ }, [ready]);
4003
3985
  var value = useMemo(function () {
4004
3986
  return {
4005
3987
  focusModelReady: ready,
@@ -9222,18 +9204,17 @@ function SelfieGuidanceModelsProvider(_a) {
9222
9204
  onModelError: onModelError,
9223
9205
  modelLoadTimeoutMs: modelLoadTimeoutMs
9224
9206
  }),
9225
- detector = _f.detector,
9226
9207
  ready = _f.ready,
9227
9208
  modelDownloadProgress = _f.modelDownloadProgress,
9228
9209
  modelError = _f.modelError;
9229
9210
  var _g = useFrameLoop(useCallback(function () {
9230
9211
  return __awaiter(_this, void 0, void 0, function () {
9231
- var vw, vh, ctx, faces, processed, e_1;
9232
- var _a;
9233
- return __generator(this, function (_b) {
9234
- switch (_b.label) {
9212
+ var vw, vh, ctx, prediction, processed, e_1;
9213
+ var _a, _b;
9214
+ return __generator(this, function (_c) {
9215
+ switch (_c.label) {
9235
9216
  case 0:
9236
- if (!videoLoaded || !cameraReady || !ready || modelError || !videoRef.current || !detector.current || !canvasRef.current) return [2 /*return*/];
9217
+ if (!videoLoaded || !cameraReady || !ready || modelError || !videoRef.current || !canvasRef.current) return [2 /*return*/];
9237
9218
  vw = videoRef.current.videoWidth;
9238
9219
  vh = videoRef.current.videoHeight;
9239
9220
  ctx = canvasRef.current.getContext('2d');
@@ -9243,23 +9224,23 @@ function SelfieGuidanceModelsProvider(_a) {
9243
9224
  ctx.translate(vw, 0);
9244
9225
  ctx.scale(-1, 1);
9245
9226
  ctx.drawImage(videoRef.current, 0, 0, vw, vh);
9246
- _b.label = 1;
9227
+ _c.label = 1;
9247
9228
  case 1:
9248
- _b.trys.push([1, 3,, 4]);
9249
- faces = makeFaceDetectorPrediction(detector.current, canvasRef.current).faces;
9229
+ _c.trys.push([1, 3,, 4]);
9230
+ prediction = makeFaceDetectorPrediction(canvasRef.current);
9250
9231
  processed = processFaceDetectorPrediction({
9251
- faces: faces,
9232
+ faces: (_a = prediction === null || prediction === void 0 ? void 0 : prediction.faces) !== null && _a !== void 0 ? _a : [],
9252
9233
  videoWidth: vw,
9253
9234
  videoHeight: vh,
9254
9235
  requireVerticalFaceCentering: requireVerticalFaceCentering
9255
9236
  });
9256
9237
  setLastFaceDetectionAt(new Date().getTime());
9257
- return [4 /*yield*/, (_a = onPredictionHandler.current) === null || _a === void 0 ? void 0 : _a.call(onPredictionHandler, processed)];
9238
+ return [4 /*yield*/, (_b = onPredictionHandler.current) === null || _b === void 0 ? void 0 : _b.call(onPredictionHandler, processed)];
9258
9239
  case 2:
9259
- _b.sent();
9240
+ _c.sent();
9260
9241
  return [3 /*break*/, 4];
9261
9242
  case 3:
9262
- e_1 = _b.sent();
9243
+ e_1 = _c.sent();
9263
9244
  error('caught face detection error', e_1);
9264
9245
  return [3 /*break*/, 4];
9265
9246
  case 4:
@@ -9267,7 +9248,7 @@ function SelfieGuidanceModelsProvider(_a) {
9267
9248
  }
9268
9249
  });
9269
9250
  });
9270
- }, [cameraReady, detector, modelError, ready, requireVerticalFaceCentering, videoLoaded, videoRef]), {
9251
+ }, [cameraReady, modelError, ready, requireVerticalFaceCentering, videoLoaded, videoRef]), {
9271
9252
  throttleMs: throttleMs,
9272
9253
  autoStart: autoStart
9273
9254
  }),