idmission-web-sdk 1.0.256 → 1.0.258

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.
@@ -51,7 +51,7 @@ var LanguageDetector__default = /*#__PURE__*/_interopDefaultLegacy(LanguageDetec
51
51
  var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
52
52
  var SignatureCanvas__default = /*#__PURE__*/_interopDefaultLegacy(SignatureCanvas);
53
53
 
54
- var webSdkVersion = '1.0.256';
54
+ var webSdkVersion = '1.0.258';
55
55
 
56
56
  function getPlatform() {
57
57
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -9014,64 +9014,55 @@ var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfie
9014
9014
  ctx === null || ctx === void 0 ? void 0 : ctx.scale(-1, 1);
9015
9015
  }
9016
9016
  return [4 /*yield*/, function renderPrediction() {
9017
- var _a;
9017
+ var _a, _b;
9018
9018
  return tslib.__awaiter(this, void 0, void 0, function () {
9019
- var vw, vh, prediction, faces;
9020
- return tslib.__generator(this, function (_b) {
9021
- switch (_b.label) {
9022
- case 0:
9023
- if (!detectorRef.current || !videoRef.current || currentLoopId !== loopId.current) return [2 /*return*/];
9024
- if (!(videoRef.current.readyState < 2)) return [3 /*break*/, 2];
9025
- return [4 /*yield*/, new Promise(function (resolve) {
9026
- if (videoRef.current) videoRef.current.onloadeddata = function () {
9027
- resolve([]);
9028
- };
9029
- })];
9030
- case 1:
9031
- _b.sent();
9032
- _b.label = 2;
9033
- case 2:
9034
- vw = videoRef.current.videoWidth;
9035
- vh = videoRef.current.videoHeight;
9036
- ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(videoRef.current, 0, 0, vw, vh);
9037
- // Detectors can throw errors, for example when using custom URLs that
9038
- // contain a model that doesn't provide the expected output.
9039
- try {
9040
- prediction = detectorRef.current.detectForVideo(videoRef.current, performance.now());
9041
- if (prediction) {
9042
- faces = prediction.detections.map(function (d) {
9043
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
9044
- return {
9045
- keypoints: d.keypoints.map(function (k) {
9046
- var _a;
9047
- return tslib.__assign(tslib.__assign({}, k), {
9048
- x: k.x * vw,
9049
- y: k.y * vh,
9050
- name: (_a = k.label) !== null && _a !== void 0 ? _a : ''
9051
- });
9052
- }),
9053
- box: {
9054
- xMin: (_b = (_a = d.boundingBox) === null || _a === void 0 ? void 0 : _a.originX) !== null && _b !== void 0 ? _b : 0,
9055
- 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),
9056
- yMin: (_h = (_g = d.boundingBox) === null || _g === void 0 ? void 0 : _g.originY) !== null && _h !== void 0 ? _h : 0,
9057
- 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),
9058
- width: (_p = (_o = d.boundingBox) === null || _o === void 0 ? void 0 : _o.width) !== null && _p !== void 0 ? _p : 0,
9059
- height: (_r = (_q = d.boundingBox) === null || _q === void 0 ? void 0 : _q.height) !== null && _r !== void 0 ? _r : 0
9060
- }
9061
- };
9062
- });
9063
- (_a = onPredictionHandler.current) === null || _a === void 0 ? void 0 : _a.call(onPredictionHandler, faces);
9064
- ctx && drawResults(ctx, faces, true, true);
9065
- }
9066
- } catch (error) {
9067
- console.error('caught face detection error', error);
9068
- // detector.dispose()
9019
+ var ctx, vw_1, vh_1, prediction, faces;
9020
+ return tslib.__generator(this, function (_c) {
9021
+ if (!detectorRef.current || !videoRef.current || currentLoopId !== loopId.current) return [2 /*return*/];
9022
+ ctx = (_a = canvasRef.current) === null || _a === void 0 ? void 0 : _a.getContext('2d');
9023
+ if (ctx && videoRef.current.readyState === 4) {
9024
+ vw_1 = videoRef.current.videoWidth;
9025
+ vh_1 = videoRef.current.videoHeight;
9026
+ ctx.drawImage(videoRef.current, 0, 0, vw_1, vh_1);
9027
+ prediction = void 0;
9028
+ // Detectors can throw errors, for example when using custom URLs that
9029
+ // contain a model that doesn't provide the expected output.
9030
+ try {
9031
+ prediction = detectorRef.current.detectForVideo(canvasRef.current, performance.now());
9032
+ if (prediction) {
9033
+ faces = prediction.detections.map(function (d) {
9034
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
9035
+ return {
9036
+ keypoints: d.keypoints.map(function (k) {
9037
+ var _a;
9038
+ return tslib.__assign(tslib.__assign({}, k), {
9039
+ x: k.x * vw_1,
9040
+ y: k.y * vh_1,
9041
+ name: (_a = k.label) !== null && _a !== void 0 ? _a : ''
9042
+ });
9043
+ }),
9044
+ box: {
9045
+ xMin: (_b = (_a = d.boundingBox) === null || _a === void 0 ? void 0 : _a.originX) !== null && _b !== void 0 ? _b : 0,
9046
+ 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),
9047
+ yMin: (_h = (_g = d.boundingBox) === null || _g === void 0 ? void 0 : _g.originY) !== null && _h !== void 0 ? _h : 0,
9048
+ 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),
9049
+ width: (_p = (_o = d.boundingBox) === null || _o === void 0 ? void 0 : _o.width) !== null && _p !== void 0 ? _p : 0,
9050
+ height: (_r = (_q = d.boundingBox) === null || _q === void 0 ? void 0 : _q.height) !== null && _r !== void 0 ? _r : 0
9051
+ }
9052
+ };
9053
+ });
9054
+ (_b = onPredictionHandler.current) === null || _b === void 0 ? void 0 : _b.call(onPredictionHandler, faces);
9055
+ ctx && drawResults(ctx, faces, true, true);
9069
9056
  }
9070
- timer = setTimeout(function () {
9071
- rafId.current = requestAnimationFrame(renderPrediction);
9072
- }, throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0);
9073
- return [2 /*return*/];
9057
+ } catch (error) {
9058
+ console.error('caught face detection error', error);
9059
+ // detector.dispose()
9060
+ }
9074
9061
  }
9062
+ timer = setTimeout(function () {
9063
+ rafId.current = requestAnimationFrame(renderPrediction);
9064
+ }, throttleMs !== null && throttleMs !== void 0 ? throttleMs : 0);
9065
+ return [2 /*return*/];
9075
9066
  });
9076
9067
  });
9077
9068
  }()];
@@ -9115,7 +9106,9 @@ var HighPerformanceSelfieGuidanceModelsProvider = function HighPerformanceSelfie
9115
9106
  }, [error, modelDownloadProgress, onPredictionMade, ready, start, stop]);
9116
9107
  return /*#__PURE__*/React__namespace.createElement(HighPerformanceSelfieGuidanceModelsContext.Provider, {
9117
9108
  value: value
9118
- }, children);
9109
+ }, /*#__PURE__*/React__namespace.createElement(InvisibleCanvas, {
9110
+ ref: canvasRef
9111
+ }), children);
9119
9112
  };
9120
9113
 
9121
9114
  var preloadModels = function preloadModels(_a) {
@@ -12511,41 +12504,41 @@ var reducer$3 = function reducer(state, action) {
12511
12504
  }
12512
12505
  };
12513
12506
  var SelfieCapture = function SelfieCapture(_a) {
12514
- var _b, _c;
12507
+ var _b;
12515
12508
  var onGuidanceSatisfied = _a.onGuidanceSatisfied,
12516
12509
  onGuidanceNotSatisfied = _a.onGuidanceNotSatisfied,
12517
12510
  onSelfieCaptured = _a.onSelfieCaptured,
12518
12511
  onTimeout = _a.onTimeout,
12519
12512
  onExit = _a.onExit,
12520
- _d = _a.timeoutDurationMs,
12521
- timeoutDurationMs = _d === void 0 ? 15000 : _d,
12513
+ _c = _a.timeoutDurationMs,
12514
+ timeoutDurationMs = _c === void 0 ? 15000 : _c,
12522
12515
  guidanceMessage = _a.guidanceMessage,
12523
12516
  guidanceSatisfied = _a.guidanceSatisfied,
12524
- _e = _a.classNames,
12525
- classNames = _e === void 0 ? {} : _e,
12526
- _f = _a.colors,
12527
- colors = _f === void 0 ? {} : _f,
12528
- _g = _a.verbiage,
12529
- rawVerbiage = _g === void 0 ? {} : _g,
12530
- _h = _a.debugMode,
12531
- debugMode = _h === void 0 ? false : _h;
12532
- var _j = useResizeObserver__default['default'](),
12533
- ref = _j.ref,
12534
- _k = _j.width,
12535
- width = _k === void 0 ? 1 : _k,
12536
- _l = _j.height,
12537
- height = _l === void 0 ? 1 : _l;
12538
- var _m = React.useReducer(reducer$3, initialState$3),
12539
- state = _m[0],
12540
- dispatch = _m[1];
12517
+ _d = _a.classNames,
12518
+ classNames = _d === void 0 ? {} : _d,
12519
+ _e = _a.colors,
12520
+ colors = _e === void 0 ? {} : _e,
12521
+ _f = _a.verbiage,
12522
+ rawVerbiage = _f === void 0 ? {} : _f,
12523
+ _g = _a.debugMode,
12524
+ debugMode = _g === void 0 ? false : _g;
12525
+ var _h = useResizeObserver__default['default'](),
12526
+ ref = _h.ref,
12527
+ _j = _h.width,
12528
+ width = _j === void 0 ? 1 : _j,
12529
+ _k = _h.height,
12530
+ height = _k === void 0 ? 1 : _k;
12531
+ var _l = React.useReducer(reducer$3, initialState$3),
12532
+ state = _l[0],
12533
+ dispatch = _l[1];
12541
12534
  var lastPredictionCanvas = React.useRef(null);
12542
- var _o = React.useContext(CameraStateContext),
12543
- cameraRef = _o.cameraRef,
12544
- cameraReady = _o.cameraReady,
12545
- videoRef = _o.videoRef;
12546
- var _p = React.useContext(HighPerformanceSelfieGuidanceModelsContext),
12547
- onPredictionMade = _p.onPredictionMade,
12548
- guidanceError = _p.error;
12535
+ var _m = React.useContext(CameraStateContext),
12536
+ cameraRef = _m.cameraRef,
12537
+ cameraReady = _m.cameraReady,
12538
+ videoRef = _m.videoRef;
12539
+ var _o = React.useContext(HighPerformanceSelfieGuidanceModelsContext),
12540
+ onPredictionMade = _o.onPredictionMade,
12541
+ guidanceError = _o.error;
12549
12542
  React.useEffect(function () {
12550
12543
  if (cameraReady && videoRef.current && videoRef.current.videoWidth !== 0) {
12551
12544
  dispatch({
@@ -12567,9 +12560,9 @@ var SelfieCapture = function SelfieCapture(_a) {
12567
12560
  });
12568
12561
  });
12569
12562
  }, [onPredictionMade]);
12570
- var _q = React.useState(false),
12571
- captureReady = _q[0],
12572
- setCaptureReady = _q[1];
12563
+ var _p = React.useState(false),
12564
+ captureReady = _p[0],
12565
+ setCaptureReady = _p[1];
12573
12566
  React.useEffect(function () {
12574
12567
  var timer;
12575
12568
  if (state.faceReady) {
@@ -12602,9 +12595,9 @@ var SelfieCapture = function SelfieCapture(_a) {
12602
12595
  });
12603
12596
  })();
12604
12597
  }, [captureReady, onSelfieCaptured, state.faces, videoRef]);
12605
- var _r = useTimeout(timeoutDurationMs, onTimeout),
12606
- timedOut = _r.timedOut,
12607
- timeoutStartedAt = _r.timeoutStartedAt;
12598
+ var _q = useTimeout(timeoutDurationMs, onTimeout),
12599
+ timedOut = _q.timedOut,
12600
+ timeoutStartedAt = _q.timeoutStartedAt;
12608
12601
  var debugScalingDetails = useDebugScalingDetails({
12609
12602
  enabled: debugMode,
12610
12603
  pageWidth: width,
@@ -12644,15 +12637,11 @@ var SelfieCapture = function SelfieCapture(_a) {
12644
12637
  }, /*#__PURE__*/React__default['default'].createElement(GuidanceMessage, {
12645
12638
  "$variant": satisfied ? 'positive' : 'negative',
12646
12639
  className: classNames.guidanceMessage
12647
- }, guidanceMessage))), debugMode && state.faces.length > 0 && ( /*#__PURE__*/React__default['default'].createElement(ObjectDetectionDebugOverlayDiv, {
12648
- "$flipX": !((_c = cameraRef.current) === null || _c === void 0 ? void 0 : _c.isRearFacing)
12649
- }, state.faces.map(function (face, i) {
12650
- var _a;
12640
+ }, guidanceMessage))), debugMode && state.faces.length > 0 && ( /*#__PURE__*/React__default['default'].createElement(ObjectDetectionDebugOverlayDiv, null, state.faces.map(function (face, i) {
12651
12641
  return /*#__PURE__*/React__default['default'].createElement(SelfieCaptureFaceDebugBox, {
12652
12642
  key: i,
12653
12643
  face: face,
12654
12644
  scaling: debugScalingDetails,
12655
- flipX: !((_a = cameraRef.current) === null || _a === void 0 ? void 0 : _a.isRearFacing),
12656
12645
  color: satisfied ? 'green' : 'red'
12657
12646
  });
12658
12647
  }))), 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, {