idmission-web-sdk 1.0.268 → 1.0.270

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.268';
54
+ var webSdkVersion = '1.0.270';
55
55
 
56
56
  function getPlatform() {
57
57
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -13638,13 +13638,12 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13638
13638
  height = _l.height;
13639
13639
  var signaturePad = React.useRef(null);
13640
13640
  var signatureRecorder = React.useRef(null);
13641
- var recordedChunks = React.useRef([]);
13641
+ // const recordedChunks = useRef<BlobPart[]>([])
13642
13642
  var onPredictionMade = React.useContext(HighPerformanceSelfieGuidanceModelsContext).onPredictionMade;
13643
13643
  var _m = useVideoRecorder(cameraRef.current),
13644
13644
  isRecording = _m.isRecording,
13645
13645
  startRecording = _m.startRecording,
13646
- stopRecording = _m.stopRecording,
13647
- videoUrl = _m.videoUrl;
13646
+ stopRecording = _m.stopRecording;
13648
13647
  var _o = React.useState(null),
13649
13648
  signatureData = _o[0],
13650
13649
  setSignatureData = _o[1];
@@ -13652,8 +13651,8 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13652
13651
  signatureDataUrl = _p[0],
13653
13652
  setSignatureDataUrl = _p[1];
13654
13653
  var _q = React.useState(null),
13655
- signatureVideoData = _q[0],
13656
- setSignatureVideoData = _q[1];
13654
+ signatureVideoData = _q[0];
13655
+ _q[1];
13657
13656
  colors.guidanceMessageBackgroundColor || (colors.guidanceMessageBackgroundColor = '#ccc');
13658
13657
  colors.guidanceMessageTextColor || (colors.guidanceMessageTextColor = 'black');
13659
13658
  var verbiage = useTranslations(rawVerbiage, {
@@ -13662,32 +13661,35 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13662
13661
  clearBtnText: 'Clear'
13663
13662
  });
13664
13663
  var outputCanvas = React.useRef(null);
13664
+ var recordingLock = React.useRef(false);
13665
13665
  React.useEffect(function () {
13666
- // delay 100ms to make sure outputCanvas has rendered.
13667
- setTimeout(function () {
13668
- if (!isRecording && !videoUrl && !!outputCanvas.current) {
13669
- startRecording();
13670
- var stream = outputCanvas.current.captureStream(25 /* fps */);
13671
- signatureRecorder.current = new MediaRecorder(stream, {
13672
- videoBitsPerSecond: 270000
13673
- });
13674
- signatureRecorder.current.start();
13675
- signatureRecorder.current.ondataavailable = function (event) {
13676
- var _a;
13677
- recordedChunks.current.push(event.data);
13678
- if (((_a = signatureRecorder.current) === null || _a === void 0 ? void 0 : _a.state) === 'recording') {
13679
- signatureRecorder.current.stop();
13666
+ if (recordingLock.current) return;
13667
+ recordingLock.current = true;
13668
+ (function () {
13669
+ return tslib.__awaiter(void 0, void 0, void 0, function () {
13670
+ return tslib.__generator(this, function (_a) {
13671
+ switch (_a.label) {
13672
+ case 0:
13673
+ if (!!outputCanvas.current) return [3 /*break*/, 2];
13674
+ return [4 /*yield*/, new Promise(function (resolve) {
13675
+ var interval = setInterval(function () {
13676
+ if (outputCanvas.current) {
13677
+ clearInterval(interval);
13678
+ resolve(null);
13679
+ }
13680
+ }, 10);
13681
+ })];
13682
+ case 1:
13683
+ _a.sent();
13684
+ _a.label = 2;
13685
+ case 2:
13686
+ startRecording();
13687
+ return [2 /*return*/];
13680
13688
  }
13681
- };
13682
- signatureRecorder.current.onstop = function () {
13683
- var blob = new Blob(recordedChunks.current, {
13684
- type: 'video/mp4'
13685
- });
13686
- setSignatureVideoData(blob);
13687
- };
13688
- }
13689
- }, 100);
13690
- }, [isRecording, startRecording, videoUrl]);
13689
+ });
13690
+ });
13691
+ })();
13692
+ }, [startRecording]);
13691
13693
  React.useEffect(function () {
13692
13694
  if (signatureVideoData && signatureData && signatureDataUrl) {
13693
13695
  onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(signatureVideoData, signatureData, signatureDataUrl);
@@ -13709,26 +13711,19 @@ var VideoSignatureCapture = function VideoSignatureCapture(_a) {
13709
13711
  if (!ctx) return;
13710
13712
  animationFrame.current = requestAnimationFrame(function runFrame() {
13711
13713
  return tslib.__awaiter(this, void 0, void 0, function () {
13714
+ var rect;
13712
13715
  return tslib.__generator(this, function (_a) {
13713
13716
  if (!signaturePad.current || !videoRef.current || !outputCanvas.current) {
13714
13717
  cancelAnimationFrame(animationFrame.current);
13715
13718
  return [2 /*return*/];
13716
13719
  }
13717
- // const rect: [number, number, number, number] = [
13718
- // w * (isPortrait ? 0.02 : 0.15),
13719
- // h * (isPortrait ? 0.15 : 0.25),
13720
- // w * (isPortrait ? 0.96 : 0.7),
13721
- // h * (isPortrait ? 0.7 : 0.5),
13722
- // ]
13723
- //
13724
- // ctx.drawImage(videoRef.current, 0, 0, w, h)
13725
- //
13726
- // ctx.beginPath()
13727
- // ctx.fillStyle = 'rgba(255,255,255,0.5)'
13728
- // ctx.roundRect(...rect, 16)
13729
- // ctx.fill()
13730
- //
13731
- // ctx.drawImage(signaturePad.current.getCanvas(), ...rect)
13720
+ rect = [w * (isPortrait ? 0.02 : 0.15), h * (isPortrait ? 0.15 : 0.25), w * (isPortrait ? 0.96 : 0.7), h * (isPortrait ? 0.7 : 0.5)];
13721
+ ctx.drawImage(videoRef.current, 0, 0, w, h);
13722
+ ctx.beginPath();
13723
+ ctx.fillStyle = 'rgba(255,255,255,0.5)';
13724
+ ctx.roundRect.apply(ctx, tslib.__spreadArray(tslib.__spreadArray([], rect, false), [16], false));
13725
+ ctx.fill();
13726
+ ctx.drawImage.apply(ctx, tslib.__spreadArray([signaturePad.current.getCanvas()], rect, false));
13732
13727
  animationFrame.current = requestAnimationFrame(runFrame);
13733
13728
  return [2 /*return*/];
13734
13729
  });