idmission-web-sdk 2.3.120 → 2.3.122

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.120';
214
+ var webSdkVersion = '2.3.122';
215
215
 
216
216
  function getPlatform() {
217
217
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -24302,6 +24302,8 @@
24302
24302
  supportsRoundRect: undefined,
24303
24303
  nullChunksReceived: 0,
24304
24304
  timesSignatureCleared: 0,
24305
+ finalChunkReceived: false,
24306
+ requestDataInterval: undefined,
24305
24307
  onSignatureVideoCaptured: function onSignatureVideoCaptured() {
24306
24308
  return null;
24307
24309
  }
@@ -24359,8 +24361,12 @@
24359
24361
  });
24360
24362
  }
24361
24363
  };
24362
- signatureRecorder.start(250);
24364
+ signatureRecorder.start();
24365
+ var interval = setInterval(function () {
24366
+ return signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.requestData();
24367
+ }, 250);
24363
24368
  set({
24369
+ requestDataInterval: interval,
24364
24370
  recordingStartRequestedAt: performance.now()
24365
24371
  });
24366
24372
  },
@@ -24390,8 +24396,8 @@
24390
24396
  },
24391
24397
  diagnostics: {
24392
24398
  nullChunksReceived: nullChunksReceived,
24393
- firstNullChunkReceivedAt: firstNullChunkReceivedAt,
24394
- lastNullChunkReceivedAt: lastNullChunkReceivedAt,
24399
+ firstNullChunkReceivedAt: firstNullChunkReceivedAt ? Math.ceil(firstNullChunkReceivedAt) : 0,
24400
+ lastNullChunkReceivedAt: lastNullChunkReceivedAt ? Math.ceil(lastNullChunkReceivedAt) : 0,
24395
24401
  finalChunkReceived: finalChunkReceived,
24396
24402
  finalChunkTimedOut: timedOut,
24397
24403
  finalChunkWaitedMs: Math.ceil(waitedMs),
@@ -24428,9 +24434,16 @@
24428
24434
  recordingStopRequestedAt: performance.now(),
24429
24435
  recordingStoppedAt: undefined
24430
24436
  });
24431
- return [4 /*yield*/, waitForOneMoreChunk()];
24437
+ clearInterval(get().requestDataInterval);
24438
+ return [4 /*yield*/, waitForOneMoreChunk()
24439
+ // this represents the time that it is safe to release the camera access
24440
+ ];
24432
24441
  case 1:
24433
24442
  _b = _c.sent(), finalChunkReceived = _b.finalChunkReceived, timedOut = _b.timedOut, waitedMs = _b.waitedMs;
24443
+ // this represents the time that it is safe to release the camera access
24444
+ set({
24445
+ finalChunkReceived: true
24446
+ });
24434
24447
  if (!signatureRecorder) return [3 /*break*/, 2];
24435
24448
  signatureRecorder.onstop = processVideo;
24436
24449
  signatureRecorder.stop();
@@ -24466,12 +24479,13 @@
24466
24479
  signatureStartedAt: undefined,
24467
24480
  signatureEndedAt: undefined,
24468
24481
  acceptClickedAt: undefined,
24469
- clearClickedAt: undefined,
24482
+ // Note: clearClickedAt is intentionally preserved for telemetry metadata
24470
24483
  supportsRequestVideoFrameCallback: undefined,
24471
24484
  supportsRoundRect: undefined,
24472
24485
  nullChunksReceived: 0,
24473
24486
  firstNullChunkReceivedAt: undefined,
24474
- lastNullChunkReceivedAt: undefined
24487
+ lastNullChunkReceivedAt: undefined,
24488
+ finalChunkReceived: false
24475
24489
  });
24476
24490
  }
24477
24491
  });
@@ -24485,7 +24499,7 @@
24485
24499
  */
24486
24500
  function waitForOneMoreChunk(delayMs, checkEveryMs, timeoutMs) {
24487
24501
  if (delayMs === void 0) {
24488
- delayMs = 1000;
24502
+ delayMs = 250;
24489
24503
  }
24490
24504
  if (checkEveryMs === void 0) {
24491
24505
  checkEveryMs = 100;
@@ -24494,8 +24508,10 @@
24494
24508
  timeoutMs = 3000;
24495
24509
  }
24496
24510
  return new Promise(function (resolve) {
24511
+ var _a;
24497
24512
  var start = performance.now();
24498
- var initialLastChunkReceivedAt = useVideoSignatureStore.getState().lastChunkReceivedAt;
24513
+ var initialLastChunkReceivedAt = (_a = useVideoSignatureStore.getState().lastChunkReceivedAt) !== null && _a !== void 0 ? _a : start;
24514
+ signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.requestData();
24499
24515
  function checkForChunk() {
24500
24516
  var lastChunkReceivedAt = useVideoSignatureStore.getState().lastChunkReceivedAt;
24501
24517
  var waitedMs = performance.now() - start;
@@ -24523,9 +24539,12 @@
24523
24539
  });
24524
24540
  }
24525
24541
  function VideoSignatureContextProvider(_a) {
24526
- var _b, _c;
24527
24542
  var children = _a.children;
24528
- var videoRef = useCameraStore().videoRef;
24543
+ var _b = useCameraStore(),
24544
+ videoRef = _b.videoRef,
24545
+ videoWidth = _b.videoWidth,
24546
+ videoHeight = _b.videoHeight,
24547
+ releaseCameraAccess = _b.releaseCameraAccess;
24529
24548
  var outputCanvas = React.useRef(null);
24530
24549
  React.useEffect(function () {
24531
24550
  return useVideoSignatureStore.setState({
@@ -24533,18 +24552,13 @@
24533
24552
  });
24534
24553
  }, []);
24535
24554
  var drawOutputFrame = React.useCallback(function () {
24536
- if (!outputCanvas.current || !videoRef.current) return;
24555
+ if (!outputCanvas.current) return;
24537
24556
  var ctx = outputCanvas.current.getContext('2d');
24538
24557
  if (!ctx) return;
24539
- var _a = [videoRef.current.videoWidth, videoRef.current.videoHeight],
24558
+ var _a = [outputCanvas.current.width, outputCanvas.current.height],
24540
24559
  w = _a[0],
24541
24560
  h = _a[1];
24542
24561
  var isPortrait = w < h;
24543
- // Only update canvas dimensions if they changed (setting dimensions clears the canvas!)
24544
- if (outputCanvas.current.width !== w || outputCanvas.current.height !== h) {
24545
- outputCanvas.current.width = w;
24546
- outputCanvas.current.height = h;
24547
- }
24548
24562
  var rect = [w * (isPortrait ? 0.02 : 0.15),
24549
24563
  // x
24550
24564
  h * (isPortrait ? 0.15 : 0.25),
@@ -24553,7 +24567,9 @@
24553
24567
  // width
24554
24568
  h * (isPortrait ? 0.7 : 0.5) // height
24555
24569
  ];
24556
- ctx.drawImage(videoRef.current, 0, 0, w, h);
24570
+ if (videoRef.current) {
24571
+ ctx.drawImage(videoRef.current, 0, 0, w, h);
24572
+ }
24557
24573
  ctx.beginPath();
24558
24574
  ctx.fillStyle = 'rgba(255,255,255,0.5)';
24559
24575
  var supportsRoundRect = typeof ctx.roundRect === 'function';
@@ -24575,11 +24591,15 @@
24575
24591
  ctx.drawImage.apply(ctx, __spreadArray([signatureCanvas], rect, false));
24576
24592
  }
24577
24593
  }, [videoRef]);
24578
- useVideoFrameLoop(videoRef, drawOutputFrame);
24594
+ var finalChunkReceived = useVideoSignatureStore().finalChunkReceived;
24595
+ React.useEffect(function () {
24596
+ if (finalChunkReceived) releaseCameraAccess();
24597
+ }, [finalChunkReceived, releaseCameraAccess]);
24598
+ useVideoFrameLoop(videoRef, drawOutputFrame, !finalChunkReceived);
24579
24599
  return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(InvisibleCanvas, {
24580
24600
  ref: outputCanvas,
24581
- width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
24582
- height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
24601
+ width: videoWidth,
24602
+ height: videoHeight
24583
24603
  }));
24584
24604
  }
24585
24605
  function requestVideoFrameCallback(video, onFrame) {
@@ -24599,8 +24619,11 @@
24599
24619
  };
24600
24620
  }
24601
24621
  }
24602
- function videoFrameLoop(video, onFrame) {
24603
- if (!video) return;
24622
+ function videoFrameLoop(video, onFrame, running) {
24623
+ if (running === void 0) {
24624
+ running = true;
24625
+ }
24626
+ if (!video || !running) return;
24604
24627
  var cancelFn;
24605
24628
  var canceled = false;
24606
24629
  function onFrameRecursive() {
@@ -24621,10 +24644,13 @@
24621
24644
  if (cancelFn !== undefined) cancelFn();
24622
24645
  };
24623
24646
  }
24624
- function useVideoFrameLoop(ref, onFrame) {
24647
+ function useVideoFrameLoop(ref, onFrame, running) {
24648
+ if (running === void 0) {
24649
+ running = true;
24650
+ }
24625
24651
  React.useEffect(function () {
24626
- return videoFrameLoop(ref.current, onFrame);
24627
- }, [onFrame, ref]);
24652
+ return videoFrameLoop(ref.current, onFrame, running);
24653
+ }, [onFrame, ref, running]);
24628
24654
  }
24629
24655
  function calculateAndStoreOndataavailableRate() {
24630
24656
  if (ondataavailableInvocations.length < 2 || !ondataavailableStartTime) {