idmission-web-sdk 2.3.97 → 2.3.99

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
@@ -206,7 +206,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
206
206
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
207
207
  };
208
208
 
209
- var webSdkVersion = '2.3.97';
209
+ var webSdkVersion = '2.3.99';
210
210
 
211
211
  function getPlatform() {
212
212
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -14347,9 +14347,8 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
14347
14347
  if (!camera) throw new Error('Camera not found');
14348
14348
  // set our flag and clear whatever we have recorded so far.
14349
14349
  signatureChunks = [];
14350
- var outputCanvas = get().outputCanvas;
14351
14350
  // start recording from the output canvas to capture the signature
14352
- var outputStream = (_a = outputCanvas.current) === null || _a === void 0 ? void 0 : _a.captureStream(24);
14351
+ var outputStream = (_a = get().outputCanvas.current) === null || _a === void 0 ? void 0 : _a.captureStream(24);
14353
14352
  if (!outputStream) throw new Error('outputStream not found');
14354
14353
  var tracks = [outputStream.getVideoTracks()[0]];
14355
14354
  if (captureAudio) {
@@ -14556,37 +14555,12 @@ function VideoSignatureContextProvider(_a) {
14556
14555
  });
14557
14556
  });
14558
14557
  }, [videoRef, outputCanvas]);
14559
- useEffect(function () {
14560
- if (!signatureVideoRef.current) return;
14561
- var video = signatureVideoRef.current;
14562
- function onFrame() {
14563
- blankCheckPassed.current || (blankCheckPassed.current = !isVideoBlank(signatureVideoRef.current, frameCheckCanvas.current));
14564
- drawOutputFrame();
14565
- video.requestVideoFrameCallback(onFrame);
14566
- }
14567
- function onPlay() {
14568
- video.requestVideoFrameCallback(onFrame);
14569
- }
14570
- video.addEventListener('play', onPlay);
14571
- return function () {
14572
- video.removeEventListener('play', onPlay);
14573
- };
14574
- }, [drawOutputFrame]);
14575
- useEffect(function () {
14576
- if (!videoRef.current) return;
14577
- var video = videoRef.current;
14578
- function onFrame() {
14579
- drawOutputFrame();
14580
- video.requestVideoFrameCallback(onFrame);
14581
- }
14582
- function onPlay() {
14583
- video.requestVideoFrameCallback(onFrame);
14584
- }
14585
- video.addEventListener('play', onPlay);
14586
- return function () {
14587
- video.removeEventListener('play', onPlay);
14588
- };
14589
- }, [drawOutputFrame, videoRef]);
14558
+ var checkBlankAndDrawOutputFrame = useCallback(function () {
14559
+ blankCheckPassed.current || (blankCheckPassed.current = !isVideoBlank(signatureVideoRef.current, frameCheckCanvas.current));
14560
+ drawOutputFrame();
14561
+ }, [drawOutputFrame, signatureVideoRef]);
14562
+ useVideoFrameLoop(signatureVideoRef, checkBlankAndDrawOutputFrame);
14563
+ useVideoFrameLoop(videoRef, drawOutputFrame);
14590
14564
  var _g = useVideoSignatureStore(),
14591
14565
  signaturePad = _g.signaturePad,
14592
14566
  recordingStartedAt = _g.recordingStartedAt;
@@ -14629,6 +14603,32 @@ function isCanvasBlank(canvas) {
14629
14603
  });
14630
14604
  return result;
14631
14605
  }
14606
+ function requestVideoFrameCallback(video, onFrame) {
14607
+ if (typeof (video === null || video === void 0 ? void 0 : video.requestVideoFrameCallback) === 'function') {
14608
+ video.requestVideoFrameCallback(onFrame);
14609
+ } else {
14610
+ requestAnimationFrame(onFrame);
14611
+ }
14612
+ }
14613
+ function videoFrameLoop(video, onFrame) {
14614
+ if (!video) return;
14615
+ function onFrameRecursive() {
14616
+ onFrame();
14617
+ requestVideoFrameCallback(video, onFrameRecursive);
14618
+ }
14619
+ function onPlay() {
14620
+ requestVideoFrameCallback(video, onFrameRecursive);
14621
+ }
14622
+ video.addEventListener('play', onPlay);
14623
+ return function () {
14624
+ video.removeEventListener('play', onPlay);
14625
+ };
14626
+ }
14627
+ function useVideoFrameLoop(ref, onFrame) {
14628
+ useEffect(function () {
14629
+ return videoFrameLoop(ref.current, onFrame);
14630
+ }, [onFrame, ref]);
14631
+ }
14632
14632
 
14633
14633
  function VideoSignaturePad(_a) {
14634
14634
  var onAcceptBtnClicked = _a.onAcceptBtnClicked,