idmission-web-sdk 2.1.76 → 2.1.78

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.
@@ -33,4 +33,7 @@ export declare function useLoadFocusModel({ modelPath, modelLoadTimeoutMs, onMod
33
33
  modelDownloadProgress: number;
34
34
  modelError: Error | null;
35
35
  };
36
+ export declare let lastFocusPredictionAt: number;
37
+ export declare let lastFocusPredictionTime: number;
38
+ export declare function setLastFocusPredictionAt(time: number): void;
36
39
  export declare function makeFocusModelPrediction(model: ImageClassifier, imageData: Frame, cropCanvas: HTMLCanvasElement, rotateCanvas: HTMLCanvasElement, box?: DetectedObjectBox): FocusPrediction;
@@ -234,7 +234,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
234
234
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
235
235
  };
236
236
 
237
- var webSdkVersion = '2.1.76';
237
+ var webSdkVersion = '2.1.78';
238
238
 
239
239
  function getPlatform() {
240
240
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2872,6 +2872,12 @@ function useLoadFocusModel(_a) {
2872
2872
  modelError: modelError
2873
2873
  };
2874
2874
  }
2875
+ var lastFocusPredictionAt = 0;
2876
+ var lastFocusPredictionTime = 0;
2877
+ function setLastFocusPredictionAt(time) {
2878
+ lastFocusPredictionTime = time - lastFocusPredictionAt;
2879
+ lastFocusPredictionAt = time;
2880
+ }
2875
2881
  function makeFocusModelPrediction(model, imageData, cropCanvas, rotateCanvas, box) {
2876
2882
  var _a, _b, _c, _d, _e;
2877
2883
  var startedAt = new Date();
@@ -5984,22 +5990,19 @@ function FocusModelProvider(_a) {
5984
5990
  var _e = React.useState({}),
5985
5991
  focusThresholds = _e[0],
5986
5992
  setFocusThresholds = _e[1];
5987
- var _f = React.useState(0),
5988
- focusPredictionTime = _f[0],
5989
- setFocusPredictionTime = _f[1];
5990
- var _g = useLoadFocusModel({
5993
+ var _f = useLoadFocusModel({
5991
5994
  modelPath: focusModelPath,
5992
5995
  modelLoadTimeoutMs: focusModelLoadTimeoutMs,
5993
5996
  onModelError: onFocusModelError
5994
5997
  }),
5995
- model = _g.model,
5996
- ready = _g.ready,
5997
- modelDownloadProgress = _g.modelDownloadProgress,
5998
- modelError = _g.modelError;
5998
+ model = _f.model,
5999
+ ready = _f.ready,
6000
+ modelDownloadProgress = _f.modelDownloadProgress,
6001
+ modelError = _f.modelError;
5999
6002
  var makeFocusPrediction = React.useCallback(function (imageData, box) {
6000
6003
  if (!model.current) return null;
6001
6004
  var prediction = makeFocusModelPrediction(model.current, imageData, cropCanvas.current, rotateCanvas.current, box);
6002
- setFocusPredictionTime(prediction.predictionTime);
6005
+ setLastFocusPredictionAt(prediction.predictionTime);
6003
6006
  return prediction;
6004
6007
  }, [model]);
6005
6008
  var value = React.useMemo(function () {
@@ -6008,11 +6011,11 @@ function FocusModelProvider(_a) {
6008
6011
  focusModelDownloadProgress: modelDownloadProgress,
6009
6012
  focusModelError: modelError,
6010
6013
  makeFocusPrediction: makeFocusPrediction,
6011
- focusPredictionTime: focusPredictionTime,
6014
+ focusPredictionTime: lastFocusPredictionTime,
6012
6015
  focusThresholds: focusThresholds,
6013
6016
  setFocusThresholds: setFocusThresholds
6014
6017
  };
6015
- }, [focusPredictionTime, focusThresholds, makeFocusPrediction, modelDownloadProgress, modelError, ready]);
6018
+ }, [focusThresholds, makeFocusPrediction, modelDownloadProgress, modelError, ready]);
6016
6019
  return /*#__PURE__*/React__namespace.default.createElement(FocusModelContext.Provider, {
6017
6020
  value: value
6018
6021
  }, /*#__PURE__*/React__namespace.default.createElement(InvisibleCanvas, {
@@ -8435,38 +8438,23 @@ function IdCardBorderSvg(_a) {
8435
8438
  _b = _a.borderOpacity,
8436
8439
  borderOpacity = _b === void 0 ? 1 : _b,
8437
8440
  _c = _a.progress,
8438
- progress = _c === void 0 ? 1 : _c,
8441
+ progress = _c === void 0 ? 0 : _c,
8439
8442
  _d = _a.progressPaused,
8440
8443
  progressPaused = _d === void 0 ? false : _d,
8441
8444
  _e = _a.isProgressBar,
8442
8445
  isProgressBar = _e === void 0 ? false : _e,
8443
8446
  props = __rest(_a, ["borderRadius", "borderColor", "borderWidth", "borderOpacity", "progress", "progressPaused", "isProgressBar"]);
8444
- var rectRef = React.useRef(null);
8445
8447
  var _f = React.useState(0),
8446
8448
  totalLength = _f[0],
8447
8449
  setTotalLength = _f[1];
8448
8450
  var resolvedProgress = progress * totalLength;
8449
- React.useLayoutEffect(function () {
8450
- if (totalLength > 0) return;
8451
- var interval;
8452
- var measuredLength = 0;
8453
- function measureTotalLength() {
8454
- var _a, _b;
8455
- try {
8456
- measuredLength = (_b = (_a = rectRef.current) === null || _a === void 0 ? void 0 : _a.getTotalLength()) !== null && _b !== void 0 ? _b : 0;
8457
- if (measuredLength === 0) return;
8458
- setTotalLength(measuredLength);
8459
- if (interval) clearInterval(interval);
8460
- } catch (e) {
8461
- warn('failed to measure SVG length', e);
8462
- }
8451
+ var rectRef = function rectRef(r) {
8452
+ try {
8453
+ if (isProgressBar && r) setTotalLength(r.getTotalLength());
8454
+ } catch (e) {
8455
+ debug('failed to measure SVG length', e);
8463
8456
  }
8464
- measureTotalLength();
8465
- if (measuredLength === 0) interval = setInterval(measureTotalLength, 250);
8466
- return function () {
8467
- if (interval) clearInterval(interval);
8468
- };
8469
- }, [totalLength]);
8457
+ };
8470
8458
  return /*#__PURE__*/React__namespace.default.createElement(SvgOverlay, _assign({
8471
8459
  height: "100%",
8472
8460
  fill: "none",
@@ -8499,7 +8487,7 @@ function IdCardBorderSvg(_a) {
8499
8487
  }
8500
8488
  var IdCardBorderContainer = styled__default.default.div(templateObject_3$j || (templateObject_3$j = __makeTemplateObject(["\n & > .pulse {\n position: absolute;\n animation: glow-grow 2s ease-out infinite;\n\n &:nth-child(2) {\n animation-delay: 0.66s;\n }\n\n &:nth-child(3) {\n animation-delay: 1.33s;\n }\n }\n\n @keyframes glow-grow {\n 0% {\n opacity: 0;\n transform: scale(1);\n }\n 50% {\n opacity: 1;\n }\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n }\n"], ["\n & > .pulse {\n position: absolute;\n animation: glow-grow 2s ease-out infinite;\n\n &:nth-child(2) {\n animation-delay: 0.66s;\n }\n\n &:nth-child(3) {\n animation-delay: 1.33s;\n }\n }\n\n @keyframes glow-grow {\n 0% {\n opacity: 0;\n transform: scale(1);\n }\n 50% {\n opacity: 1;\n }\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n }\n"])));
8501
8489
  var SvgOverlay = styled__default.default.svg(templateObject_4$d || (templateObject_4$d = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n"])));
8502
- var IdCardBorderRect = styled__default.default.rect(templateObject_5$8 || (templateObject_5$8 = __makeTemplateObject(["\n &.progress {\n width: 100%;\n height: 100%;\n animation: dash ", "\n ", ";\n }\n\n &.paused {\n animation-play-state: paused;\n }\n\n @keyframes dash {\n to {\n stroke-dashoffset: 0;\n }\n }\n"], ["\n &.progress {\n width: 100%;\n height: 100%;\n animation: dash ", "\n ", ";\n }\n\n &.paused {\n animation-play-state: paused;\n }\n\n @keyframes dash {\n to {\n stroke-dashoffset: 0;\n }\n }\n"])), function (props) {
8490
+ var IdCardBorderRect = styled__default.default.rect(templateObject_5$8 || (templateObject_5$8 = __makeTemplateObject(["\n &.progress {\n animation: dash ", "\n ", ";\n }\n\n &.paused {\n animation-play-state: paused;\n }\n\n @keyframes dash {\n to {\n stroke-dashoffset: 0;\n }\n }\n"], ["\n &.progress {\n animation: dash ", "\n ", ";\n }\n\n &.paused {\n animation-play-state: paused;\n }\n\n @keyframes dash {\n to {\n stroke-dashoffset: 0;\n }\n }\n"])), function (props) {
8503
8491
  var _a;
8504
8492
  return (_a = props.$speed) !== null && _a !== void 0 ? _a : '3s';
8505
8493
  }, function (props) {
@@ -13726,14 +13714,13 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
13726
13714
  idCardGuideStatus = _1 === void 0 ? 'ready' : _1,
13727
13715
  idCardGuideBorderWidth = _a.idCardGuideBorderWidth,
13728
13716
  idCardGuideBorderColor = _a.idCardGuideBorderColor,
13729
- _2 = _a.idCardCaptureProgress,
13730
- idCardCaptureProgress = _2 === void 0 ? 0 : _2,
13731
- _3 = _a.idCardCaptureGuideImages,
13732
- userSuppliedImages = _3 === void 0 ? defaultIdCaptureGuideImages : _3,
13733
- _4 = _a.classNames,
13734
- classNames = _4 === void 0 ? {} : _4,
13735
- _5 = _a.verbiage,
13736
- rawVerbiage = _5 === void 0 ? {} : _5;
13717
+ idCardCaptureProgress = _a.idCardCaptureProgress,
13718
+ _2 = _a.idCardCaptureGuideImages,
13719
+ userSuppliedImages = _2 === void 0 ? defaultIdCaptureGuideImages : _2,
13720
+ _3 = _a.classNames,
13721
+ classNames = _3 === void 0 ? {} : _3,
13722
+ _4 = _a.verbiage,
13723
+ rawVerbiage = _4 === void 0 ? {} : _4;
13737
13724
  var cameraRef = React.useContext(CameraStateContext).cameraRef;
13738
13725
  var verbiage = useTranslations(rawVerbiage, {
13739
13726
  idFrontInstructionText: 'Display the front of your ID card...',
@@ -13747,17 +13734,17 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
13747
13734
  if (faceGuideBorderColor === undefined) faceGuideBorderColor = (_j = satisfied ? (_f = (_e = theme.idVideoCapture) === null || _e === void 0 ? void 0 : _e.faceGuides) === null || _f === void 0 ? void 0 : _f.satisfiedColor : (_h = (_g = theme.idVideoCapture) === null || _g === void 0 ? void 0 : _g.faceGuides) === null || _h === void 0 ? void 0 : _h.unsatisfiedColor) !== null && _j !== void 0 ? _j : '#D6DCE7';
13748
13735
  if (idCardGuideBorderWidth === undefined) idCardGuideBorderWidth = (_m = (_l = (_k = theme.idVideoCapture) === null || _k === void 0 ? void 0 : _k.idCardGuides) === null || _l === void 0 ? void 0 : _l.borderWidth) !== null && _m !== void 0 ? _m : 20;
13749
13736
  if (idCardGuideBorderColor === undefined) idCardGuideBorderColor = (_s = satisfied ? (_p = (_o = theme.idVideoCapture) === null || _o === void 0 ? void 0 : _o.idCardGuides) === null || _p === void 0 ? void 0 : _p.satisfiedColor : (_r = (_q = theme.idVideoCapture) === null || _q === void 0 ? void 0 : _q.idCardGuides) === null || _r === void 0 ? void 0 : _r.unsatisfiedColor) !== null && _s !== void 0 ? _s : '#D6DCE7';
13750
- var _6 = useResizeObserver__default.default(),
13751
- idCardGuideRef = _6.ref,
13752
- _7 = _6.width,
13753
- idCardGuideWidth = _7 === void 0 ? 0 : _7,
13754
- _8 = _6.height,
13755
- idCardGuideHeight = _8 === void 0 ? 0 : _8;
13737
+ var _5 = useResizeObserver__default.default(),
13738
+ idCardGuideRef = _5.ref,
13739
+ _6 = _5.width,
13740
+ idCardGuideWidth = _6 === void 0 ? 0 : _6,
13741
+ _7 = _5.height,
13742
+ idCardGuideHeight = _7 === void 0 ? 0 : _7;
13756
13743
  var idCaptureGuideImages = useGuideImages(userSuppliedImages);
13757
13744
  var idCaptureGuideImagesByUrl = useGuideImagesByUrl(idCaptureGuideImages);
13758
- var _9 = React.useState(undefined),
13759
- aspectRatio = _9[0],
13760
- setAspectRatio = _9[1];
13745
+ var _8 = React.useState(undefined),
13746
+ aspectRatio = _8[0],
13747
+ setAspectRatio = _8[1];
13761
13748
  var onImageLoaded = React.useCallback(function (e) {
13762
13749
  var _a, _b, _c, _d;
13763
13750
  var img = e.currentTarget;
@@ -13799,7 +13786,7 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
13799
13786
  borderColor: idCardGuideBorderColor,
13800
13787
  aspectRatio: aspectRatio,
13801
13788
  "$isVisible": requestedAction !== 'FLIP_ID',
13802
- progress: requestedAction === 'VERIFY_LIVENESS' ? 0 : idCardCaptureProgress
13789
+ progress: requestedAction === 'VERIFY_LIVENESS' ? undefined : idCardCaptureProgress
13803
13790
  }, /*#__PURE__*/React__namespace.default.createElement(IdCardGuideImage, {
13804
13791
  alt: "",
13805
13792
  className: classNames.idCardGuideImage,
@@ -14326,7 +14313,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14326
14313
  requestedAction: requestedAction,
14327
14314
  satisfied: satisfied,
14328
14315
  idCardGuideStatus: countdownStartedAt ? 'capturing' : 'ready',
14329
- idCardCaptureProgress: countdownStartedAt ? 1 : 0,
14316
+ idCardCaptureProgress: !!countdownStartedAt ? 1 : 0,
14330
14317
  idCardCaptureGuideImages: idCardCaptureGuideImages,
14331
14318
  faceGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor,
14332
14319
  idCardGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor