idmission-web-sdk 0.0.78 → 0.0.80

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
@@ -14,7 +14,7 @@ import useResizeObserver from 'use-resize-observer';
14
14
  import { FaceDetector, FilesetResolver } from '@mediapipe/tasks-vision';
15
15
  import SignatureCanvas from 'react-signature-canvas';
16
16
 
17
- var webSdkVersion = '0.0.78';
17
+ var webSdkVersion = '0.0.80';
18
18
 
19
19
  function getPlatform() {
20
20
  return window.platform;
@@ -1386,14 +1386,15 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
1386
1386
  if (!((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia)) return cleanup;
1387
1387
  (function () {
1388
1388
  return __awaiter(void 0, void 0, void 0, function () {
1389
- var stream, e_2;
1390
- return __generator(this, function (_a) {
1391
- switch (_a.label) {
1389
+ var stream, e_2, handleStreamEnded;
1390
+ var _a;
1391
+ return __generator(this, function (_b) {
1392
+ switch (_b.label) {
1392
1393
  case 0:
1393
1394
  stream = null;
1394
- _a.label = 1;
1395
+ _b.label = 1;
1395
1396
  case 1:
1396
- _a.trys.push([1, 3,, 4]);
1397
+ _b.trys.push([1, 3,, 4]);
1397
1398
  return [4, navigator.mediaDevices.getUserMedia({
1398
1399
  audio: requestMicrophoneAccess,
1399
1400
  video: {
@@ -1407,10 +1408,10 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
1407
1408
  }
1408
1409
  })];
1409
1410
  case 2:
1410
- stream = _a.sent();
1411
+ stream = _b.sent();
1411
1412
  return [3, 4];
1412
1413
  case 3:
1413
- e_2 = _a.sent();
1414
+ e_2 = _b.sent();
1414
1415
  if (e_2.name === 'NotAllowedError') {
1415
1416
  if (iphoneContinuityCameraAllowed) {
1416
1417
  setIphoneContinuityCameraAvailable(false);
@@ -1423,26 +1424,26 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
1423
1424
  return [3, 4];
1424
1425
  case 4:
1425
1426
  if (!!stream) return [3, 8];
1426
- _a.label = 5;
1427
+ _b.label = 5;
1427
1428
  case 5:
1428
- _a.trys.push([5, 7,, 8]);
1429
+ _b.trys.push([5, 7,, 8]);
1429
1430
  return [4, navigator.mediaDevices.getUserMedia({
1430
1431
  audio: false,
1431
1432
  video: true
1432
1433
  })];
1433
1434
  case 6:
1434
- stream = _a.sent();
1435
+ stream = _b.sent();
1435
1436
  console.log('opened stream with no width and height constraints');
1436
1437
  return [3, 8];
1437
1438
  case 7:
1438
- _a.sent();
1439
+ _b.sent();
1439
1440
  console.log('cannot open stream at all');
1440
1441
  return [3, 8];
1441
1442
  case 8:
1442
1443
  if (!stream) {
1443
1444
  throw new Error('failed to open camera');
1444
1445
  }
1445
- stream.getVideoTracks()[0].onended = function () {
1446
+ handleStreamEnded = function handleStreamEnded() {
1446
1447
  var _a;
1447
1448
  if (iphoneContinuityCameraAvailable && iphoneContinuityCameraAllowed) {
1448
1449
  console.log('someone unplugged the continuity camera');
@@ -1457,6 +1458,10 @@ var useHighestResCaptureDevice = function useHighestResCaptureDevice(_a) {
1457
1458
  setCaptureDevice(null);
1458
1459
  }
1459
1460
  };
1461
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', handleStreamEnded);
1462
+ stream.getVideoTracks().forEach(function (track) {
1463
+ track.onended = handleStreamEnded;
1464
+ });
1460
1465
  cameraRef.current = obtainCameraAccess(stream, videoDevice.label, videoRef.current);
1461
1466
  return [2];
1462
1467
  }