idmission-web-sdk 2.3.12 → 2.3.14

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.3.12';
207
+ var webSdkVersion = '2.3.14';
208
208
 
209
209
  function getPlatform() {
210
210
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -13491,15 +13491,34 @@ var useVideoRecorder = function useVideoRecorder(camera, audioStream, mergeAVStr
13491
13491
  };
13492
13492
 
13493
13493
  var signatureRecorder = null;
13494
- function getSignatureRecorder() {
13494
+ var getSignatureRecorder = function getSignatureRecorder() {
13495
13495
  return signatureRecorder;
13496
- }
13497
- function setSignatureRecorder(recorder) {
13498
- signatureRecorder = recorder;
13499
- }
13496
+ };
13497
+ var setSignatureRecorder = function setSignatureRecorder(recorder) {
13498
+ return signatureRecorder = recorder;
13499
+ };
13500
13500
  var signatureChunks = [];
13501
- function clearSignatureChunks() {
13502
- signatureChunks = [];
13501
+ var clearSignatureChunks = function clearSignatureChunks() {
13502
+ return signatureChunks = [];
13503
+ };
13504
+ var recordingLock = false;
13505
+ var setRecordingLock = function setRecordingLock(lock) {
13506
+ return recordingLock = lock;
13507
+ };
13508
+ var recordingLockEngaged = function recordingLockEngaged() {
13509
+ return recordingLock;
13510
+ };
13511
+ function waitForCanvasAvailable(canvasRef) {
13512
+ if (canvasRef.current) return Promise.resolve(null);
13513
+ return new Promise(function (resolve) {
13514
+ var interval = setInterval(function () {
13515
+ log('VideoSignatureContext: waiting for output canvas');
13516
+ if (canvasRef.current) {
13517
+ clearInterval(interval);
13518
+ resolve(null);
13519
+ }
13520
+ }, 100);
13521
+ });
13503
13522
  }
13504
13523
  var videoSignatureInitialState = {
13505
13524
  startRecording: function startRecording() {
@@ -13556,7 +13575,6 @@ function VideoSignatureContextProvider(_a) {
13556
13575
  stopRecordingAudio = _k.stopRecordingAudio,
13557
13576
  clearRecordedVideoData = _k.clearRecordedData;
13558
13577
  var outputCanvas = useRef(null);
13559
- var recordingLock = useRef(false);
13560
13578
  var onRecordingStopped = useRef(function () {});
13561
13579
  var _l = useState(false),
13562
13580
  isRecording = _l[0],
@@ -13575,67 +13593,46 @@ function VideoSignatureContextProvider(_a) {
13575
13593
  setIsRecording(true);
13576
13594
  onRecordingStopped.current = function () {};
13577
13595
  };
13578
- recordingLock.current = false;
13596
+ setRecordingLock(false);
13579
13597
  setIsRecording(false);
13580
13598
  (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
13581
13599
  setSignatureRecorder(null);
13582
13600
  }, []);
13583
13601
  useEffect(function () {
13584
13602
  if (!isRecording) return;
13585
- if (recordingLock.current) return;
13586
- recordingLock.current = true;
13587
- (function () {
13588
- return __awaiter(_this, void 0, void 0, function () {
13589
- var stream, tracks, audioTrack, signatureRecorder;
13590
- var _a;
13591
- return __generator(this, function (_b) {
13592
- switch (_b.label) {
13593
- case 0:
13594
- if (!!outputCanvas.current) return [3 /*break*/, 2];
13595
- return [4 /*yield*/, new Promise(function (resolve) {
13596
- var interval = setInterval(function () {
13597
- if (outputCanvas.current) {
13598
- clearInterval(interval);
13599
- resolve(null);
13600
- }
13601
- }, 10);
13602
- })];
13603
- case 1:
13604
- _b.sent();
13605
- _b.label = 2;
13606
- case 2:
13607
- clearSignatureChunks();
13608
- clearRecordedVideoData();
13609
- startRecordingVideo();
13610
- if (captureAudio) startRecordingAudio();
13611
- stream = outputCanvas.current.captureStream(24 /* fps */);
13612
- tracks = [stream.getVideoTracks()[0]];
13613
- audioTrack = (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks()) === null || _a === void 0 ? void 0 : _a[0];
13614
- if (audioTrack) tracks.push(audioTrack);
13615
- signatureRecorder = new MediaRecorder(new MediaStream(tracks), {
13616
- videoBitsPerSecond: 270000,
13617
- audioBitsPerSecond: 32000
13618
- });
13619
- setSignatureRecorder(signatureRecorder);
13620
- signatureRecorder.start();
13621
- signatureRecorder.ondataavailable = function (event) {
13622
- signatureChunks.push(event.data);
13623
- };
13624
- signatureRecorder.onstop = function () {
13625
- var blob = new Blob(signatureChunks, {
13626
- type: 'video/mp4'
13627
- });
13628
- setSignatureVideoData(blob);
13629
- setSignatureVideoUrl(URL.createObjectURL(blob));
13630
- clearSignatureChunks();
13631
- setSignatureRecorder(null);
13632
- onRecordingStopped.current();
13633
- };
13634
- return [2 /*return*/];
13635
- }
13636
- });
13603
+ if (recordingLockEngaged()) return;
13604
+ setRecordingLock(true);
13605
+ waitForCanvasAvailable(outputCanvas).then(function () {
13606
+ var _a;
13607
+ clearSignatureChunks();
13608
+ clearRecordedVideoData();
13609
+ startRecordingVideo();
13610
+ if (captureAudio) startRecordingAudio();
13611
+ var stream = outputCanvas.current.captureStream(24 /* fps */);
13612
+ var tracks = [stream.getVideoTracks()[0]];
13613
+ var audioTrack = (_a = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks()) === null || _a === void 0 ? void 0 : _a[0];
13614
+ if (audioTrack) tracks.push(audioTrack);
13615
+ var signatureRecorder = new MediaRecorder(new MediaStream(tracks), {
13616
+ videoBitsPerSecond: 270000,
13617
+ audioBitsPerSecond: 32000
13637
13618
  });
13638
- })();
13619
+ setSignatureRecorder(signatureRecorder);
13620
+ signatureRecorder.ondataavailable = function (event) {
13621
+ signatureChunks.push(event.data);
13622
+ };
13623
+ signatureRecorder.onstop = function () {
13624
+ log('VideoSignatureContext: onstop');
13625
+ var blob = new Blob(signatureChunks, {
13626
+ type: 'video/mp4'
13627
+ });
13628
+ setSignatureVideoData(blob);
13629
+ setSignatureVideoUrl(URL.createObjectURL(blob));
13630
+ clearSignatureChunks();
13631
+ setSignatureRecorder(null);
13632
+ onRecordingStopped.current();
13633
+ };
13634
+ signatureRecorder.start(1000);
13635
+ });
13639
13636
  }, [audioStream, captureAudio, clearRecordedVideoData, isRecording, startRecordingAudio, startRecordingVideo]);
13640
13637
  var animationFrame = useRef(0);
13641
13638
  useEffect(function () {
@@ -13677,16 +13674,22 @@ function VideoSignatureContextProvider(_a) {
13677
13674
  return __generator(this, function (_b) {
13678
13675
  switch (_b.label) {
13679
13676
  case 0:
13677
+ log('VideoSignatureContext: onAcceptClicked');
13680
13678
  if (!signaturePad.current) return [2 /*return*/];
13679
+ log('VideoSignatureContext: building signature data...');
13681
13680
  signatureData = buildSignatureData(signaturePad.current);
13681
+ log('VideoSignatureContext: exporting signature image...');
13682
13682
  return [4 /*yield*/, exportSignatureImage(signaturePad.current)];
13683
13683
  case 1:
13684
13684
  imageUrl = _b.sent();
13685
13685
  if (imageUrl) signatureData.fileContent = dataUrlToBase64Sync(imageUrl);
13686
+ log('VideoSignatureContext: setting signature data url...');
13686
13687
  setSignatureDataUrl(imageUrl);
13687
13688
  setSignatureData(signatureData);
13689
+ log('VideoSignatureContext: stopping recording...');
13688
13690
  stopRecordingVideo();
13689
13691
  stopRecordingAudio();
13692
+ log('VideoSignatureContext: stopping signature recorder...');
13690
13693
  (_a = getSignatureRecorder()) === null || _a === void 0 ? void 0 : _a.stop();
13691
13694
  return [2 /*return*/];
13692
13695
  }