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.
@@ -211,7 +211,7 @@
211
211
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
212
212
  };
213
213
 
214
- var webSdkVersion = '2.3.119';
214
+ var webSdkVersion = '2.3.121';
215
215
 
216
216
  function getPlatform() {
217
217
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -24302,6 +24302,7 @@
24302
24302
  supportsRoundRect: undefined,
24303
24303
  nullChunksReceived: 0,
24304
24304
  timesSignatureCleared: 0,
24305
+ finalChunkReceived: false,
24305
24306
  onSignatureVideoCaptured: function onSignatureVideoCaptured() {
24306
24307
  return null;
24307
24308
  }
@@ -24370,6 +24371,7 @@
24370
24371
  return __awaiter(this, void 0, void 0, function () {
24371
24372
  var recordingStoppedAt, mimeType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, acceptClickedAt, clearClickedAt, recordingStopRequestedAt, lastChunkReceivedAt, supportsRequestVideoFrameCallback, supportsRoundRect, nullChunksReceived, firstNullChunkReceivedAt, lastNullChunkReceivedAt, timesSignatureCleared, metadata;
24372
24373
  return __generator(this, function (_b) {
24374
+ if (get().recordingStoppedAt) return [2 /*return*/];
24373
24375
  recordingStoppedAt = performance.now();
24374
24376
  set({
24375
24377
  recordingStoppedAt: recordingStoppedAt
@@ -24424,11 +24426,18 @@
24424
24426
  isRecording = !!recordingStartedAt && !recordingStopRequestedAt;
24425
24427
  if (!isRecording) return [2 /*return*/];
24426
24428
  set({
24427
- recordingStopRequestedAt: performance.now()
24429
+ recordingStopRequestedAt: performance.now(),
24430
+ recordingStoppedAt: undefined
24428
24431
  });
24429
- return [4 /*yield*/, waitForOneMoreChunk()];
24432
+ return [4 /*yield*/, waitForOneMoreChunk()
24433
+ // this represents the time that it is safe to release the camera access
24434
+ ];
24430
24435
  case 1:
24431
24436
  _b = _c.sent(), finalChunkReceived = _b.finalChunkReceived, timedOut = _b.timedOut, waitedMs = _b.waitedMs;
24437
+ // this represents the time that it is safe to release the camera access
24438
+ set({
24439
+ finalChunkReceived: true
24440
+ });
24432
24441
  if (!signatureRecorder) return [3 /*break*/, 2];
24433
24442
  signatureRecorder.onstop = processVideo;
24434
24443
  signatureRecorder.stop();
@@ -24469,7 +24478,8 @@
24469
24478
  supportsRoundRect: undefined,
24470
24479
  nullChunksReceived: 0,
24471
24480
  firstNullChunkReceivedAt: undefined,
24472
- lastNullChunkReceivedAt: undefined
24481
+ lastNullChunkReceivedAt: undefined,
24482
+ finalChunkReceived: false
24473
24483
  });
24474
24484
  }
24475
24485
  });
@@ -24483,7 +24493,7 @@
24483
24493
  */
24484
24494
  function waitForOneMoreChunk(delayMs, checkEveryMs, timeoutMs) {
24485
24495
  if (delayMs === void 0) {
24486
- delayMs = 1000;
24496
+ delayMs = 250;
24487
24497
  }
24488
24498
  if (checkEveryMs === void 0) {
24489
24499
  checkEveryMs = 100;
@@ -24521,9 +24531,12 @@
24521
24531
  });
24522
24532
  }
24523
24533
  function VideoSignatureContextProvider(_a) {
24524
- var _b, _c;
24525
24534
  var children = _a.children;
24526
- var videoRef = useCameraStore().videoRef;
24535
+ var _b = useCameraStore(),
24536
+ videoRef = _b.videoRef,
24537
+ videoWidth = _b.videoWidth,
24538
+ videoHeight = _b.videoHeight,
24539
+ releaseCameraAccess = _b.releaseCameraAccess;
24527
24540
  var outputCanvas = React.useRef(null);
24528
24541
  React.useEffect(function () {
24529
24542
  return useVideoSignatureStore.setState({
@@ -24531,18 +24544,13 @@
24531
24544
  });
24532
24545
  }, []);
24533
24546
  var drawOutputFrame = React.useCallback(function () {
24534
- if (!outputCanvas.current || !videoRef.current) return;
24547
+ if (!outputCanvas.current) return;
24535
24548
  var ctx = outputCanvas.current.getContext('2d');
24536
24549
  if (!ctx) return;
24537
- var _a = [videoRef.current.videoWidth, videoRef.current.videoHeight],
24550
+ var _a = [outputCanvas.current.width, outputCanvas.current.height],
24538
24551
  w = _a[0],
24539
24552
  h = _a[1];
24540
24553
  var isPortrait = w < h;
24541
- // Only update canvas dimensions if they changed (setting dimensions clears the canvas!)
24542
- if (outputCanvas.current.width !== w || outputCanvas.current.height !== h) {
24543
- outputCanvas.current.width = w;
24544
- outputCanvas.current.height = h;
24545
- }
24546
24554
  var rect = [w * (isPortrait ? 0.02 : 0.15),
24547
24555
  // x
24548
24556
  h * (isPortrait ? 0.15 : 0.25),
@@ -24551,7 +24559,9 @@
24551
24559
  // width
24552
24560
  h * (isPortrait ? 0.7 : 0.5) // height
24553
24561
  ];
24554
- ctx.drawImage(videoRef.current, 0, 0, w, h);
24562
+ if (videoRef.current) {
24563
+ ctx.drawImage(videoRef.current, 0, 0, w, h);
24564
+ }
24555
24565
  ctx.beginPath();
24556
24566
  ctx.fillStyle = 'rgba(255,255,255,0.5)';
24557
24567
  var supportsRoundRect = typeof ctx.roundRect === 'function';
@@ -24573,11 +24583,15 @@
24573
24583
  ctx.drawImage.apply(ctx, __spreadArray([signatureCanvas], rect, false));
24574
24584
  }
24575
24585
  }, [videoRef]);
24576
- useVideoFrameLoop(videoRef, drawOutputFrame);
24586
+ var finalChunkReceived = useVideoSignatureStore().finalChunkReceived;
24587
+ React.useEffect(function () {
24588
+ if (finalChunkReceived) releaseCameraAccess();
24589
+ }, [finalChunkReceived, releaseCameraAccess]);
24590
+ useVideoFrameLoop(videoRef, drawOutputFrame, !finalChunkReceived);
24577
24591
  return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(InvisibleCanvas, {
24578
24592
  ref: outputCanvas,
24579
- width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
24580
- height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
24593
+ width: videoWidth,
24594
+ height: videoHeight
24581
24595
  }));
24582
24596
  }
24583
24597
  function requestVideoFrameCallback(video, onFrame) {
@@ -24597,8 +24611,11 @@
24597
24611
  };
24598
24612
  }
24599
24613
  }
24600
- function videoFrameLoop(video, onFrame) {
24601
- if (!video) return;
24614
+ function videoFrameLoop(video, onFrame, running) {
24615
+ if (running === void 0) {
24616
+ running = true;
24617
+ }
24618
+ if (!video || !running) return;
24602
24619
  var cancelFn;
24603
24620
  var canceled = false;
24604
24621
  function onFrameRecursive() {
@@ -24619,10 +24636,13 @@
24619
24636
  if (cancelFn !== undefined) cancelFn();
24620
24637
  };
24621
24638
  }
24622
- function useVideoFrameLoop(ref, onFrame) {
24639
+ function useVideoFrameLoop(ref, onFrame, running) {
24640
+ if (running === void 0) {
24641
+ running = true;
24642
+ }
24623
24643
  React.useEffect(function () {
24624
- return videoFrameLoop(ref.current, onFrame);
24625
- }, [onFrame, ref]);
24644
+ return videoFrameLoop(ref.current, onFrame, running);
24645
+ }, [onFrame, ref, running]);
24626
24646
  }
24627
24647
  function calculateAndStoreOndataavailableRate() {
24628
24648
  if (ondataavailableInvocations.length < 2 || !ondataavailableStartTime) {