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.
package/dist/sdk2.esm.js CHANGED
@@ -204,7 +204,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
204
204
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
205
205
  };
206
206
 
207
- var webSdkVersion = '2.1.76';
207
+ var webSdkVersion = '2.1.78';
208
208
 
209
209
  function getPlatform() {
210
210
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2842,6 +2842,12 @@ function useLoadFocusModel(_a) {
2842
2842
  modelError: modelError
2843
2843
  };
2844
2844
  }
2845
+ var lastFocusPredictionAt = 0;
2846
+ var lastFocusPredictionTime = 0;
2847
+ function setLastFocusPredictionAt(time) {
2848
+ lastFocusPredictionTime = time - lastFocusPredictionAt;
2849
+ lastFocusPredictionAt = time;
2850
+ }
2845
2851
  function makeFocusModelPrediction(model, imageData, cropCanvas, rotateCanvas, box) {
2846
2852
  var _a, _b, _c, _d, _e;
2847
2853
  var startedAt = new Date();
@@ -5954,22 +5960,19 @@ function FocusModelProvider(_a) {
5954
5960
  var _e = useState({}),
5955
5961
  focusThresholds = _e[0],
5956
5962
  setFocusThresholds = _e[1];
5957
- var _f = useState(0),
5958
- focusPredictionTime = _f[0],
5959
- setFocusPredictionTime = _f[1];
5960
- var _g = useLoadFocusModel({
5963
+ var _f = useLoadFocusModel({
5961
5964
  modelPath: focusModelPath,
5962
5965
  modelLoadTimeoutMs: focusModelLoadTimeoutMs,
5963
5966
  onModelError: onFocusModelError
5964
5967
  }),
5965
- model = _g.model,
5966
- ready = _g.ready,
5967
- modelDownloadProgress = _g.modelDownloadProgress,
5968
- modelError = _g.modelError;
5968
+ model = _f.model,
5969
+ ready = _f.ready,
5970
+ modelDownloadProgress = _f.modelDownloadProgress,
5971
+ modelError = _f.modelError;
5969
5972
  var makeFocusPrediction = useCallback(function (imageData, box) {
5970
5973
  if (!model.current) return null;
5971
5974
  var prediction = makeFocusModelPrediction(model.current, imageData, cropCanvas.current, rotateCanvas.current, box);
5972
- setFocusPredictionTime(prediction.predictionTime);
5975
+ setLastFocusPredictionAt(prediction.predictionTime);
5973
5976
  return prediction;
5974
5977
  }, [model]);
5975
5978
  var value = useMemo(function () {
@@ -5978,11 +5981,11 @@ function FocusModelProvider(_a) {
5978
5981
  focusModelDownloadProgress: modelDownloadProgress,
5979
5982
  focusModelError: modelError,
5980
5983
  makeFocusPrediction: makeFocusPrediction,
5981
- focusPredictionTime: focusPredictionTime,
5984
+ focusPredictionTime: lastFocusPredictionTime,
5982
5985
  focusThresholds: focusThresholds,
5983
5986
  setFocusThresholds: setFocusThresholds
5984
5987
  };
5985
- }, [focusPredictionTime, focusThresholds, makeFocusPrediction, modelDownloadProgress, modelError, ready]);
5988
+ }, [focusThresholds, makeFocusPrediction, modelDownloadProgress, modelError, ready]);
5986
5989
  return /*#__PURE__*/React__default.createElement(FocusModelContext.Provider, {
5987
5990
  value: value
5988
5991
  }, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
@@ -8405,38 +8408,23 @@ function IdCardBorderSvg(_a) {
8405
8408
  _b = _a.borderOpacity,
8406
8409
  borderOpacity = _b === void 0 ? 1 : _b,
8407
8410
  _c = _a.progress,
8408
- progress = _c === void 0 ? 1 : _c,
8411
+ progress = _c === void 0 ? 0 : _c,
8409
8412
  _d = _a.progressPaused,
8410
8413
  progressPaused = _d === void 0 ? false : _d,
8411
8414
  _e = _a.isProgressBar,
8412
8415
  isProgressBar = _e === void 0 ? false : _e,
8413
8416
  props = __rest(_a, ["borderRadius", "borderColor", "borderWidth", "borderOpacity", "progress", "progressPaused", "isProgressBar"]);
8414
- var rectRef = useRef(null);
8415
8417
  var _f = useState(0),
8416
8418
  totalLength = _f[0],
8417
8419
  setTotalLength = _f[1];
8418
8420
  var resolvedProgress = progress * totalLength;
8419
- useLayoutEffect(function () {
8420
- if (totalLength > 0) return;
8421
- var interval;
8422
- var measuredLength = 0;
8423
- function measureTotalLength() {
8424
- var _a, _b;
8425
- try {
8426
- measuredLength = (_b = (_a = rectRef.current) === null || _a === void 0 ? void 0 : _a.getTotalLength()) !== null && _b !== void 0 ? _b : 0;
8427
- if (measuredLength === 0) return;
8428
- setTotalLength(measuredLength);
8429
- if (interval) clearInterval(interval);
8430
- } catch (e) {
8431
- warn('failed to measure SVG length', e);
8432
- }
8421
+ var rectRef = function rectRef(r) {
8422
+ try {
8423
+ if (isProgressBar && r) setTotalLength(r.getTotalLength());
8424
+ } catch (e) {
8425
+ debug('failed to measure SVG length', e);
8433
8426
  }
8434
- measureTotalLength();
8435
- if (measuredLength === 0) interval = setInterval(measureTotalLength, 250);
8436
- return function () {
8437
- if (interval) clearInterval(interval);
8438
- };
8439
- }, [totalLength]);
8427
+ };
8440
8428
  return /*#__PURE__*/React__default.createElement(SvgOverlay, _assign({
8441
8429
  height: "100%",
8442
8430
  fill: "none",
@@ -8469,7 +8457,7 @@ function IdCardBorderSvg(_a) {
8469
8457
  }
8470
8458
  var IdCardBorderContainer = styled.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"])));
8471
8459
  var SvgOverlay = styled.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"])));
8472
- var IdCardBorderRect = styled.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) {
8460
+ var IdCardBorderRect = styled.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) {
8473
8461
  var _a;
8474
8462
  return (_a = props.$speed) !== null && _a !== void 0 ? _a : '3s';
8475
8463
  }, function (props) {
@@ -13696,14 +13684,13 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
13696
13684
  idCardGuideStatus = _1 === void 0 ? 'ready' : _1,
13697
13685
  idCardGuideBorderWidth = _a.idCardGuideBorderWidth,
13698
13686
  idCardGuideBorderColor = _a.idCardGuideBorderColor,
13699
- _2 = _a.idCardCaptureProgress,
13700
- idCardCaptureProgress = _2 === void 0 ? 0 : _2,
13701
- _3 = _a.idCardCaptureGuideImages,
13702
- userSuppliedImages = _3 === void 0 ? defaultIdCaptureGuideImages : _3,
13703
- _4 = _a.classNames,
13704
- classNames = _4 === void 0 ? {} : _4,
13705
- _5 = _a.verbiage,
13706
- rawVerbiage = _5 === void 0 ? {} : _5;
13687
+ idCardCaptureProgress = _a.idCardCaptureProgress,
13688
+ _2 = _a.idCardCaptureGuideImages,
13689
+ userSuppliedImages = _2 === void 0 ? defaultIdCaptureGuideImages : _2,
13690
+ _3 = _a.classNames,
13691
+ classNames = _3 === void 0 ? {} : _3,
13692
+ _4 = _a.verbiage,
13693
+ rawVerbiage = _4 === void 0 ? {} : _4;
13707
13694
  var cameraRef = useContext(CameraStateContext).cameraRef;
13708
13695
  var verbiage = useTranslations(rawVerbiage, {
13709
13696
  idFrontInstructionText: 'Display the front of your ID card...',
@@ -13717,17 +13704,17 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
13717
13704
  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';
13718
13705
  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;
13719
13706
  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';
13720
- var _6 = useResizeObserver(),
13721
- idCardGuideRef = _6.ref,
13722
- _7 = _6.width,
13723
- idCardGuideWidth = _7 === void 0 ? 0 : _7,
13724
- _8 = _6.height,
13725
- idCardGuideHeight = _8 === void 0 ? 0 : _8;
13707
+ var _5 = useResizeObserver(),
13708
+ idCardGuideRef = _5.ref,
13709
+ _6 = _5.width,
13710
+ idCardGuideWidth = _6 === void 0 ? 0 : _6,
13711
+ _7 = _5.height,
13712
+ idCardGuideHeight = _7 === void 0 ? 0 : _7;
13726
13713
  var idCaptureGuideImages = useGuideImages(userSuppliedImages);
13727
13714
  var idCaptureGuideImagesByUrl = useGuideImagesByUrl(idCaptureGuideImages);
13728
- var _9 = useState(undefined),
13729
- aspectRatio = _9[0],
13730
- setAspectRatio = _9[1];
13715
+ var _8 = useState(undefined),
13716
+ aspectRatio = _8[0],
13717
+ setAspectRatio = _8[1];
13731
13718
  var onImageLoaded = useCallback(function (e) {
13732
13719
  var _a, _b, _c, _d;
13733
13720
  var img = e.currentTarget;
@@ -13769,7 +13756,7 @@ var IdVideoCaptureGuides = function IdVideoCaptureGuides(_a) {
13769
13756
  borderColor: idCardGuideBorderColor,
13770
13757
  aspectRatio: aspectRatio,
13771
13758
  "$isVisible": requestedAction !== 'FLIP_ID',
13772
- progress: requestedAction === 'VERIFY_LIVENESS' ? 0 : idCardCaptureProgress
13759
+ progress: requestedAction === 'VERIFY_LIVENESS' ? undefined : idCardCaptureProgress
13773
13760
  }, /*#__PURE__*/React__default.createElement(IdCardGuideImage, {
13774
13761
  alt: "",
13775
13762
  className: classNames.idCardGuideImage,
@@ -14296,7 +14283,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
14296
14283
  requestedAction: requestedAction,
14297
14284
  satisfied: satisfied,
14298
14285
  idCardGuideStatus: countdownStartedAt ? 'capturing' : 'ready',
14299
- idCardCaptureProgress: countdownStartedAt ? 1 : 0,
14286
+ idCardCaptureProgress: !!countdownStartedAt ? 1 : 0,
14300
14287
  idCardCaptureGuideImages: idCardCaptureGuideImages,
14301
14288
  faceGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor,
14302
14289
  idCardGuideBorderColor: satisfied ? colors.guidesSatisfiedColor : colors.guidesUnsatisfiedColor