idmission-web-sdk 1.0.255 → 1.0.257

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.
@@ -50,7 +50,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
50
50
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
51
51
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
52
52
 
53
- var webSdkVersion = '1.0.255';
53
+ var webSdkVersion = '1.0.257';
54
54
 
55
55
  function getPlatform() {
56
56
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -8881,64 +8881,55 @@ var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfie
8881
8881
  ctx === null || ctx === void 0 ? void 0 : ctx.scale(-1, 1);
8882
8882
  }
8883
8883
  return [4 /*yield*/, function renderPrediction() {
8884
- var _a;
8884
+ var _a, _b;
8885
8885
  return tslib.__awaiter(this, void 0, void 0, function () {
8886
- var vw, vh, prediction, faces;
8887
- return tslib.__generator(this, function (_b) {
8888
- switch (_b.label) {
8889
- case 0:
8890
- if (!detectorRef.current || !videoRef.current || currentLoopId !== loopId.current) return [2 /*return*/];
8891
- if (!(videoRef.current.readyState < 2)) return [3 /*break*/, 2];
8892
- return [4 /*yield*/, new Promise(function (resolve) {
8893
- if (videoRef.current) videoRef.current.onloadeddata = function () {
8894
- resolve([]);
8895
- };
8896
- })];
8897
- case 1:
8898
- _b.sent();
8899
- _b.label = 2;
8900
- case 2:
8901
- vw = videoRef.current.videoWidth;
8902
- vh = videoRef.current.videoHeight;
8903
- ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(videoRef.current, 0, 0, vw, vh);
8904
- // Detectors can throw errors, for example when using custom URLs that
8905
- // contain a model that doesn't provide the expected output.
8906
- try {
8907
- prediction = detectorRef.current.detectForVideo(videoRef.current, performance.now());
8908
- if (prediction) {
8909
- faces = prediction.detections.map(function (d) {
8910
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
8911
- return {
8912
- keypoints: d.keypoints.map(function (k) {
8913
- var _a;
8914
- return tslib.__assign(tslib.__assign({}, k), {
8915
- x: k.x * vw,
8916
- y: k.y * vh,
8917
- name: (_a = k.label) !== null && _a !== void 0 ? _a : ''
8918
- });
8919
- }),
8920
- box: {
8921
- xMin: (_b = (_a = d.boundingBox) === null || _a === void 0 ? void 0 : _a.originX) !== null && _b !== void 0 ? _b : 0,
8922
- xMax: ((_d = (_c = d.boundingBox) === null || _c === void 0 ? void 0 : _c.originX) !== null && _d !== void 0 ? _d : 0) + ((_f = (_e = d.boundingBox) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : 0),
8923
- yMin: (_h = (_g = d.boundingBox) === null || _g === void 0 ? void 0 : _g.originY) !== null && _h !== void 0 ? _h : 0,
8924
- yMax: ((_k = (_j = d.boundingBox) === null || _j === void 0 ? void 0 : _j.originY) !== null && _k !== void 0 ? _k : 0) + ((_m = (_l = d.boundingBox) === null || _l === void 0 ? void 0 : _l.height) !== null && _m !== void 0 ? _m : 0),
8925
- width: (_p = (_o = d.boundingBox) === null || _o === void 0 ? void 0 : _o.width) !== null && _p !== void 0 ? _p : 0,
8926
- height: (_r = (_q = d.boundingBox) === null || _q === void 0 ? void 0 : _q.height) !== null && _r !== void 0 ? _r : 0
8927
- }
8928
- };
8929
- });
8930
- (_a = onPredictionHandler.current) === null || _a === void 0 ? void 0 : _a.call(onPredictionHandler, faces);
8931
- ctx && drawResults(ctx, faces, true, true);
8932
- }
8933
- } catch (error) {
8934
- console.error('caught face detection error', error);
8935
- // detector.dispose()
8886
+ var ctx, vw_1, vh_1, prediction, faces;
8887
+ return tslib.__generator(this, function (_c) {
8888
+ if (!detectorRef.current || !videoRef.current || currentLoopId !== loopId.current) return [2 /*return*/];
8889
+ ctx = (_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.getContext('2d');
8890
+ if (ctx && videoRef.current.readyState === 4) {
8891
+ vw_1 = videoRef.current.videoWidth;
8892
+ vh_1 = videoRef.current.videoHeight;
8893
+ ctx.drawImage(videoRef.current, 0, 0, vw_1, vh_1);
8894
+ prediction = void 0;
8895
+ // Detectors can throw errors, for example when using custom URLs that
8896
+ // contain a model that doesn't provide the expected output.
8897
+ try {
8898
+ prediction = detectorRef.current.detectForVideo(canvasRef.current, performance.now());
8899
+ if (prediction) {
8900
+ faces = prediction.detections.map(function (d) {
8901
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
8902
+ return {
8903
+ keypoints: d.keypoints.map(function (k) {
8904
+ var _a;
8905
+ return tslib.__assign(tslib.__assign({}, k), {
8906
+ x: k.x * vw_1,
8907
+ y: k.y * vh_1,
8908
+ name: (_a = k.label) !== null && _a !== void 0 ? _a : ''
8909
+ });
8910
+ }),
8911
+ box: {
8912
+ xMin: (_b = (_a = d.boundingBox) === null || _a === void 0 ? void 0 : _a.originX) !== null && _b !== void 0 ? _b : 0,
8913
+ xMax: ((_d = (_c = d.boundingBox) === null || _c === void 0 ? void 0 : _c.originX) !== null && _d !== void 0 ? _d : 0) + ((_f = (_e = d.boundingBox) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : 0),
8914
+ yMin: (_h = (_g = d.boundingBox) === null || _g === void 0 ? void 0 : _g.originY) !== null && _h !== void 0 ? _h : 0,
8915
+ yMax: ((_k = (_j = d.boundingBox) === null || _j === void 0 ? void 0 : _j.originY) !== null && _k !== void 0 ? _k : 0) + ((_m = (_l = d.boundingBox) === null || _l === void 0 ? void 0 : _l.height) !== null && _m !== void 0 ? _m : 0),
8916
+ width: (_p = (_o = d.boundingBox) === null || _o === void 0 ? void 0 : _o.width) !== null && _p !== void 0 ? _p : 0,
8917
+ height: (_r = (_q = d.boundingBox) === null || _q === void 0 ? void 0 : _q.height) !== null && _r !== void 0 ? _r : 0
8918
+ }
8919
+ };
8920
+ });
8921
+ (_b = onPredictionHandler.current) === null || _b === void 0 ? void 0 : _b.call(onPredictionHandler, faces);
8922
+ ctx && drawResults(ctx, faces, true, true);
8936
8923
  }
8937
- timer = setTimeout(function () {
8938
- rafId.current = requestAnimationFrame(renderPrediction);
8939
- }, throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0);
8940
- return [2 /*return*/];
8924
+ } catch (error) {
8925
+ console.error('caught face detection error', error);
8926
+ // detector.dispose()
8927
+ }
8941
8928
  }
8929
+ timer = setTimeout(function () {
8930
+ rafId.current = requestAnimationFrame(renderPrediction);
8931
+ }, throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0);
8932
+ return [2 /*return*/];
8942
8933
  });
8943
8934
  });
8944
8935
  }()];
@@ -8982,7 +8973,9 @@ var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfie
8982
8973
  }, [error, modelDownloadProgress, onPredictionMade, ready, start, stop]);
8983
8974
  return /*#__PURE__*/React__namespace.createElement(HighPerformanceSelfieGuidanceModelsContext.Provider, {
8984
8975
  value: value
8985
- }, children);
8976
+ }, /*#__PURE__*/React__namespace.createElement(InvisibleCanvas, {
8977
+ ref: canvasRef
8978
+ }), children);
8986
8979
  };
8987
8980
 
8988
8981
  var preloadModels = function preloadModels(_a) {
@@ -12405,41 +12398,41 @@ var reducer$3 = function reducer(state, action) {
12405
12398
  }
12406
12399
  };
12407
12400
  var SelfieCapture = function SelfieCapture(_a) {
12408
- var _b, _c;
12401
+ var _b;
12409
12402
  var onGuidanceSatisfied = _a.onGuidanceSatisfied,
12410
12403
  onGuidanceNotSatisfied = _a.onGuidanceNotSatisfied,
12411
12404
  onSelfieCaptured = _a.onSelfieCaptured,
12412
12405
  onTimeout = _a.onTimeout,
12413
12406
  onExit = _a.onExit,
12414
- _d = _a.timeoutDurationMs,
12415
- timeoutDurationMs = _d === void 0 ? 15000 : _d,
12407
+ _c = _a.timeoutDurationMs,
12408
+ timeoutDurationMs = _c === void 0 ? 15000 : _c,
12416
12409
  guidanceMessage = _a.guidanceMessage,
12417
12410
  guidanceSatisfied = _a.guidanceSatisfied,
12418
- _e = _a.classNames,
12419
- classNames = _e === void 0 ? {} : _e,
12420
- _f = _a.colors,
12421
- colors = _f === void 0 ? {} : _f,
12422
- _g = _a.verbiage,
12423
- rawVerbiage = _g === void 0 ? {} : _g,
12424
- _h = _a.debugMode,
12425
- debugMode = _h === void 0 ? false : _h;
12426
- var _j = useResizeObserver__default['default'](),
12427
- ref = _j.ref,
12428
- _k = _j.width,
12429
- width = _k === void 0 ? 1 : _k,
12430
- _l = _j.height,
12431
- height = _l === void 0 ? 1 : _l;
12432
- var _m = React.useReducer(reducer$3, initialState$3),
12433
- state = _m[0],
12434
- dispatch = _m[1];
12411
+ _d = _a.classNames,
12412
+ classNames = _d === void 0 ? {} : _d,
12413
+ _e = _a.colors,
12414
+ colors = _e === void 0 ? {} : _e,
12415
+ _f = _a.verbiage,
12416
+ rawVerbiage = _f === void 0 ? {} : _f,
12417
+ _g = _a.debugMode,
12418
+ debugMode = _g === void 0 ? false : _g;
12419
+ var _h = useResizeObserver__default['default'](),
12420
+ ref = _h.ref,
12421
+ _j = _h.width,
12422
+ width = _j === void 0 ? 1 : _j,
12423
+ _k = _h.height,
12424
+ height = _k === void 0 ? 1 : _k;
12425
+ var _l = React.useReducer(reducer$3, initialState$3),
12426
+ state = _l[0],
12427
+ dispatch = _l[1];
12435
12428
  var lastPredictionCanvas = React.useRef(null);
12436
- var _o = React.useContext(CameraStateContext),
12437
- cameraRef = _o.cameraRef,
12438
- cameraReady = _o.cameraReady,
12439
- videoRef = _o.videoRef;
12440
- var _p = React.useContext(HighPerformanceSelfieGuidanceModelsContext),
12441
- onPredictionMade = _p.onPredictionMade,
12442
- guidanceError = _p.error;
12429
+ var _m = React.useContext(CameraStateContext),
12430
+ cameraRef = _m.cameraRef,
12431
+ cameraReady = _m.cameraReady,
12432
+ videoRef = _m.videoRef;
12433
+ var _o = React.useContext(HighPerformanceSelfieGuidanceModelsContext),
12434
+ onPredictionMade = _o.onPredictionMade,
12435
+ guidanceError = _o.error;
12443
12436
  React.useEffect(function () {
12444
12437
  if (cameraReady && videoRef.current && videoRef.current.videoWidth !== 0) {
12445
12438
  dispatch({
@@ -12461,9 +12454,9 @@ var SelfieCapture = function SelfieCapture(_a) {
12461
12454
  });
12462
12455
  });
12463
12456
  }, [onPredictionMade]);
12464
- var _q = React.useState(false),
12465
- captureReady = _q[0],
12466
- setCaptureReady = _q[1];
12457
+ var _p = React.useState(false),
12458
+ captureReady = _p[0],
12459
+ setCaptureReady = _p[1];
12467
12460
  React.useEffect(function () {
12468
12461
  var timer;
12469
12462
  if (state.faceReady) {
@@ -12496,9 +12489,9 @@ var SelfieCapture = function SelfieCapture(_a) {
12496
12489
  });
12497
12490
  })();
12498
12491
  }, [captureReady, onSelfieCaptured, state.faces, videoRef]);
12499
- var _r = useTimeout(timeoutDurationMs, onTimeout),
12500
- timedOut = _r.timedOut,
12501
- timeoutStartedAt = _r.timeoutStartedAt;
12492
+ var _q = useTimeout(timeoutDurationMs, onTimeout),
12493
+ timedOut = _q.timedOut,
12494
+ timeoutStartedAt = _q.timeoutStartedAt;
12502
12495
  var debugScalingDetails = useDebugScalingDetails({
12503
12496
  enabled: debugMode,
12504
12497
  pageWidth: width,
@@ -12538,15 +12531,11 @@ var SelfieCapture = function SelfieCapture(_a) {
12538
12531
  }, /*#__PURE__*/React__default['default'].createElement(GuidanceMessage, {
12539
12532
  "$variant": satisfied ? 'positive' : 'negative',
12540
12533
  className: classNames.guidanceMessage
12541
- }, guidanceMessage))), debugMode && state.faces.length > 0 && ( /*#__PURE__*/React__default['default'].createElement(ObjectDetectionDebugOverlayDiv, {
12542
- "$flipX": !((_c = cameraRef.current) === null || _c === void 0 ? void 0 : _c.isRearFacing)
12543
- }, state.faces.map(function (face, i) {
12544
- var _a;
12534
+ }, guidanceMessage))), debugMode && state.faces.length > 0 && ( /*#__PURE__*/React__default['default'].createElement(ObjectDetectionDebugOverlayDiv, null, state.faces.map(function (face, i) {
12545
12535
  return /*#__PURE__*/React__default['default'].createElement(SelfieCaptureFaceDebugBox, {
12546
12536
  key: i,
12547
12537
  face: face,
12548
12538
  scaling: debugScalingDetails,
12549
- flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing),
12550
12539
  color: satisfied ? 'green' : 'red'
12551
12540
  });
12552
12541
  }))), debugMode && ( /*#__PURE__*/React__default['default'].createElement(DebugStatsPane, null, cameraRef.current ? ( /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, "\u2705 Camera: ", cameraRef.current.label, " (", cameraRef.current.width, "x", cameraRef.current.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceNotCentered ? '✅' : '❌', " Face Centered", /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceTooClose && !state.faceTooFar ? '✅' : '❌', " Face", ' ', state.faceTooClose ? 'Too Close' : state.faceTooFar ? 'Too Far' : 'Distance Correct', /*#__PURE__*/React__default['default'].createElement("br", null), !state.faceLookingAway ? '✅' : '❌', " Face Looking Forward", /*#__PURE__*/React__default['default'].createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " ", state.goodFramesCount, ' ', "Good Frames", /*#__PURE__*/React__default['default'].createElement("br", null), !timedOut ? '✅' : '❌', " Time Remaining:", ' ', Math.max(0, timeoutDurationMs - (new Date().getTime() - (timeoutStartedAt !== null && timeoutStartedAt !== void 0 ? timeoutStartedAt : new Date()).getTime())), "ms")), /*#__PURE__*/React__default['default'].createElement(ExitCaptureButton, {