idmission-web-sdk 2.3.119 → 2.3.121

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
@@ -205,7 +205,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
205
205
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
206
206
  };
207
207
 
208
- var webSdkVersion = '2.3.119';
208
+ var webSdkVersion = '2.3.121';
209
209
 
210
210
  function getPlatform() {
211
211
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -14397,6 +14397,7 @@ var videoSignatureInitialState = {
14397
14397
  supportsRoundRect: undefined,
14398
14398
  nullChunksReceived: 0,
14399
14399
  timesSignatureCleared: 0,
14400
+ finalChunkReceived: false,
14400
14401
  onSignatureVideoCaptured: function onSignatureVideoCaptured() {
14401
14402
  return null;
14402
14403
  }
@@ -14465,6 +14466,7 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
14465
14466
  return __awaiter(this, void 0, void 0, function () {
14466
14467
  var recordingStoppedAt, mimeType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, acceptClickedAt, clearClickedAt, recordingStopRequestedAt, lastChunkReceivedAt, supportsRequestVideoFrameCallback, supportsRoundRect, nullChunksReceived, firstNullChunkReceivedAt, lastNullChunkReceivedAt, timesSignatureCleared, metadata;
14467
14468
  return __generator(this, function (_b) {
14469
+ if (get().recordingStoppedAt) return [2 /*return*/];
14468
14470
  recordingStoppedAt = performance.now();
14469
14471
  set({
14470
14472
  recordingStoppedAt: recordingStoppedAt
@@ -14519,11 +14521,18 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
14519
14521
  isRecording = !!recordingStartedAt && !recordingStopRequestedAt;
14520
14522
  if (!isRecording) return [2 /*return*/];
14521
14523
  set({
14522
- recordingStopRequestedAt: performance.now()
14524
+ recordingStopRequestedAt: performance.now(),
14525
+ recordingStoppedAt: undefined
14523
14526
  });
14524
- return [4 /*yield*/, waitForOneMoreChunk()];
14527
+ return [4 /*yield*/, waitForOneMoreChunk()
14528
+ // this represents the time that it is safe to release the camera access
14529
+ ];
14525
14530
  case 1:
14526
14531
  _b = _c.sent(), finalChunkReceived = _b.finalChunkReceived, timedOut = _b.timedOut, waitedMs = _b.waitedMs;
14532
+ // this represents the time that it is safe to release the camera access
14533
+ set({
14534
+ finalChunkReceived: true
14535
+ });
14527
14536
  if (!signatureRecorder) return [3 /*break*/, 2];
14528
14537
  signatureRecorder.onstop = processVideo;
14529
14538
  signatureRecorder.stop();
@@ -14564,7 +14573,8 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
14564
14573
  supportsRoundRect: undefined,
14565
14574
  nullChunksReceived: 0,
14566
14575
  firstNullChunkReceivedAt: undefined,
14567
- lastNullChunkReceivedAt: undefined
14576
+ lastNullChunkReceivedAt: undefined,
14577
+ finalChunkReceived: false
14568
14578
  });
14569
14579
  }
14570
14580
  });
@@ -14578,7 +14588,7 @@ var useVideoSignatureStore = create()(devtools(function (set, get) {
14578
14588
  */
14579
14589
  function waitForOneMoreChunk(delayMs, checkEveryMs, timeoutMs) {
14580
14590
  if (delayMs === void 0) {
14581
- delayMs = 1000;
14591
+ delayMs = 250;
14582
14592
  }
14583
14593
  if (checkEveryMs === void 0) {
14584
14594
  checkEveryMs = 100;
@@ -14616,9 +14626,12 @@ function waitForOneMoreChunk(delayMs, checkEveryMs, timeoutMs) {
14616
14626
  });
14617
14627
  }
14618
14628
  function VideoSignatureContextProvider(_a) {
14619
- var _b, _c;
14620
14629
  var children = _a.children;
14621
- var videoRef = useCameraStore().videoRef;
14630
+ var _b = useCameraStore(),
14631
+ videoRef = _b.videoRef,
14632
+ videoWidth = _b.videoWidth,
14633
+ videoHeight = _b.videoHeight,
14634
+ releaseCameraAccess = _b.releaseCameraAccess;
14622
14635
  var outputCanvas = useRef(null);
14623
14636
  useEffect(function () {
14624
14637
  return useVideoSignatureStore.setState({
@@ -14626,18 +14639,13 @@ function VideoSignatureContextProvider(_a) {
14626
14639
  });
14627
14640
  }, []);
14628
14641
  var drawOutputFrame = useCallback(function () {
14629
- if (!outputCanvas.current || !videoRef.current) return;
14642
+ if (!outputCanvas.current) return;
14630
14643
  var ctx = outputCanvas.current.getContext('2d');
14631
14644
  if (!ctx) return;
14632
- var _a = [videoRef.current.videoWidth, videoRef.current.videoHeight],
14645
+ var _a = [outputCanvas.current.width, outputCanvas.current.height],
14633
14646
  w = _a[0],
14634
14647
  h = _a[1];
14635
14648
  var isPortrait = w < h;
14636
- // Only update canvas dimensions if they changed (setting dimensions clears the canvas!)
14637
- if (outputCanvas.current.width !== w || outputCanvas.current.height !== h) {
14638
- outputCanvas.current.width = w;
14639
- outputCanvas.current.height = h;
14640
- }
14641
14649
  var rect = [w * (isPortrait ? 0.02 : 0.15),
14642
14650
  // x
14643
14651
  h * (isPortrait ? 0.15 : 0.25),
@@ -14646,7 +14654,9 @@ function VideoSignatureContextProvider(_a) {
14646
14654
  // width
14647
14655
  h * (isPortrait ? 0.7 : 0.5) // height
14648
14656
  ];
14649
- ctx.drawImage(videoRef.current, 0, 0, w, h);
14657
+ if (videoRef.current) {
14658
+ ctx.drawImage(videoRef.current, 0, 0, w, h);
14659
+ }
14650
14660
  ctx.beginPath();
14651
14661
  ctx.fillStyle = 'rgba(255,255,255,0.5)';
14652
14662
  var supportsRoundRect = typeof ctx.roundRect === 'function';
@@ -14668,11 +14678,15 @@ function VideoSignatureContextProvider(_a) {
14668
14678
  ctx.drawImage.apply(ctx, __spreadArray([signatureCanvas], rect, false));
14669
14679
  }
14670
14680
  }, [videoRef]);
14671
- useVideoFrameLoop(videoRef, drawOutputFrame);
14681
+ var finalChunkReceived = useVideoSignatureStore().finalChunkReceived;
14682
+ useEffect(function () {
14683
+ if (finalChunkReceived) releaseCameraAccess();
14684
+ }, [finalChunkReceived, releaseCameraAccess]);
14685
+ useVideoFrameLoop(videoRef, drawOutputFrame, !finalChunkReceived);
14672
14686
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children, /*#__PURE__*/React__default.createElement(InvisibleCanvas, {
14673
14687
  ref: outputCanvas,
14674
- width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
14675
- height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
14688
+ width: videoWidth,
14689
+ height: videoHeight
14676
14690
  }));
14677
14691
  }
14678
14692
  function requestVideoFrameCallback(video, onFrame) {
@@ -14692,8 +14706,11 @@ function requestVideoFrameCallback(video, onFrame) {
14692
14706
  };
14693
14707
  }
14694
14708
  }
14695
- function videoFrameLoop(video, onFrame) {
14696
- if (!video) return;
14709
+ function videoFrameLoop(video, onFrame, running) {
14710
+ if (running === void 0) {
14711
+ running = true;
14712
+ }
14713
+ if (!video || !running) return;
14697
14714
  var cancelFn;
14698
14715
  var canceled = false;
14699
14716
  function onFrameRecursive() {
@@ -14714,10 +14731,13 @@ function videoFrameLoop(video, onFrame) {
14714
14731
  if (cancelFn !== undefined) cancelFn();
14715
14732
  };
14716
14733
  }
14717
- function useVideoFrameLoop(ref, onFrame) {
14734
+ function useVideoFrameLoop(ref, onFrame, running) {
14735
+ if (running === void 0) {
14736
+ running = true;
14737
+ }
14718
14738
  useEffect(function () {
14719
- return videoFrameLoop(ref.current, onFrame);
14720
- }, [onFrame, ref]);
14739
+ return videoFrameLoop(ref.current, onFrame, running);
14740
+ }, [onFrame, ref, running]);
14721
14741
  }
14722
14742
  function calculateAndStoreOndataavailableRate() {
14723
14743
  if (ondataavailableInvocations.length < 2 || !ondataavailableStartTime) {